How to find out that a Scroll event has completed using jQuery

Possible duplicate:
Javascript: perform an action after user scroll

An event Scrollfires when a user starts scrolling a page, right? How to know if it is finished then? I want to call a function after scrolling. Somebody knows?

Thank!

PS With jQuery, please, but pure JS is ok too.

+5
source share
1 answer

You can achieve this using setTimeout. you can change the timeout (im using 100) according to your requirement.

var timeoutId;
$(selector).scroll(function(){
  if(timeoutId ){
         clearTimeout(timeoutId );  
  }
  timeoutId = setTimeout(function(){
   // your code 
  }, 100);

});
+8
source

All Articles