react-native-ezswiper切換閃爍問題
解決方案:
- node_modules中react-native-ezswiper/src/EZSwiper.js修改
- 1、在onScroll中添加如下:
if (this.ezswiper.loop) {
if (Math.abs(offset - ((this.ezswiper.count + 1) * this.ezswiper.side)) < 20.1) {
offset = this.ezswiper.side
this.scrollView.scrollTo() //-----增加
this.scrollView.scrollTo({ [this.ezswiper.scrollToDirection]: offset, animated: false });
} else if (Math.abs(offset) < 20.1) {
offset = this.ezswiper.side * this.ezswiper.count
this.scrollView.scrollTo() //----增加
this.scrollView.scrollTo({ [this.ezswiper.scrollToDirection]: offset, animated: false });
}
}
2、在安卓上最後一張切換後不動了,解決如下:
scrollTo(index, animated = true) {
this.scrollView && this.scrollView.scrollTo({ [this.ezswiper.scrollToDirection]: this.ezswiper.side * index, animated: animated });
if (index === this.props.dataSource.length && Platform.OS === 'android') {
setTimeout(()=> {
this.scrollTo(this.scrollIndex + 1);
},this.ezswiper.autoplayTimeout * 1000);
}
}