IT story

jquery-ui 정렬 가능 |

hot-time 2020. 8. 3. 17:36
반응형

jquery-ui 정렬 가능 | iPad / 터치 기기에서 작동시키는 방법?


iPad 및 기타 터치 장치에서 jQuery-UI 정렬 가능 기능을 사용하려면 어떻게해야합니까?

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

내가 사용하는 시도 event.preventDefault();, event.cancelBubble=true;event.stopPropagation();touchmovescroll이벤트,하지만 결과는 페이지가 더 이상 이동하지 않는 것이 었습니다.

어떤 아이디어?


해결책을 찾았습니다 (지금까지 iPad로만 테스트되었습니다!)!

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


확인하려면 sortable모바일 작업을. 다음 과 같이 터치 펀치를 사용 하고 있습니다.

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

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

disableSelection();정렬 가능한 인스턴스를 생성 한 후 추가에 유의하십시오 .


Tom, 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);
    }
};

참고URL : https://stackoverflow.com/questions/4641590/jquery-ui-sortable-how-to-get-it-work-on-ipad-touchdevices

반응형