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

[docs] Improve Reanimated Swipeable documentation. #3121

Closed latekvo closed 1 month ago

latekvo commented 1 month ago

Description

Fixed the example provided with the Reanimated Swipeable docs, it looks like a fragment of it was missing.

Also, what's the verdict on this issue? Today I had to take a look at these docs again and it really occurred to me the way it's currently written can be really confusing.

Here's my proposition, it removes the [0, +] mapping in favour of a verbose explanation:

renderRightActions

accepts a function.
The function receives the following arguments:

  • progress value representing swiping progress relative to the width of the returned element.
    progress is 0 when swipeable is closed, 1 when right action is fully visible.

  • translation horizontal translation of swipeable in pixels.

  • swipeable provides an object exposing the methods listed here

This function must return a ReactNode.

side-by-side comparison: old new
image image

Of course this change applies to both renderLeftActions and renderRightActions

m-bert commented 1 month ago

Also, what's the verdict on https://github.com/software-mansion/react-native-gesture-handler/pull/2962#discussion_r1666562893?

We could use Infinity to make it cleaner. Your suggested version does not say anything about acceptable values and I think it would be better to keep them. However, I'm still not fond of using [0, -], even with Infinity.

latekvo commented 1 month ago

I'm still not fond of using [0, -], even with Infinity.

Please let me know if the proposal written in description is ok then, it replaces [0, -] with a regular description of the input-output ranges.

m-bert commented 1 month ago

Your suggested version does not say anything about acceptable values and I think it would be better to keep them.

latekvo commented 1 month ago

Your suggested version does not say anything about acceptable values and I think it would be better to keep them.

Do either of these work? I think the input-output range is implicitly stated in both of them.

m-bert commented 1 month ago

What about:

?

latekvo commented 1 month ago

progress value representing swiping progress relative to the width of the returned element. Equals 0 when swipeable is closed, 1 when right action is open. Linearly increases to Infinity as right action overshoots it's open position.

Sounds good, added it in 2967cea

latekvo commented 1 month ago

As of 8c3fd7b added a missing argument description to the docstrings. Let me know if it's ok