I have a side menu that opens when a specific div reaches the top of the window.
The menu includes a toggle button for opening and closing it.
However, I am encountering an issue where the script keeps closing the menu on scroll even after manually opening it using the toggle button.
Is there a way to only open and close the menu once the div has passed the top of the screen, rather than the script continuously checking?
Here is my current script:
var stickyTop = $('#section1').offset().top;
$(window).on('scroll', function() {
if ($(window).scrollTop() >= stickyTop) {
$('.be-toggled').removeClass('toggled');
} else {
$('.be-toggled').addClass('toggled');
}
});
});