javascript event for a mobile pinch/zoom action

∥☆過路亽.° 提交于 2019-12-17 19:28:02

问题


I need some help. I am trying to work on a mobile web page. What i'm trying to do is "capture" when the user does a zoom in/zoom out action. That is, when they put two fingers on screen and separate or close their fingers together. I looked at jquery mobile and didn't see it.

So specifically can I attach a javascript function to a pinch/zoom event in a mobile device?

Any help would be greatly appreciated.


回答1:


hammer.js http://eightmedia.github.com/hammer.js/ is one of the best javascript library for such problems..




回答2:


Zepto is a jquery compatible library for mobile and provides handlers for pinch events. Unfortunately, they are listed as iOS only. (See "Touch Events")

Synopsis:

$('some selector').pinch(function(){ ... });
$('some selector').pinchIn(function(){ ... });
$('some selector').pinchOut(function(){ ... });



回答3:


Touchy is a jQuery plugin that provides support for pinch, drag, swipe, longpress, rotate. It works on any browser that implements touchstart, touchmove and touchend. Future versions will also support IE10.



来源:https://stackoverflow.com/questions/8509799/javascript-event-for-a-mobile-pinch-zoom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!