完整错误:
Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.
preventDefault @ jquery-2.2.4.min.js:3
f @ jquery.ui.touch-punch.min.js:14
b._touchMove @ jquery.ui.touch-punch.min.js:26
f @ jquery-2.2.4.min.js:2
dispatch @ jquery-2.2.4.min.js:3
r.handle @ jquery-2.2.4.min.js:3
我使用touchpunch,这可能会使问题复杂化?我尝试将cancel: false
添加到可拖动选项中,因为此错误的大多数解决方案都表明了这一点。它没有帮助。
这种情况经常被拖累,30-80次。
以下是所有拖动相关代码:
var t;
$(document).on('touchstart','.menu-item', function (event) {
selectItem(this);
var self = this;
if ($(self).hasClass('draggable')) return;
t = setTimeout(function () {
$(self).draggable({
revert: 'invalid',
helper: 'clone',
opacity: .75,
cancel: false,
appendTo: 'body',
cursorAt: {
left: 100,
top: 100
},
start: function(e, ui)
{
$(ui.helper).addClass("ui-draggable-helper");
$('.menu-container').addClass('stop-scrolling');
},
stop: function(e, ui) {
$('.menu-container').removeClass('stop-scrolling');
}
}).draggable('enable').addClass('draggable');
$(self).trigger(event)
}, 800);
});
$(document).on("touchend", function () {
clearTimeout(t);
$('.draggable:not(.ui-draggable-helper)').draggable( 'disable' ).removeClass('draggable');
});
答案 0 :(得分:1)
我遇到了同样的问题,我通过在jquery.ui.touch-punch.js
中添加if语句来解决它:
这是原始代码(从第31行开始):
function simulateMouseEvent (event, simulatedType) {
// Ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
return;
}
event.preventDefault();
这是更新的代码:
function simulateMouseEvent (event, simulatedType) {
// Ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
return;
}
if(event.cancelable) {
event.preventDefault();
}