сортировка jquery-ui | Как заставить его работать на iPad / touchdevices? - PullRequest
105 голосов
/ 09 января 2011

Как получить сортируемую функцию jQuery-UI, работающую на iPad и других сенсорных устройствах?

http://jqueryui.com/demos/sortable/

Я пытался использовать event.preventDefault();, event.cancelBubble=true; и event.stopPropagation(); с событиями touchmove и scroll, но в результате страница больше не прокручивалась.

Есть идеи?

Ответы [ 3 ]

209 голосов
/ 10 января 2011

Нашли решение (до сих пор тестировали только с iPad!)!

http://touchpunch.furf.com/content.php?/sortable/default-functionality

1 голос
/ 26 февраля 2019

Чтобы sortable работал на мобильном телефоне. Я использую touch-punch вот так:

$("#target").sortable({
  // option: 'value1',
  // otherOption: 'value2',
});

$("#target").disableSelection();

Обратите внимание на добавление disableSelection(); после создания сортируемого экземпляра.

0 голосов
/ 19 марта 2016

Том, я добавил следующий код в mouseProto._touchStart событие:

var time1Sec;
var ifProceed = false, timerStart = false;
mouseProto._touchStart = function (event) {

    var self = this;

    // Ignore the event if another widget is already being handled
    if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {
        return;
    }

    if (!timerStart) {
        time1Sec = setTimeout(function () {
            ifProceed = true;
        }, 1000);
        timerStart=true;
    }
    if (ifProceed) {
        // Set the flag to prevent other widgets from inheriting the touch event
        touchHandled = true;

        // Track movement to determine if interaction was a click
        self._touchMoved = false;

        // Simulate the mouseover event
        simulateMouseEvent(event, 'mouseover');

        // Simulate the mousemove event
        simulateMouseEvent(event, 'mousemove');

        // Simulate the mousedown event
        simulateMouseEvent(event, 'mousedown');
        ifProceed = false;
         timerStart=false;
        clearTimeout(time1Sec);
    }
};
...