PDA

View Full Version : Kind of pinch to zoom that sort of works on Android.



karudo
27 Jul 2011, 7:17 AM
Hi EveryOne.

I want to introduce you a little hack i did to zoom on pinch. It's not fully working but let's say that it works for 80% of the cases (and more if you know how to pinch correctly ;)). I only catched pinches on the X axis, that are enough for me.

It is based on something that is certainly a bug:
When you drag with only one finger, many drag events are firing. But when you drag with two fingers (when you pinch for exemple!), only one drag event is firing, and one can catch the dragend to have usefull informations.

It is also based on the fact you pinch somewhere near the middle of the screen... !

After some tests, i realized that :
- if the startX of the dragend is before the pageX (the end)
--- if the middle point of your drag is before the middle of the screen you are pinching IN
--- else you are pinching out
- else it's the exact opposite !

Edit: Try it here:
http://webeleves.emse.fr/~cpichery/test (http://webeleves.emse.fr/%7Ecpichery/test)

Well it has to be improved somehow, but yet it works quite fine! ;)

Best regards

karudo
3 Aug 2011, 12:10 AM
And a link to show how it works with an Esri map (needs a browser compatible with Dojo)
http://webeleves.emse.fr/~cpichery/map

(http://webeleves.emse.fr/~cpichery/map)