2011-09-23 119 views

回答

9

亲爱的朋友们在你的HTML使用。它没有运行,因为在浏览器中工作的功能是根据鼠标运动模式。你所要做的事情是改变对移动然后正常工作触控模式...

$(init); 

function init() { 
    document.addEventListener("touchstart", touchHandler, true); 
    document.addEventListener("touchmove", touchHandler, true); 
    document.addEventListener("touchend", touchHandler, true); 
    document.addEventListener("touchcancel", touchHandler, true); 
    } 
    function touchHandler(event) 
    { 
    var touches = event.changedTouches, 
    first = touches[0], 
    type = ""; 
    switch(event.type) 
    { 
    case "touchstart": type = "mousedown"; break; 
    case "touchmove": type="mousemove"; break;   
    case "touchend": type="mouseup"; break; 
    default: return; 
    } 
    var simulatedEvent = document.createEvent("MouseEvent"); 
    simulatedEvent.initMouseEvent(type, true, true, window, 1, 
         first.screenX, first.screenY, 
         first.clientX, first.clientY, false, 
         false, false, false, 0/*left*/, null); 
    first.target.dispatchEvent(simulatedEvent); 
    event.preventDefault(); 
    } 
+0

我只是这样做的,但我解决了这个绑定touchstart和touchmove在一起,这很好:) –

+0

@阿米特哈夫你测试了这个在移动....? –

+0

@阿米特在我的暴徒它适用于拖放的工作正常,但问题是我可以拖动,但对于删除我需要再次点击,然后只有在移动,但浏览器下降工作正常... –