leecade/react-native-swiper
Vedi su GitHubLoop={true} + initialIndex leads to brief off by one error flicker
Open
#1003 aperta il 30 giu 2019
component: ViewPagerhelp wanted🐛bug🔎investigate
Metriche repository
- Star
- (10.334 star)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Which OS ?
iOS
Version
1.6
- react-native-swiper v1.6
- react-native v0.59.8
Expected behaviour
I was debugging an issue where setting the index param briefly showed the wrong data (off by one earlier) for a brief second before a redraw happened.
In debugging, this seems to be related to the loop={true} behavior (the default), since eliminating looping causes the offset to be calculated correctly and no flicker.
I'm guessing the implementation has some kind of 'extra' item at the front to handle the left-swipe when looping, and the initialOffset is not accounting for this?
Actual behaviour
Setting index causes it to start drawing on the correct position without a flicker.
Steps to reproduce
- Create a Swiper with multiple items, and loop={true}
- Set the initial index.
- Observe that it is briefly off by one before correcting itself.