我创建一个web应用程序拥有的div溢出:滚动造型。由于Android的浏览器不支持此,我需要使用触摸和拖拽用我自己的自定义功能。
I'm creating a web app featuring divs with overflow: scroll styling. Since the Android browser doesn't support this, I need to use touches and drags with my own custom function.
$([element]).
.bind('touchmove', function(event) {
event.preventDefault();
// Move elements around as page scrolls, using event.pageY
})
.bind('touchstart', function(event) {
event.preventDefault();
// Do stuff to set up scrolling event.
}
这工作正常在iOS设备上。但是,在Android中,它没有。
This works fine on iOS devices. However, in Android, it does not.
使用的console.log,我发现event.pageY总是被设置为零(iOS中它会告诉你,你的接触是相对于页面的其余部分)。我也得到了以下晦涩的消息:
With console.log, I found out that event.pageY is always set to zero (in iOS it tells you where your touch is in relation to the rest of the page). I also get the following cryptic message:
W/webview (21798): Miss a drag as we are waiting for WebCore's response for touch down.
数据对这个已经微乎其微,但它似乎是Android不实际注册触摸事件,直至取消触摸的情况。我不相信它,因为正常的页面滚动的罚款。我只是不知道热,以使其接受而不是忽略触摸的Y值pageY的真正价值。
Data on this has been minimal, but it seems to be the case that Android doesn't actually register a touch event until you un-touch. I don't believe it, since normal pages scroll fine. I just don't know hot to get it to recognize the real value of pageY, instead of ignoring the Y-value of the touch.
为寻找谢谢!
请使用:
event.touches [0] .pageY
来代替:
event.pageY
它会工作。
上一篇:Android的ClassNotFound的和android.view.InflateException:ClassNotFound、Android、android、InflateException
下一篇:如何在请求中传递 $value 以使用图形 sdk 而不是 api 获取邮件的 mime 内容而不是、图形、邮件、内容