0

完全错误:

[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);
        }
    });

});

任何解决方案将不胜感激

4

1 回答 1

2

我得到了解决方案.. 将 css = 'touch-action:none' 放到 div 区域,一切都会正常工作。

于 2018-06-06T07:22:45.680 回答