javascript 在 phonegap-android 中拖放
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7531412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
drag and drop in phonegap-android
提问by Amit Hooda
I am trying to drag and drop images using phonegap-android.
我正在尝试使用 phonegap-android 拖放图像。
When i run the code in the mozilla firefox browser then the code runs great and i am able to drag any image but when i run that code in phonegap android 2.1update then i am not able to drag it and even not able to click on it.
当我在 mozilla firefox 浏览器中运行代码时,代码运行良好,我可以拖动任何图像,但是当我在 phonegap android 2.1update 中运行该代码时,我无法拖动它,甚至无法点击它.
Anyone can tell me whats going wrong. http://www.devarticles.com/c/a/JavaScript/Building-DragandDrop-DIVs-Developing-a-Basic-Script/that i used for drag and drop
任何人都可以告诉我出了什么问题。 我用于拖放的http://www.devarticles.com/c/a/JavaScript/Building-DragandDrop-DIVs-Developing-a-Basic-Script/
plzz help me out..
lz帮帮我..
Thnks
谢谢
回答by srinivasaraghavan ramji
Dear all use this in your html. It is not running because the functions working in browser are according to mouse motion mode. Thing you have to do is change to on touch mode of mobile then it works fine...
亲爱的大家在你的 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();
}
回答by Dmitry F
Jquery Mobile Drag And Drop
Jquery 移动拖放
Similar discussion:
类似讨论: