leecade / leecade/react-native-swiper
scrollBy behaves differently on iOS works perfectly fine on Android
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Which OS ?
iOS
Version
Which versions are you using:
- react-native-swiper v? ^1.6.0
- react-native v0.?.? 0.62.2
Expected behaviour
Swiping programmatically when tapping the next button by calling swiperEl.current!.scrollBy(1) works perfectly on Android but not on iOS. It only works for the first time when I tap on next button but when I do it for the second time it persists on the second component and it didn't move to the third screen or component.
Gif below:

Full code below:
const Slider = ({ index }: SliderProps) => {
const swiperEl = useRef<Swiper>(null);
useEffect(() => {
swiperEl.current!.scrollBy(1);
}, [index, swiperEl]);
return (
<View style={styles.sliderContainer}>
<Swiper
scrollEnabled={false}
// index={index}
activeDotColor={colors.secondary}
ref={swiperEl}
paginationStyle={{ position: 'relative' }}
>
<View style={styles.slideContent}>
<LottieView
style={styles.wrapperContent}
hardwareAccelerationAndroid
source={careAnimation}
autoPlay
loop={false}
/>
</View>
<View style={styles.slideContent}>
<LottieView
style={styles.wrapperContent}
hardwareAccelerationAndroid
source={connectAnimation}
autoPlay
loop={false}
/>
</View>
<View style={styles.slideContent}>
<LottieView
style={styles.wrapperContent}
hardwareAccelerationAndroid
source={celebrateAnimation}
autoPlay
loop={false}
/>
</View>
</Swiper>
</View>
);
Actual behaviour
It should behave the sameway as Android.
How to reproduce it>
To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.
Steps to reproduce
- Create an index useState hook if which slider component is active.
- Update that index when clicking a button. By using
useEffecthook at Slider component. - Trigger
swiperEl.current!.scrollBy(1)when index is changed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by adapting an example in the examples folder to reproduce the issue on iOS and Android with react-native-swiper v1.6.0 and React Native 0.62.2. Trace the swiperEl.current!.scrollBy(1) call after the index changes and compare the second navigation attempt; done means repeated programmatic swipes reach the next slide on iOS as they do on Android.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100