Reputation: 93
I am using the codrops border menu overlay and I wanted to find a way for the user to close an overlay on scroll. As of now, a user can click an overlay on a desktop or mobile to close it, but scrolling will just scroll the body underneath. I want it to instead close the overlay.
The overlay has an event listener, but it is only for click, not for body scroll. Is there a way to add a listener for body scroll to the overlay as well?
overlay.addEventListener( eventtype, closeClickFn );
Above adds an event listener to the overlay that says: on click/mobile touch, close the overlay.
Upvotes: 0
Views: 493
Reputation: 1058
Maybe you can attach to scroll event and then tricker a click to the codrops.
$(window).scroll(function(event) {
$('yourCodrop').click();
});
Upvotes: 1