software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.13k stars 982 forks source link

[macOS] Switch `hasPointerInside` to `containsPointInView` #3012

Closed m-bert closed 3 months ago

m-bert commented 3 months ago

Description

While working on LongPress I've noticed that currently check if pointer is inside view is implemented inside NativeViewGestureHandler. I've decided to move it to GestureHandler to be able to use it in other places.

HitSlop

Current implementation of containsPointInView also takes into consideration HitSlop property. The only problem is that on macOS we cannot detect clicks outside of view using mouseDown. This means that HitSlop will work only if click was started inside view - clicking on HitSlop area won't activate handlers.

Test plan

Tested on example app. You can simply see that RectButtons navigate to examples - it doesn't work if pointerInside is false.

Also tested on the following code: ```tsx export default function App() { return ( ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'space-around', alignItems: 'center', }, button: { width: 100, height: 30, borderRadius: 15, backgroundColor: 'crimson', }, }); ```