software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.05k stars 1.31k forks source link

getRelativeCoords not work correctly on android #5810

Closed doublelam closed 6 months ago

doublelam commented 8 months ago

Description

const inRect = useCallback((point: Point, rect: Rect) => {
        'worklet';

        const coords = getRelativeCoords(containerRef, point.x, point.y);
...
 const panGesture = Gesture.Pan()
        .onBegin(() => {
            runOnJS(onBegin)();
        })
        .onUpdate((e) => {
            if (!visible) { return; }
            if (inRect({ x: e.absoluteX, y: e.absoluteY }, trashNode)) {
...

the coords is expected to be a relative value but got an absolute value. not working on android, works well on ios.

Steps to reproduce

as official example

Snack or a link to a repository

null

Reanimated version

3.5.4 - 3.8.0

React Native version

0.72.6

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 8 months ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

szydlovsky commented 6 months ago

Hi @doublelam - indeed the function returns wrong values - it should be fixed in https://github.com/software-mansion/react-native-reanimated/pull/5926.

szydlovsky commented 6 months ago

@doublelam the fix got merged - it should be available in the next nightly build (around 2AM CEST time) - see npm page