X / Y触摸移动设备的坐标 [英] X/Y Touch coordinates for mobile devices

查看:115
本文介绍了X / Y触摸移动设备的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个我希望在移动设备上可用的网络应用。
所述应用程序的初始机制需要鼠标的当前X / Y坐标 - 不需要点击和拖动,只需在浏览器窗口中移动鼠标即可。

I am creating a web app that I am wanting to be usable on mobile devices. The initial mechanic of said app requires the current X/Y coordinates of the mouse - which doesn't require clicking and dragging, just simply moving the mouse around a browser window.

现在我一直在寻找有关Touch和Gestures的各种jQuery / Javascript库,但我找不到任何适合我的东西。

Now I have been looking in to the various jQuery/Javascript libraries concerning Touch and Gestures, yet I am unable to find anything that suits what I am after.

所以基本上我正在寻找一种方法来获得单指触摸/拖动的x / y位置。

So basically I am looking for a way to get the x/y pos of a single finger touch/drag.

例如:触摸屏幕0,0然后按住并将其拖动到480,320。然后,值将在 x1 y1 之间插值到 x2 y2

Eg: Touch the screen at 0, 0 then hold and drag it to 480,320. The values would then interpolate between x1, y1 to x2, y2.

谢谢。

推荐答案

你不需要一个库,使用touchstart,touchmove和touchend编写自己的代码相当容易事件。

You shouldn't need a library for this, it's fairly easy to write your own code using the touchstart, touchmove and touchend events.

http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/

作为附注,如果您使用iOS模拟器进行测试,请注意它有时会以实际设备不会的方式提供不正确的坐标,因此您将始终需要保持物理iOS设备方便,以验证您的代码是否正常工作。

As a side note, if you're using the iOS simulator for testing, be aware that it can sometimes give incorrect coordinates in a way that an actual device wouldn't, so you'll always need to keep a physical iOS device handy to verify that your code works.

这篇关于X / Y触摸移动设备的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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