親愛的朋友們在你的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();
}
我試圖jQuery Mobile的拖放但它僅適用於TTL所以它不提供阻力選項,,但我已經通過綁定touchstart和touchmove事件完成了任務,對於drop我使用了touchend事件,並且我完成了這個:)。回覆的問題 –