diff --git a/src/EZSwiper.js b/src/EZSwiper.js index 49511bd..af9cad6 100755 --- a/src/EZSwiper.js +++ b/src/EZSwiper.js @@ -263,8 +263,15 @@ export default class EZSwiper extends Component<{}> { const oldIndex = this.ezswiper.currentIndex this.ezswiper.currentIndex = this.ezswiper.loop ? (this.scrollIndex + this.ezswiper.count - 1) % this.ezswiper.count : this.scrollIndex - if (oldIndex !== this.ezswiper.currentIndex) { - this.onDidChange(this.ezswiper.dataSource[this.ezswiper.currentIndex], this.ezswiper.currentIndex) + if(this.ezswiper.loop) { + if(willIndex === 2 && oldIndex === 0) return; + if(!(this.scrollIndex === 1 && willIndex >= 3)){ + this.onDidChange(this.ezswiper.dataSource[this.ezswiper.currentIndex], this.ezswiper.currentIndex) + } + }else { + if (oldIndex !== this.ezswiper.currentIndex || willIndex === 0) { + this.onDidChange(this.ezswiper.dataSource[this.ezswiper.currentIndex], this.ezswiper.currentIndex) + } } this.updateAnimated(currentPageFloat, this.scrollIndex);