Swipeable: onSwipeableOpen, onSwipeableClose, onSwipeableRightOpen and onSwipeableLeftOpen callback taking to long, about 2 seconds.
See original GitHub issueonSwipeableOpen
, onSwipeableClose
, onSwipeableRightOpen
and onSwipeableLeftOpen
callback taking to long, about 2 seconds.
Suggestion: in Swipeable.js after line 173 rowTranslation.setValue(fromValue);
Add:
let animatedListenerId = rowTranslation.addListener(({value}) => {
let threshold = 0.1;
if(Math.abs(value.toFixed()) >= (Math.abs(toValue.toFixed()) - Math.abs(toValue.toFixed()) * threshold)) {
if (toValue > 0 && this.props.onSwipeableLeftOpen) {
this.props.onSwipeableLeftOpen();
} else if (toValue < 0 && this.props.onSwipeableRightOpen) {
this.props.onSwipeableRightOpen();
}
if (toValue === 0) {
this.props.onSwipeableClose && this.props.onSwipeableClose();
} else {
this.props.onSwipeableOpen && this.props.onSwipeableOpen();
}
rowTranslation.removeListener(animatedListenerId);
}
});
Change:
From:
Animated.spring(rowTranslation, {
velocity: velocityX,
bounciness: 0,
toValue,
useNativeDriver: this.props.useNativeAnimations,
}).start(({ finished }) => {
if (finished) {
if (toValue > 0 && this.props.onSwipeableLeftOpen) {
this.props.onSwipeableLeftOpen();
} else if (toValue < 0 && this.props.onSwipeableRightOpen) {
this.props.onSwipeableRightOpen();
}
if (toValue === 0) {
this.props.onSwipeableClose && this.props.onSwipeableClose();
} else {
this.props.onSwipeableOpen && this.props.onSwipeableOpen();
}
}
});
To:
Animated.spring(rowTranslation, {
velocity: velocityX,
bounciness: 0,
toValue,
useNativeDriver: this.props.useNativeAnimations,
}).start();
Now I can close any opened row at real time…
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Swipeable: onSwipeableOpen, onSwipeableClose ... - GitHub
onSwipeableOpen, onSwipeableClose, onSwipeableRightOpen and onSwipeableLeftOpen callback taking to long, about 2 seconds. Suggestion: in Swipeable.js after ...
Read more >Swipeable | React Native Gesture Handler - Software Mansion
onSwipeableOpen . method that is called when action panel gets open (either right or left). Takes swipe direction as an argument. onSwipeableClose ....
Read more >React native swipe-able from gesture handler showing ...
It is working, what I am not able to achieve is that if the user keeps swiping I want the one of the...
Read more >React Native Gesture Handler: Swipe, long-press, and more
Implementing gestures in a React Native app improves the user experience. Learn how to create swipeable, pan, long-press, and other ...
Read more >How to Create a Swipeable Component in React Native
First of all, install react native gesture handler using any of the ... onSwipeableRightOpen, onSwipeableOpen, onSwipeableClose etc.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/kmagiera/react-native-gesture-handler/pull/164 @Blah2014 @ptmt @kmagiera What do you think about this solution? I didn’t wish to add any listeners to native animation as it’s not a way of using this library. It seems to be a hacky workaround. However, mind that
Spring
has some given duration. You may useonSwipeableLeftStartOpen
and then set a timeout.Thanks @Blah2014 for reaching out.
If this issue is about code changes you suggest it would be much easier to discuss them if you decided to send a pull request instead.