检查用户是否正在使用触控板滚动? [英] Check if user is scrolling with trackpad?

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

问题描述

我创建了一个网站,用户可以在其中使用鼠标滚动或向上/向下箭头滚动浏览画廊。它的工作方式就像我想要的那样,并在使用鼠标滚动时更改一个图像。
但是,如果用户使用触控板滚动,则几乎不可能一次滚动单个图像。

I have created a site where users are able to scroll through a gallery using mouse scroll or arrow up/down. It is working like I want it to, and changing one image pr scroll when scrolling with a mouse. But if the user is scrolling with a trackpad it is almost impossible to scroll a single image at a time.

所以我的问题是:有没有办法检查用户是否正在通过触控板滚动,然后更改滚动行为,从而使其变得不那么敏感,从而更容易一次滚动单个图像?

So my question is: Is there a way to check if the user is scrolling by trackpad, and then changing the behavior of the scrolling, so it becomes less sensitive, and thereby easier to scroll a single image at a time?

我不太擅长使用jquery,到目前为止,我的解决方案是通过以下两个脚本组合而成的:

I am not very good at jquery, my solution so far has been put together from a couple of scripts:

http://jsfiddle.net/MukuMedia/PFjzX/33/

希望有人可以帮助我:)

Hope someone can help me :)

推荐答案

不,这是不可能的。我能想到的唯一解决方案是限制滚动速度。我不会尝试破译您的代码,但建议您将 timedOut 变量初始化为零,每次滚动到新图像时将其设置为1。使用 setTimeout()将其设置为50ms后恢复为零。在滚动到新图像之前,请检查此 timedOut 变量,仅在该变量为零时滚动。 (请确保将 setTimeout 放在 timedOut 支票内,否则每次鼠标滚轮移动时都会被不断调用,这不是您想要的。)

No, this is not possible. The only solution I can think of is set a limit on the scrolling speed. I'm not going to try and decipher your code but I'd recommend making a timedOut variable initialized to zero which is set to one every time you scroll to a new image. Use a setTimeout() to set it back to zero after, say, 50ms. Before you scroll to a new image, check this timedOut variable and only scroll if it's zero. (Make sure you place your setTimeout inside of the timedOut check, otherwise it will be constantly called every time the mousewheel moves, which is not what you want.)

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

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