javascript:可以使用 touchmove 来模拟 iPhone 上的鼠标悬停吗?
理想情况下,有一种方法可以在 iphone/ipad 上使用 touchstart 和 touchmove 来模拟以下 javascript 的鼠标悬停图像映射功能:
http ://www.netzgesta.de/mapper/
我希望允许 iphone/ipad 用户触摸地图,突出显示他们触摸过的国家/地区,当他们将手指拖动到其他国家/地区时,这些国家/地区依次点亮向上,就像他们通过桌面浏览器使用鼠标悬停一样。
想法、想法?这可能吗?
Ideally there is a way to mimic the mouseover imagemap capabilities of the following javascript using touchstart and touchmove on the iphone/ipad:
http://www.netzgesta.de/mapper/
I wish to allow the iphone/ipad user to touch the map, have the country they've touched highlight, and when they drag their finger over other countries, those countries in turn light up, just as they would via a desktop browser using mouseover.
Ideas, thoughts? Is this even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用touchesBegan和touchesMoved来获取触摸的坐标,然后检查它们是否在地图上的对象内。要获取这些坐标,请使用:
类似地,您可以使用
也存在touchesEnded 和touchesCancelled。您可以使用这些来获取触摸的坐标,然后由您来解释这些点。您可以为要滚动的每个部分绘制近似矩形,这将使这变得相当简单,但如果您有一个具有 javascript 地图的预期功能的地图,您将需要更复杂的形状,并且必须使用其他方法来定义形状。
You might try using touchesBegan and touchesMoved to get the coordinates of your touch and then check to see if those are within the object on your map. To get these coordinates, use:
Similarly, you can use
There also exists touchesEnded and touchesCancelled. You can use these to get the coordinates of the touch, afterwards it is up to you to interpret these points. You could approximate rectangles for each section to be rolled over which would make this rather simple, but if you have a map with the intended functionality as the javascript map, you would need more complex shapes and would have to use other methods to define the shape.