BUG with menu scrolling (sticky) and blocking of the expand and close buttons –
-
Hi,
I had an error with Elementor’s sticky menu.
The problem was that when I was scrolling through the menu on my smartphone, it automatically blocked the X button to close the menu and I couldn’t expand the submenu. I looked for a solution on the support website but didn’t find it. I decided to test the solutions and it turns out that adding this simple js code:
The problem occurs with scrolling, so to eliminate the bug I blocked the ability to scroll when the menu is open, when you close it you can continue scrolling the page (body).<script> document.addEventListener('DOMContentLoaded', function() { const mobileMenu = document.querySelector('.htmobile-menu-wrap'); // Funkcja do blokowania scrollowania function blockScroll() { document.body.style.overflow = 'hidden'; } // Funkcja do odblokowywania scrollowania function allowScroll() { document.body.style.overflow = ''; } // Obserwator zmian w klasach elementu const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.attributeName === 'class') { const hasInsideClass = mobileMenu.classList.contains('inside'); if (hasInsideClass) { blockScroll(); } else { allowScroll(); } } }); }); // Konfiguracja obserwatora observer.observe(mobileMenu, { attributes: true }); // Sprawdzenie na starcie, czy element ma klas? inside if (mobileMenu.classList.contains('inside')) { blockScroll(); } }); </script>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.