react-native-swipe-list-view
react-native-swipe-list-view copied to clipboard
onRightAction gets called with a delay.
Hello, I have problem. I put a function into the onRightAction
prop. The problem is that it gets called with about 1-2 second delay. I'd like for it to be called instantly as soon as the action occurs.
Hello, I have problem. I put a function into the
onRightAction
prop. The problem is that it gets called with about 1-2 second delay. I'd like for it to be called instantly as soon as the action occurs.
Hello, I have the same problem, did you manage to solve it?
Stumbled upon the same issue. For the time being I went with a temporary solution:
onSwipeRightAction = (data) => {
this.isRightSwipeActivated = data.isActivated;
if (data.isActivated) {
this.activatedKey = data.key;
} else {
this.activatedKey = undefined;
}
}
onSwipeTouchEnd = () => {
if (this.isRightSwipeActivated) {
// do something with this.activatedKey
}
}
...
<SwipeListView
...
onRightActionStatusChange={data => this.onSwipeRightAction(data)}
onTouchEnd={() => this.onSwipeTouchEnd()} />
Hi! I just came across the same issue.
The issue is that the onRightAction
only gets called after the swipeout animation has finished (see here and here).
That animation being a 'spring' type animation actually takes some time to finish "bouncing" off-screen, thus the delay.
I solved this by sticking to the method used in the example, which is to "listen" on the onSwipeValueChange
, check if the row has been swiped off-screen (±value > ±screenwidth), and if so execute my rightAction. This way it will be executed right after the row has gone invisible. (make sure to have something like animationIsRunning in place, as onSwipeValueChange
gets still called on every tiny move during the invisible animation)