Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the number of fingers used in gesture event

I want to implement a function that zoom object when user uses two fingers to scale.

I am trying to use gesturechange event to implement it, but I found the event fired as long as the fingers number exceed one. I want to stop zoom when user uses too many fingers to operate object (it is hard to get the correct position and scale ratio).

Could I detect the number of fingers when gesturechange fired? I know touchstart event has a event.touches.length can get it. But I want to know is the same property in gesturechange event.

like image 746
Sam Avatar asked Oct 31 '12 02:10

Sam


1 Answers

Actually this is possible only on IOSX devices. Android does not expose this information to javascript. For example you have the:

document.ongesturechange=function(e)
{
    //e.scale
    //fingers=e.touches.length;
};

event, but this will work only on iphone/ipad.

Some jquery libraries like http://jgestures.codeplex.com/ can help simulate gesture events on android.

like image 199
albanx Avatar answered Sep 23 '22 23:09

albanx