Skip to content

Commit

Permalink
fix(swiper): circular current slide fix #7757
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Nov 9, 2020
1 parent 10f4586 commit a63a137
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/taro-components/src/components/swiper/swiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export class Swiper implements ComponentInterface {
if (isNaN(n)) return

if (this.circular) {
this.swiper.slideToLoop(n) // 更新下标
const interval = this.swiper.isBeginning || this.swiper.isBeginning ? this.interval : 0
this.swiper.slideToLoop(n, interval) // 更新下标
} else {
this.swiper.slideTo(n) // 更新下标
}
Expand Down Expand Up @@ -127,6 +128,7 @@ export class Swiper implements ComponentInterface {
watchInterval (newVal) {
this.swiper.params.autoplay.delay = newVal
}

@Watch('swiperWrapper')
watchSwiperWrapper (newVal?: HTMLElement) {
if (!newVal) return
Expand Down Expand Up @@ -170,6 +172,7 @@ export class Swiper implements ComponentInterface {
on: {
// slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionEnd 事件代替
slideChangeTransitionEnd () {
that.current = this.realIndex
that.onChange.emit({
current: this.realIndex,
source: ''
Expand Down

0 comments on commit a63a137

Please sign in to comment.