[英]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區域,一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.