Closed m-bert closed 5 months ago
Actually, don't we want this also for focal
and anchor
points?
@j-piasecki well, probably we do, but that's something that I was looking at while investigating transformations
example in Update examples
PR. I think we can leave it as it is and then check if using relative coords helps in that case (at first I thought it does, but seems like there's more to it)
Description
Changes made in #2938 and #2939 allowed us to calculate
x
andy
relative to givenView
with the same method onPointerEvents
andTouchEvents
. This PR changes logic inGestureHandler
base class, so that now it sends relative coordinates calculated by tracker.This change, combined with the one from #2943, makes handlers send correct relative coords.
Test plan
Copy snippet below and paste it into
transformNativeEvent
inGestureHandler.ts
Logs snippet
```jsx const rect = this.delegate.measureView(); const old = { x: lastCoords.x - rect.pageX, y: lastCoords.y - rect.pageY, }; console.table({ oldX: old.x, oldY: old.y, newX: lastRelativeCoords.x, newY: lastRelativeCoords.y, dx: old.x - lastRelativeCoords.x, dy: old.y - lastRelativeCoords.y, }); ```Here's example video that shows difference between those calculations:
https://github.com/software-mansion/react-native-gesture-handler/assets/63123542/d3a0575c-3821-4d2a-ac96-a0c3a870a1f5