Javascript: do an action after user is done scrolling

As you are already using jQuery, have a look at Ben Alman’s doTimeout plugin which already handles the debouncing of methods (which is what you are after).

Example shamelessly stolen from his website:

$(window).scroll(function(){
   $.doTimeout( 'scroll', 250, function(){
      // do something computationally expensive
   });
});

Leave a Comment