Mobile Pinch Zoom Gesture Detection in Javascript & JQuery

Here is how to detect a pinch zoom gesture for mobile browsers in Javascript:

1 function onPinch(e) {
2     if (e.scale > 1)
3     {
4         // React to the pinch zoom in here.
5     } else if (e.scale < 1) {
6         //React to the pinch zoom out here.
7     }
8 }
9 document.getElementById("myPinchElement").ongestureend = onPinch;

You can also listen for the pinch event using jQuery like this:

1 $("#myPinchElement").on("gestureend", onPinch);