拖放在PhoneGap的,机器人 [英] drag and drop in phonegap-android

查看:104
本文介绍了拖放在PhoneGap的,机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拖,并使用拖放图片的PhoneGap-机器人。

I am trying to drag and drop images using phonegap-android.

当我运行code中的Mozilla Firefox浏览器中,然后在code运行很好,我能够拖动任何图像,但是当我运行code在PhoneGap的安卓2.1update我就不是能拖它,甚至不能一下就可以了。

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.

谁能告诉我怎么回事错了。 <一href="http://www.devarticles.com/c/a/JavaScript/Building-DragandDrop-DIVs-Developing-a-Basic-Script/" rel="nofollow">http://www.devarticles.com/c/a/JavaScript/Building-DragandDrop-DIVs-Developing-a-Basic-Script/ 我使用的拖放

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帮助我。

Thnks

推荐答案

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

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

这篇关于拖放在PhoneGap的,机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆