While working on PointerTracker refactor and adding relativeCoords to it, I've noticed that offsetX/offsetY in PointerEventManager use PointerEvent.offsetX (and offsetY respectively) while TouchEventManager calculates this property by calculating the difference between clientX and bounding box (event.clientX - rect.left). I've decided to unify this behavior so that offset is now calculated in PointerEventManager the same way as in TouchEventManager.
As. you can see in the videos below, those 2 values may have different results - that is the main reason behind unifying them. offset property is used only in relativeCoords which have been recently introduced, so it won't be a breaking change.
Test plan
Tested by adding console.table in onPointerMove inside PanGestureHandler
Description
While working on
PointerTracker
refactor and addingrelativeCoords
to it, I've noticed thatoffsetX
/offsetY
inPointerEventManager
usePointerEvent.offsetX
(andoffsetY
respectively) whileTouchEventManager
calculates this property by calculating the difference betweenclientX
and bounding box (event.clientX - rect.left
). I've decided to unify this behavior so thatoffset
is now calculated inPointerEventManager
the same way as inTouchEventManager
.As. you can see in the videos below, those 2 values may have different results - that is the main reason behind unifying them.
offset
property is used only inrelativeCoords
which have been recently introduced, so it won't be a breaking change.Test plan
Tested by adding
console.table
inonPointerMove
insidePanGestureHandler
div
withPan
Before
https://github.com/software-mansion/react-native-gesture-handler/assets/63123542/61918493-b667-49c5-88c5-bf5205336dae
After
https://github.com/software-mansion/react-native-gesture-handler/assets/63123542/a499a69e-52aa-4ed5-a4a4-826b9dc28a7e