From 772fbdc2e8a7253eeed63d835d17217430dcd673 Mon Sep 17 00:00:00 2001 From: jinzelin Date: Tue, 11 Jun 2024 16:54:34 +0800 Subject: [PATCH] fix: swiper autoplay --- packages/hippy_ui_react/src/components/Swiper/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hippy_ui_react/src/components/Swiper/index.tsx b/packages/hippy_ui_react/src/components/Swiper/index.tsx index 1536a6b..77f1ca4 100644 --- a/packages/hippy_ui_react/src/components/Swiper/index.tsx +++ b/packages/hippy_ui_react/src/components/Swiper/index.tsx @@ -73,8 +73,8 @@ export class Swiper extends Component { if (autoplay > 0 && children.length > 1 && !this.autoplayTimer) { this.autoplayTimer = setTimeout(() => { const { beforePlay } = this.props; - // 已经最后一个了要回滚到0(留1的偏移误差) - const nextIndex = this.scrollX >= this.getMaxScrollX() - 1 ? 0 : this.getNextIndex(); + // 已经最后一个了要回滚到0(留2的偏移误差) + const nextIndex = this.scrollX >= this.getMaxScrollX() - 2 ? 0 : this.getNextIndex(); (!beforePlay || beforePlay(nextIndex)) && this.setIndex(nextIndex); this.stopAutoplay(); this.autoplay();