react-native-swipe-list-view icon indicating copy to clipboard operation
react-native-swipe-list-view copied to clipboard

onRightAction gets called with a delay.

Open JorensM opened this issue 2 years ago • 3 comments

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.

JorensM avatar Mar 13 '22 15:03 JorensM

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?

edurib17 avatar Apr 17 '22 20:04 edurib17

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()} />

numsu avatar May 06 '22 20:05 numsu

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)

vanso-hubsi avatar May 25 '22 13:05 vanso-hubsi