jQuery scroll() detect when user stops scrolling

前端 未结 13 1442
情歌与酒
情歌与酒 2020-11-22 02:17

Ok with this..

$(window).scroll(function()
{
    $(\'.slides_layover\').removeClass(\'showing_layover\');
    $(\'#slides_effect\').show();
});
13条回答
  •  无人及你
    2020-11-22 02:57

    This detects the scroll stop after 1 milisecond (or change it) using a global timer:

    var scrollTimer;
    
    $(window).on("scroll",function(){
        clearTimeout(scrollTimer);
        //Do  what you want whilst scrolling
        scrollTimer=setTimeout(function(){afterScroll()},1);
    })
    
    function afterScroll(){
        //I catched scroll stop.
    }
    

提交回复
热议问题