9

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.

Jose
  • 10,891
  • 19
  • 67
  • 89
  • 1
    Have you looked at this? http://stackoverflow.com/questions/995914/catch-browsers-zoom-event-in-javascript – kvc Dec 14 '11 at 18:59

3 Answers3

4

hammer.js https://hammerjs.github.io/ is one of the best javascript library for such problems..

cweiske
  • 30,033
  • 14
  • 133
  • 194
Nachiketha
  • 21,705
  • 3
  • 24
  • 32
3

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(){ ... });
psema4
  • 3,007
  • 1
  • 17
  • 22
2

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.

fisherwebdev
  • 12,658
  • 4
  • 28
  • 27