我在 the github site 上找不到任何示例或者在谷歌搜索如何检测 Zynga Scroller 的点击事件时。
例如,从 Pull-to-refresh 开始演示它包含此代码:
if ('ontouchstart' in window) {
container.addEventListener("touchstart", function(e) {
scroller.doTouchStart(e.touches, e.timeStamp);
e.preventDefault(); // Problem !!!
}, false);
由于我们一直在阻止默认,所以我永远无法单击可滚动列表中的一行。如果我删除该行,我可以单击但滚动不起作用。
有没有其他方法可以检测点击?
(在电脑上可以,但在有 ontouchstart 事件的智能手机上不行,(iPhone 4s))
最佳答案
这是因为 scrollerObject 会阻止用户操作,具体取决于您使用的 Zynga 滚动插件,例如在 EazyScroller.js 上,搜索此代码 that.scroller.doTouchStart(e.touches, e.timeStamp)
并删除下一行的 e.preventDefault() :
that.scroller.doTouchStart(e.touches, e.timeStamp);
//e.preventDefault();
关于javascript - Zynga Scroller - 检测点击单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13217816/