react-swipeable-views icon indicating copy to clipboard operation
react-swipeable-views copied to clipboard

Incorrect index callback when swiping top fast

Open sergivillar opened this issue 6 years ago • 10 comments

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

sergivillar avatar Jan 29 '18 18:01 sergivillar

You can restrict the increment to one in userland. Unless the user didn't actually swiped two days, I will close the issue.

oliviertassinari avatar Jan 29 '18 18:01 oliviertassinari

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)

sergivillar avatar Jan 29 '18 19:01 sergivillar

Maybe we can leverage threshold and hysteresis properties to prevent it in the first place?

oliviertassinari avatar Jan 29 '18 19:01 oliviertassinari

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 avatar Jan 29 '18 20:01 sergivillar

@sergivillar Did you fix your problem?

TiagoSousa26 avatar Jul 12 '18 11:07 TiagoSousa26

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:

  1. Go to the Circular example (https://react-swipeable-views.com/demos/demos/#circular)
  2. 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?

alex-lechner avatar Nov 19 '19 16:11 alex-lechner

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 ;)

vanhoutenbos avatar Dec 11 '19 20:12 vanhoutenbos

Wrong button

vanhoutenbos avatar Dec 11 '19 20:12 vanhoutenbos

@alex-lechner Did you found a solution?

kmkadze avatar Mar 24 '20 19:03 kmkadze

@kmkadze Unfortunately not :/ I've tried other slider libraries but then they had other bugs so... still waiting for a fix

alex-lechner avatar Mar 24 '20 22:03 alex-lechner