react-swipeable-views
react-swipeable-views copied to clipboard
Incorrect index callback when swiping top fast
hi, I’ve an issue with the onChangeIndex method, sometimes when an user is swiping too fast, the index received is incremented by two or three instead of one by one, this is annoying because in my case each slide represent one day and one swipe could supose pass two or three days
Thanks
You can restrict the increment to one in userland. Unless the user didn't actually swiped two days, I will close the issue.
Sure I can, but if I do this, the animation is made in the opposite direction, I mean, if you are in slide 1 and you go to de right and the swipe said the next slide is number 3, I can force it to be number 2, but the animation is incorrect and it appears from right to lefr (because I force the slide number 3 to be number 2, as if I was swiping backwards)
Maybe we can leverage threshold
and hysteresis
properties to prevent it in the first place?
I've already tried this, I think that the problem is that the swipe is such a fast that the setState’s callback inside the handleTouchEnd is not executed ecery time I do a swipe, sometimes the handle is executed twice but the callback only one (I added some console.logs to see this) what do you think?
@sergivillar Did you fix your problem?
I need a solution for this as well. If the user swipes fast, then sometimes the next index is skipped (even in the onChangeIndex
callback) and the items are basically 'jumping'. This behavior looks buggy.
EDIT: Actually, the slider doesn't return the wrong index but it turns off the animation on too fast swiping (only when it is wrapped in virtualize()
as it seems). You can even reproduce this issue on the demo page: https://react-swipeable-views.com/demos/demos/
Steps to reproduce:
- Go to the Circular example (https://react-swipeable-views.com/demos/demos/#circular)
- Swipe very fast consecutively
For example, the transition from slide 1 to slide 2 behaves as expected but from slide 2 to slide 3 turns off the animation and the item 'jumps'. The user might think that one item was skipped, but it wasn't. It's simply a UX issue. Any fix for this?
Feel free to take a look and create a PR, when I cleared most of the PR's and issues I will try and build one but I can't promise anything ;)
Wrong button
@alex-lechner Did you found a solution?
@kmkadze Unfortunately not :/ I've tried other slider libraries but then they had other bugs so... still waiting for a fix