触摸移动在 30-80 次后卡住并且控制台错误即将到来
Touch move getting stuck after 30-80 times & in console error is coming
完整错误:
[Intervention] Ignored attempt to cancel a touchend event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.
preventDefault @ jquery.min.js:2
(anonymous) @ number_grid_game.php:239
each @ jquery.min.js:2
(anonymous) @ number_grid_game.php:234
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
我有一个使用触摸事件的代码。当我开始拖动时,起初 10-30 步是正常的,但在 30-35 步后,拖动变得缓慢并且难以拖动。我不确定是什么导致了这个问题,我是接触事件的新手,似乎无法解决这个问题。
这是处理触摸事件的代码:
$(window)
.on('touchstart', function(event) {
var missingNumbers, $target = $(event.target);
if(!$target.hasClass('missing-number'))
return;
missingNumbers = MissingNumbers.ByElement($target);
//185
$.each(event.originalEvent.changedTouches, function(index, touch) {
event.preventDefault();
event.stopPropagation();
missingNumbers.startDrag($target, touch.identifier, touch.pageX, touch.pageY);
});
})
.on('touchmove', function(event) {
$.each(event.originalEvent.changedTouches, function(index, touch) {
var touchId = touch.identifier;
if((touchId in MissingNumbers.DraggedElements)) {
event.preventDefault();
event.stopPropagation();
MissingNumbers.DoCellDrag(touchId, touch.pageX, touch.pageY);
}
});
})
.on('touchend', function(event) {
$.each(event.originalEvent.changedTouches, function(index, touch) {
var touchId = touch.identifier;
if((touchId in MissingNumbers.DraggedElements)) {
event.preventDefault();
event.stopPropagation();
MissingNumbers.EndCellDrag(touchId);
}
});
});
任何解决方案将不胜感激
我找到了解决方案..
将 css = 'touch-action:none' 放到 div 区域 & 一切都会正常工作。
完整错误:
[Intervention] Ignored attempt to cancel a touchend event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.
preventDefault @ jquery.min.js:2
(anonymous) @ number_grid_game.php:239
each @ jquery.min.js:2
(anonymous) @ number_grid_game.php:234
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
我有一个使用触摸事件的代码。当我开始拖动时,起初 10-30 步是正常的,但在 30-35 步后,拖动变得缓慢并且难以拖动。我不确定是什么导致了这个问题,我是接触事件的新手,似乎无法解决这个问题。 这是处理触摸事件的代码:
$(window)
.on('touchstart', function(event) {
var missingNumbers, $target = $(event.target);
if(!$target.hasClass('missing-number'))
return;
missingNumbers = MissingNumbers.ByElement($target);
//185
$.each(event.originalEvent.changedTouches, function(index, touch) {
event.preventDefault();
event.stopPropagation();
missingNumbers.startDrag($target, touch.identifier, touch.pageX, touch.pageY);
});
})
.on('touchmove', function(event) {
$.each(event.originalEvent.changedTouches, function(index, touch) {
var touchId = touch.identifier;
if((touchId in MissingNumbers.DraggedElements)) {
event.preventDefault();
event.stopPropagation();
MissingNumbers.DoCellDrag(touchId, touch.pageX, touch.pageY);
}
});
})
.on('touchend', function(event) {
$.each(event.originalEvent.changedTouches, function(index, touch) {
var touchId = touch.identifier;
if((touchId in MissingNumbers.DraggedElements)) {
event.preventDefault();
event.stopPropagation();
MissingNumbers.EndCellDrag(touchId);
}
});
});
任何解决方案将不胜感激
我找到了解决方案.. 将 css = 'touch-action:none' 放到 div 区域 & 一切都会正常工作。