drag and drop in phonegap-android
I am trying to drag and drop images using phonegap-androi开发者_JAVA技巧d.
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.
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
plzz help me out..
Thnks
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...
$( 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 Drag And Drop
- http://www.stevefenton.co.uk/Content/Jquery-Mobile-Drag-And-Drop/
Similar discussion:
- HTML Drag And Drop On Mobile Devices
精彩评论