I have put a scroll handler to my page :
$(window).scroll(function() {
...
});
and I’d like to do some operation when i stop to scroll the bar, not when I’am scrolling it.
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Timers are usually a gross hack but I can’t think of anything better in this case. Maybe something like this will work for you:
The basic strategy is to use a timer delay the “they’ve stopped scrolling” action until a few clock ticks after the last scroll event, the rest is just bookkeeping. You’ll want to play around with the
DELAYvalue to get something that feels right.Useful references:
clearTimeoutsetTimeout