user1574832
user1574832

Reputation: 93

Close overlay on scroll

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

Answers (2)

tire0011
tire0011

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

geekInside
geekInside

Reputation: 588

Use .scroll method from jquery

http://api.jquery.com/scroll/

Upvotes: 0

Related Questions