Skip to content

Commit

Permalink
fix: swiper autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
linjinze999 committed Jun 11, 2024
1 parent 22042d9 commit 772fbdc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/hippy_ui_react/src/components/Swiper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class Swiper extends Component<SwiperProps, SwiperState> {
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();
Expand Down

0 comments on commit 772fbdc

Please sign in to comment.