如何在Mac Safari中检测/禁用惯性滚动? [英] How to detect/disable inertial scrolling in Mac Safari?

查看:186
本文介绍了如何在Mac Safari中检测/禁用惯性滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过Mac上的惯性"设置禁用或检测车轮事件?

Is there a way to disable or detect that wheel events are from the "inertia" setting on a Mac?

我希望能够分辨真实事件与其他事件之间的区别...或针对特定页面禁用这种滚动.

I'd like to be able to tell the difference between real events and the others...or disable that kind of scrolling for a particular page.

推荐答案

是,不是.

您可以使用触地/向上滚动,并将其作为事件滚动以查找正在移动的页面,但是如果操作系统正在进行惯性滚动,则不会触发这些页面.好玩吧?

You can use touchdown/up, and scroll as events to look for the page moving about but those won't trigger if the OS is doing an inertial scroll. Fun, right?

但是,您可以连续检测到的一件事是window.pageYOffset.在发生惯性滚动时,该值将保持变化,但不会引发事件.因此,您可以使用一组计时器来继续检查惯性滚动并保持自身运行,直到页面停止移动为止.

One thing that you can continually detect, however, is window.pageYOffset. That value will keep changing while an inertial scroll is happening but won't throw an event. So you can come up with a set of timers to keep checking for an inertial scroll and keep running itself until the page has stopped moving.

棘手的东西,但应该可以.

Tricky stuff, but it should work.

这篇关于如何在Mac Safari中检测/禁用惯性滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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