How can I trigger a function when the browser window stops scrolling? Either by mouse wheel, click, space bar or arrow key? Is there any event for such action? I have tried to search online but couldn’t get any solution. I’m fine with a jQuery solution.
Share
There’s no “event” but you could make your own, like this:
Then you could bind to it, like this:
This creates an event, there’s no “stop” for this, but you can define your own… in this case “stop” is defined as “hasn’t scrolled in 250ms”, you can adjust the timer to your liking, but that’s the idea.
Also, if you’re just doing one thing there’s no need for an event, just put your code where I’m calling
$(window).trigger("scrollStop")and it’ll runnmilliseconds after the scroll stops.