Fix the navigation menu not opening on touch (#690)

* Fix iOS menu issue

* Fix burger menu iOS trigger

* Modify the menu script to work on iOS too

* Update main.rs

* Update main.rs

* Update main.rs
This commit is contained in:
Marek Ľach 2019-11-16 18:52:30 +01:00 committed by Ana Gelez
parent df6f398efc
commit c66ef5f85d

View file

@ -69,19 +69,19 @@ fn main() {
.ok();
}
/// Toggle menu on mobile device
/// Toggle menu on mobile devices
///
/// It should normally be working fine even without this code
/// But :focus-within is not yet supported by Webkit/Blink
fn menu() {
if let Some(button) = document().get_element_by_id("menu") {
if let Some(menu) = document().get_element_by_id("content") {
button.add_event_listener(|_: ClickEvent| {
button.add_event_listener(|_: TouchEnd| {
document()
.get_element_by_id("menu")
.map(|menu| menu.class_list().add("show"));
});
menu.add_event_listener(|_: ClickEvent| {
menu.add_event_listener(|_: TouchEnd| {
document()
.get_element_by_id("menu")
.map(|menu| menu.class_list().remove("show"));