jquery-ui sortable | How to get it work on iPad/touchdevices?

后端 未结 4 1565
遥遥无期
遥遥无期 2020-12-22 17:11

How do I get the jQuery-UI sortable feature working on iPad and other touch devices?

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

I tried to using event.prevent

4条回答
  •  遥遥无期
    2020-12-22 17:40

    Tom, I have added following code to mouseProto._touchStart event:

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

提交回复
热议问题