简体   繁体   中英

How to implement both pinch zoom and pan with multitouch?

First of all i should say my app is already has pinch zoom which works perfectly and it has pan feature too but this pan feature works with single touch and i want to make both work with multi touch. What i mean is if user make pinch gesture zoom work should be done and if user move both finger in same direction then pan work would be done. I have tried to use a threshold approach which measures the distance between fingers and compare the distance with previous distance and if the difference between distances is less than threshold it act as pan and if the difference is bigger than threshold then it acts as zoom. This approach kind of works but it is inconsistent. So i am here to ask for smarter and smoother way to make work this.

PS: My pinch zoom code is from here

The best approach that I can think of is by using the direction of movement. If the two fingers move in different directions, then activate only the zoom. But if they move in the same direction, pan and check for zoom based on the threshold. This should add some consistency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM