PDA

View Full Version : Android doesn't support javascrip pinch events... or does it?



ChrisWTI
4 May 2011, 5:30 AM
Everything I have read seems to say that iOS is the only mobile platform that supports multitouch and the pinch event. I have been using a Motorola Xoom recently and have found something that I am at a loss to explain. Running the maps example that is included with Sencha Touch, the pinch zoom WORKS. Sencha maps use googles javascript maps API. So if the maps are javascript, and it's running on the Xoom, then the pinch zoom shouldn't work... right? So why does it? And can I get pinch events to work for my web applications the same way?

realjax
4 May 2011, 12:05 PM
Everything I have read seems to say that iOS is the only mobile platform that supports multitouch and the pinch event.

Go beyond www.apple.com (http://www.apple.com) and you'll discover a whole new 'Steve-I'll-control-what-apps-you-are-allowed-to-run' free world!!!

So errm, yes. Android supports it as well. So does Blackberry OS 6 if I'm not mistaken.
And yes, Sencha Touch does too.

ChrisWTI
4 May 2011, 12:11 PM
I am not talking about natively. I am talking about what is exposed to javascript. Have you tried to use the pinch event on an Android device? The coordinates in the event object do not update as the pinch events are fired. At least that has been my experience with the TouchEvent section of the KitchenSink example.

realjax
4 May 2011, 1:13 PM
Did you run the kicthensink examples in the Android browser directly?
If yes, then please don't. All(most all) examples suck heavily when viewed that way.

hitman01
5 May 2011, 6:31 AM
I'm interested in this as well..

I've tried the new BB Playbook and everything seems to work except updates to coordinates for the pinch which results in the scale not being updated while you are pinching. But the pinch is detected.

But if google maps work, we should be able to use it as well.

ChrisWTI
6 May 2011, 12:04 PM
I have been able to retrieve accurate data by drilling down further in the event object.

e.targetTouches[0].screenX
e.targetTouches[0].screenY
e.targetTouches[1].screenX
e.targetTouches[1].screenY

Using the above, I was able to get values for the locations of the fingers on the screen, but whenever I am trying to access this data it causes the pinch events to fail. It will generate anywhere from 2-5 pinch events and then it stops firing pinch events.

hitman01
9 May 2011, 1:32 PM
ChrisWTI, can you point me to the function that you are looking at?

I was looking at Ext.gesture.Pinch, specifically getPinchInfo and getDistance functions and tried replacing pageX/pageY with screenX/screenY but with no luck.

It seems that they are the same as pageX/pageY.

ChrisWTI
10 May 2011, 4:40 AM
I am looking at that Pinch function. When you write your function for the 'pinch' listener e is the event object being passed to the function. I never was able to get this method to work. Instead, I bypassed sencha-touch all together and wrote my own javascript to detect pinch events based on the browsers touchmove event.

hitman01
10 May 2011, 5:30 AM
I'm actually trying to do exactly the same thing now. Since it looks like Sencha will not do anything about this.