简体   繁体   English

如何使用javascript / jquery处理iphone和ipad上的拖动事件?

[英]How to handle drag events on iphone and ipad with javascript/jquery?

I have a little app that has been under development for some time. 我有一个小应用程序已经开发了一段时间。 My friends and I have been working really hard on this and are near release of the beta version. 我的朋友和我一直在努力工作,并且接近发布测试版。

I want to give some demos using iPhone and iPad to look cool :p 我想用iPhone和iPad进行一些演示看起来很酷:p

Now my problem is how to handle: 现在我的问题是如何处理:

  • Mouse Down 鼠标按下
  • Mouse Up 鼠标向上
  • Mouse Leave 鼠标离开

The multitouch interface of the iPhone (which I expect is similar to the iPad) handles mouse move on a browser has a scrolling event. iPhone的多点触控界面(我期望类似于iPad)处理浏览器上的鼠标移动有一个滚动事件。 One could try to capture the scrolling event and use it to simulate the dragging but I don't even know if it will be doable or if it will only be a hack. 可以尝试捕获滚动事件并使用它来模拟拖动但我甚至不知道它是否可行或者它是否只是一个黑客。

Any one knows of a more robust manner to manage dragging events on the iphone/ipad? 任何人都知道更健壮的方式来管理iphone / ipad上的拖动事件?

Apple's Developer pages have a lot of good info on handling just these types of issues. Apple的Developer页面有很多关于处理这些类型问题的好信息。

Handling Events 处理事件

Try this : 试试这个 :

jquery.event.drag - v 2.2 Three Dub Media - http://threedubmedia.com jquery.event.drag - v 2.2三个配音媒体 - http://threedubmedia.com

I was having the same problem and I realized that in the short time-span I had, developing codes to handle raw mouse (down, move and up) events would take time. 我遇到了同样的问题,我意识到在短时间内我开发代码来处理原始鼠标(向下,向上和向上)事件需要时间。 So, I went ahead and modified the ThreeDumsMedia jQuery.event.drag plugin to make it to work on iPhone. 所以,我继续修改了ThreeDumsMedia jQuery.event.drag插件,使其适用于iPhone。

Get the jQuery.event.drag from http://www.shamasis.net/2011/06/javascript-drag-events-on-iphone-and-other-touch-based-devices/ and the 'drag' event would work just fine on iOS devices. http://www.shamasis.net/2011/06/javascript-drag-events-on-iphone-and-other-touch-based-devices/获取jQuery.event.drag,并且'drag'事件将起作用在iOS设备上就好了。

let me know if this helped. 如果这有帮助,请告诉我。

如果您使用的是jQuery, 请将jquery.ui.mouse.touch.jsjquery UI 1.9一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM