[removed] do an action after user is done scrolling

后端 未结 5 1925
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 06:55

I\'m trying to figure out a way to do this. I have a list of boxes, each about 150px high. I am using javascript (and jquery) and want that, after a user scroll

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 07:17

    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
       });
    });
    

提交回复
热议问题