Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onRightAction gets called with a delay. #594

Open
JorensM opened this issue Mar 13, 2022 · 3 comments
Open

onRightAction gets called with a delay. #594

JorensM opened this issue Mar 13, 2022 · 3 comments

Comments

@JorensM
Copy link

JorensM commented Mar 13, 2022

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.

@edurib17
Copy link

edurib17 commented Apr 17, 2022

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?

@numsu
Copy link

numsu commented May 6, 2022

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

@vanso-hubsi
Copy link

vanso-hubsi commented May 25, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants