如果您使用的唯一控件是Scrollable,那么您可以从此处编辑它的源代码以修复该行为或根据您认为合适的方式对其进行调整。
我修改了您发布的小提琴,以在代码部分中包含Scrollable控件的JavaScript
代码。
// added
在控件代码中添加的行是以下代码段末尾带有注释的行:
// touch event
if (conf.touch) {
var touch = {};
itemWrap[0].ontouchstart = function(e) {
var t = e.touches[0];
touch.x = t.clientX;
touch.y = t.clientY;
};
itemWrap[0].ontouchmove = function(e) {
// only deal with one finger
if (e.touches.length == 1 && !itemWrap.is(":animated")) {
var t = e.touches[0],
deltaX = touch.x - t.clientX,
deltaY = touch.y - t.clientY,
absX = Math.abs(deltaX), // added
absY = Math.abs(deltaY); // added
// Only consider the event when the delta in the
// desired axis is greater than the one in the other.
if(vertical && absY > absX || !vertical && absX > absY) // added
self[vertical && deltaY > 0 || !vertical && deltaX > 0 ? 'next' : 'prev']();
e.preventDefault();
}
};
}
我已经在 Android 中使用本机和 Opera 浏览器进行了尝试,并且似乎可以按预期工作。