Skip to content

Commit

Permalink
Add enabled prop support to swipeable (#3011)
Browse files Browse the repository at this point in the history
## Description

This issue fixes `enabled` prop having no effect on the new Swipeable.

Reported
[here](#2936 (comment))
by @jackstudd

## Test plan

- open `release_tests` > `Swipeable Reanimation` example in both an
emulator and an editor
- add `enabled={false}` prop to both the swipeables
- legacy `swipeable` is now immovable
- new `swipeable` used to be unaffected, with this fix it should be
immovable as well

I added the `enabled` usage only for the `Pan` gesture and not the `Tap`
gesture intentionally.
The `Tap` gesture should remain active even when the rest of `swipeable`
is disabled,
as I found when testing the legacy `swipeable`
  • Loading branch information
latekvo authored Jul 30, 2024
1 parent abc9410 commit da5707a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/ReanimatedSwipeable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
swipeableMethods,
]);

panGesture.enabled(props.enabled !== false);

const animatedStyle = useAnimatedStyle(
() => ({
transform: [{ translateX: appliedTranslation.value }],
Expand Down

0 comments on commit da5707a

Please sign in to comment.