0

I've used the code from this link:

https://dev.to/ljcdev/easy-hamburger-menu-with-js-2do0

I've changed the TS part into this (I'm working with Angular):

  toggleMenu() {
    if (this.menu.classList.contains("showMenu")) {
      this.menu.classList.remove("showMenu");
    } else {
      this.menu.classList.add("showMenu");
    }
  }

And like the headline suggests, it works just fine on my laptop (also on the Chrome's device mode), but when I deploy it and try it from an actual mobile device, it doesn't.

I've tried some solutions from other Stackoverflow threads, like:

css transition not working in mobile chrome, Problems with Z-index while browsing my page in mobile

But none did the trick... last chance before I delete this cursed dropdown menu code?

Thanks! :)

4
  • Could you create a runnable snippet which you've tested definitely shows the problem on mobile, otherwise we have to create something ourselves which may miss the vital bit that is going wrong. See stackoverflow.com/help/minimal-reproducible-example Commented Oct 30, 2024 at 8:54
  • When you say 'it doean't work' do you mean that the click on the menu isn't seen? What debugging have you tried on mobile? e.g. a simple alert in the toggle function to make sure it's actually being called, or in whatever function is called on the click? Commented Oct 30, 2024 at 8:55
  • @AHaworth first of all thanks! it works then it stops after pressing one of the links. sorry that it's in hebrew. it's for a (political) good cause... the url is: tacheles-7fbc518a6a19.herokuapp.com (i'll try to create a runnable snippet) Commented Oct 30, 2024 at 9:41
  • you can try using the popover api if you arent worried about safari support. this is a native browser api and it handled the complicated parts for you like the indexing. developer.mozilla.org/en-US/docs/Web/API/Popover_API Commented Nov 9, 2024 at 5:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.