[Version: 2.4.0] Rotation & Pinch with anchor points that consider the touch points? #2071
-
GoalGesture behavior that is present in the Instagram Story editor when moving, scaling, and rotating stickers. In particular, when rotating a sticker with 2 fingers, 1 still and 1 moving, the still touchpoint is the anchor point. When pinching, the scaling also respects the line of the touchpoints, the shape will scale away from the line. If you touch the bottom edge of a shape and pinch out, the shape will only grow above the line of your touches and the bottom edge of the shape will constantly be where your touches are. Default behavior of the rotation gesture out-of-the-boxThe However, as described in my goal, I want to use the touchpoint that is not moving as the anchor point instead of the center point of the touches. From the docs, it seems like such information is not possible to obtain from the gesture event. Is there any way to build such gesture behavior with the current version? Perhaps use the Manual gesture and implement all pan, rotation, and pinch interactions from the ground up? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've found this repo which can calculate a transform matrix from given sets of points: https://github.com/axelpale/nudged So technically it should be possible to provide (a) the 2 initial touchpoints from the activate event and (b) the current touchpoints from the update event to the lib and retrieve the translate, rotate, and scale params, which can then be applied to the component style. I have not yet tried to implement this so not sure if it actually works as expected. However, I'm still wondering if this is the easiest way to do it, or perhaps there is something built-in of RN-gesture-handler that I'm missing? |
Beta Was this translation helpful? Give feedback.
-
This is answered here: #1826 (reply in thread) |
Beta Was this translation helpful? Give feedback.
This is answered here: #1826 (reply in thread)