检测用户是否正在滚动 [英] Detect if user is scrolling

查看:116
本文介绍了检测用户是否正在滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户正在滚动,我如何在javascript中检测到?

How can I detect in javascript if the user is scrolling?

推荐答案

这可行:

window.onscroll = function (e) {  
// called when the window is scrolled.  
} 

编辑:

你说这是TimeInterval中的一个函数..

尝试这样做:

you said this is a function in a TimeInterval..
Try doing it like so:

userHasScrolled = false;
window.onscroll = function (e)
{
    userHasScrolled = true;
}

然后在你的Interval插入这个:

then inside your Interval insert this:

if(userHasScrolled)
{
//do your code here
userHasScrolled = false;
}

这篇关于检测用户是否正在滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆