[removed] do an action after user is done scrolling

后端 未结 5 1932
被撕碎了的回忆
被撕碎了的回忆 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:25

    This is basically the same as Šime Vidas' answer, but less complex:

    var scrollTimeout = null;
    $(window).scroll(function(){
        if (scrollTimeout) clearTimeout(scrollTimeout);
        scrollTimeout = setTimeout(function(){yourFunctionGoesHere()},500);
    });
    

    500 is the delay. Should be ok for mouse scroll.

提交回复
热议问题