美文网首页前了个端
如何判断html页面停止滚动?

如何判断html页面停止滚动?

作者: 刘勇虎 | 来源:发表于2018-03-07 16:40 被阅读7次

写在开始的话

查遍的文献,没有找到js或者jquery定义好的方法可用,最后迫不得已自己写了个方法。(如果哪位同学知道有其他方法,欢迎讨论)

代码

            var count_index = 0;
            $(window).scroll(
                function(e) {
                    if(count_index == 0) {
                        var timeIntervalFunction = setInterval(function() {
                            count_index--;
                            if(count_index <= 0) {
                                console.log("scroll end = " + count_index);
                                clearInterval(timeIntervalFunction);
                                count_index = 0;
                            }
                        }, 300);
                    }
                    count_index++;
                }
            );

效果

判断是否停止滑动_演示效果.gif

   
   
   

友情链接:

技术博客        简书主页

相关文章

网友评论

    本文标题:如何判断html页面停止滚动?

    本文链接:https://www.haomeiwen.com/subject/saojfftx.html