How to call a function after scroll has ended?

后端 未结 4 892
渐次进展
渐次进展 2021-01-14 17:30

I want to call a function right after a scroll ends. I have tried a load of different things, none of which have quite worked, and then I came upon this solution in

4条回答
  •  悲&欢浪女
    2021-01-14 18:12

    have you tried putting scrollEnded() on top of bodyScroll()?

    function scrollEnded(){
        console.log('scrollEnded. Now do something astounding.');
    };
    function bodyScroll() {
        console.log('scrolling.');
    
        if (scrollTimer != -1)
            clearTimeout(scrollTimer);
    
        scrollTimer = window.setTimeout('scrollEnded()', 500);
    
    };
    

提交回复
热议问题