Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript event for a mobile pinch/zoom action

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.

like image 611
Jose Avatar asked Dec 14 '11 18:12

Jose


2 Answers

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

like image 176
Nachiketha Avatar answered Sep 17 '22 17:09

Nachiketha


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(){ ... });
like image 34
psema4 Avatar answered Sep 21 '22 17:09

psema4