From b919b955293f1cf7279494837e9a2b1762203651 Mon Sep 17 00:00:00 2001 From: LinkRober <1246983559@qq.com> Date: Tue, 25 Dec 2018 16:10:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dindex=E5=88=B00=E6=97=B6?= =?UTF-8?q?=E5=87=BA=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EZSwiper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EZSwiper.js b/src/EZSwiper.js index 49511bd..05a4cc6 100755 --- a/src/EZSwiper.js +++ b/src/EZSwiper.js @@ -263,7 +263,7 @@ 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) { + if (oldIndex !== this.ezswiper.currentIndex || willIndex === 0) { this.onDidChange(this.ezswiper.dataSource[this.ezswiper.currentIndex], this.ezswiper.currentIndex) } From fbc71b2ac7cb55753e5942a351ab66e52ab0e69c Mon Sep 17 00:00:00 2001 From: LinkRober <1246983559@qq.com> Date: Tue, 25 Dec 2018 16:45:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8loop=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E7=B4=A2=E5=BC=95=E5=87=BA=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EZSwiper.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/EZSwiper.js b/src/EZSwiper.js index 05a4cc6..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 || willIndex === 0) { - 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);