移动Safari惯性滚动的事件 [英] Events for Inertial Scrolling on Mobile Safari

查看:182
本文介绍了移动Safari惯性滚动的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用溢出功能:在iPad优化的网页上滚动,效果非常好。因为它将滚动滑动解释为触摸,所以我开始遇到滚动div中的项目的触摸事件的麻烦。由于没有滚动完成事件,并且每次滚动时滚动事件都会触发,我尝试检测滚动事件并设置一个定时器来临时禁用触摸事件。但是,我发现滚动事件只会在每次用户启动滚动时触发,这很少有惯性滚动。

I am currently using overflow:scroll on a web page optimized for the iPad, and it works great. I began running into trouble with touch events on the items in the scrolling div, because it was interpreting the scrolling swipes as touches. Since there is no scroll complete event, and the scroll event fires each time you scroll, I tried detecting the scroll event and setting a timer to disable the touch event temporarily. However, I have discovered that the scroll event only fires each time the user initiates a scroll, which is rarely with inertial scrolling.

是否有不断的触发滚动事件或一些另一种方式来检测滚动是否正在发生?

Is there a constantly firing scroll event or some other way to detect that scrolling is currently happening?

这只是Mobile Safari上的惯性滚动问题,因为当您将鼠标移到OS X上时,惯性自动滚动停止,所以要启动点击事件,你通常需要移动鼠标,从而避免冲突。你也没有双重使用的触摸输入滚动和触摸点击。

This is only a problem with inertial scrolling on Mobile Safari, because when you move your mouse on OS X, inertial scrolling automatically stops, so to initiate the click event, you would generally need to move the mouse, thus avoiding a conflict. You also don't have the dual use input of touch for scrolling and touch for tapping.

推荐答案

<script type="text/javascript">
<!--
    document.addEventListener("touchmove", ScrollStart, false);
    document.addEventListener("scroll", Scroll, false);
    function ScrollStart() {
        //start of scroll event for iOS
    }
    function Scroll() {
        //end of scroll event for iOS
        //and
        //start/end of scroll event for other browsers
    }   
// -->
</script>

这篇关于移动Safari惯性滚动的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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