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
5.83k stars 952 forks source link

Add corner area detection to Fling gesture. #2807

Closed latekvo closed 1 month ago

latekvo commented 1 month ago

Description

This PR implements a requested feature to activate fling on corners of two adjacent activated directions.

Test plan

latekvo commented 1 month ago

I am still polishing up some details, but if you have any questions or suggestions, feel free to ask.

I actually want to ask for your opinion, current cornerFillAlignmentList initialisation prevents corners from being calculated if enableCornerActivation is false, but since that will probably never happen, i feel like including that condition only makes the code less readable.

So instead, i could move this condition a few lines lower to isAligned like this:

const alignmentList = Object.values(Directions).map((direction) =>
  getAlignment(direction, this.minimalAlignmentCosine)
);
const cornerFillAlignmentList = Object.values(CornerDirections).map((direction) =>
  getAlignment(direction, this.minimalCornerAlignmentCosine)
);

const isAligned = alignmentList.some(Boolean) || (cornerFillAlignmentList.some(Boolean) && this.enableCornerActivation);
latekvo commented 1 month ago

I will apply all relevant changes to the kotlin side in the next commit.