문제

I want to get the position (relative or otherwise) of the two fingers/touches inside a gesture event (gesturestart, gesturechange, gestureend) on mobile Safari (iOS: iPad/iPhone). I know that the gesture* events don't actually provide this in the event args but i thought there might be a 'trick' to getting this info. It would be great to get the coords of the fingers while tracking a gesture (eg. scaling and moving an object in the same gesture).

Can this be done?

도움이 되었습니까?

해결책

It turns out that this information is not directly available via the 'gesture' events. The touch events are the key and i was able to get the touches collection and use the first two touches to derive a delta/midpoint of the two sets of coords. This seems to work.

다른 팁

There are three arrays in the returned event object for touch event:

  1. touches
  2. targetTouches
  3. changedTouches

I can't remember where I originally found this info, but a quick Google search brings up http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/

Got it! https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html Down at "Handling Multi-Touch Events"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top