@tarojs/components 3.6.0-beta.0 → 3.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,11 +28,9 @@ export class Swiper {
28
28
  this.handleSwiperLoop = debounce(() => {
29
29
  if (this.swiper && this.circular) {
30
30
  // @ts-ignore
31
- this.swiper.loopDestroy();
32
- // @ts-ignore
33
- this.swiper.loopCreate();
31
+ this.swiper.loopFix();
34
32
  }
35
- }, 500);
33
+ }, 50);
36
34
  this.handleSwiperSize = debounce(() => {
37
35
  if (this.swiper && !this.circular) {
38
36
  this.swiper.updateSlides();
@@ -189,7 +187,7 @@ export class Swiper {
189
187
  slideChangeTransitionStart(_swiper) {
190
188
  if (that.circular) {
191
189
  if (_swiper.isBeginning || _swiper.isEnd) {
192
- _swiper.slideToLoop(this.realIndex, 0); // 更新下标
190
+ // _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标
193
191
  return;
194
192
  }
195
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"swiper.js","sourceRoot":"","sources":["../../../src/components/swiper/swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAsB,IAAI,EAAE,KAAK,EAAgB,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACxH,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,QAAQ,MAAM,6BAA6B,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,IAAI,WAAW,GAAG,CAAC,CAAA;AAQnB,MAAM,OAAO,MAAM;;IACT,QAAG,GAAG,WAAW,EAAE,CAAA;IA6M3B,2BAAsB,GAAG,GAAG,EAAE;;MAC5B,CAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,UAAU,KAAI,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAA;MACjE,CAAA,MAAA,IAAI,CA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AAI,CAAA;KAC7B;IAED,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAE,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS;MACtD,WAAK,KAAK,EAAC,kBAAkB,EAAC,KAAK,EAAE,KAAK;QACxC,aAAO,IAAI,EAAC,UAAU,IACnB;6BACgB,IAAI,CAAC,GAAG,uFAAuF,cAAc;6BAC7G,IAAI,CAAC,GAAG,8FAA8F,oBAAoB;aAC1I,CACK;QACR,WAAK,KAAK,EAAC,gBAAgB;UACzB,eAAQ,CACJ;QACN,WAAK,KAAK,EAAE,UAAU,CAAC,mBAAmB,EACxC;YACE,0BAA0B,EAAE,CAAC,aAAa;YAC1C,2BAA2B,EAAE,aAAa;WAC3C,CACF,GAAI,CACD,CACD,CACR,CAAA;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, ComponentInterface, Prop, Event, EventEmitter, Watch, Host, Element, State } from '@stencil/core'\nimport classNames from 'classnames'\nimport type ISwiper from 'swiper'\nimport SwiperJS from 'swiper/swiper-bundle.esm.js'\n\nimport { debounce } from '../../utils'\n\nlet INSTANCE_ID = 0\n\n@Component({\n tag: 'taro-swiper-core',\n styleUrls: [\n './style/index.scss'\n ]\n})\nexport class Swiper implements ComponentInterface {\n private _id = INSTANCE_ID++\n\n @Element() el: HTMLElement\n @State() swiperWrapper: HTMLElement | null\n @State() private swiper: ISwiper\n @State() isWillLoadCalled = false\n /**\n * 是否显示面板指示点\n */\n @Prop() indicatorDots = false\n\n /**\n * 指示点颜色\n */\n @Prop() indicatorColor = 'rgba(0, 0, 0, .3)'\n\n /**\n * 当前选中的指示点颜色\n */\n @Prop() indicatorActiveColor = '#000000'\n\n /**\n * 是否自动切换\n */\n @Prop() autoplay = false\n\n /**\n * 当前所在滑块的 index\n */\n @Prop() current = 0\n\n /**\n * 自动切换时间间隔\n */\n @Prop() interval = 5000\n\n /**\n * 滑动动画时长\n */\n @Prop() duration = 500\n\n /**\n * 是否采用衔接滑动\n */\n @Prop() circular = false\n\n /**\n * 滑动方向是否为纵向\n */\n @Prop() vertical = false\n\n /**\n * 前边距,可用于露出前一项的一小部分,接受 px 值\n */\n @Prop() previousMargin = '0px'\n\n /**\n * 后边距,可用于露出后一项的一小部分,接受 px 值\n */\n @Prop() nextMargin = '0px'\n\n /**\n * 同时显示的滑块数量\n */\n @Prop() displayMultipleItems = 1\n\n /**\n * 给 previewImage API 使用,全屏显示 swiper\n */\n @Prop() full = false\n\n /**\n * 给 previewImage API 使用,缩放支持\n */\n @Prop() zoom = false\n\n @Event({\n eventName: 'change'\n }) onChange: EventEmitter\n\n @Event({\n eventName: 'animationfinish'\n }) onAnimationFinish: EventEmitter\n\n @Watch('current')\n watchCurrent (newVal) {\n if (!this.isWillLoadCalled) return\n\n const n = parseInt(newVal, 10)\n if (isNaN(n)) return\n\n if (this.circular) {\n if (!this.swiper.isBeginning && !this.swiper.isEnd) {\n this.swiper.slideToLoop(n) // 更新下标\n }\n } else {\n this.swiper.slideTo(n) // 更新下标\n }\n }\n\n @Watch('autoplay')\n watchAutoplay (newVal) {\n if (!this.isWillLoadCalled || !this.swiper) return\n\n const swiperAutoplay = this.swiper.autoplay\n if (swiperAutoplay) {\n if (swiperAutoplay.running === newVal) return\n \n if (newVal) {\n if (this.swiper.params && typeof this.swiper.params.autoplay === 'object') {\n if (this.swiper.params.autoplay.disableOnInteraction === true) {\n this.swiper.params.autoplay.disableOnInteraction = false\n }\n this.swiper.params.autoplay.delay = this.interval\n }\n swiperAutoplay.start()\n } else {\n swiperAutoplay.stop()\n }\n }\n }\n\n @Watch('duration')\n watchDuration (newVal) {\n if (!this.isWillLoadCalled) return\n this.swiper.params.speed = newVal\n }\n\n @Watch('interval')\n watchInterval (newVal) {\n if (!this.isWillLoadCalled) return\n\n if (typeof this.swiper.params.autoplay === 'object') {\n this.swiper.params.autoplay.delay = newVal\n }\n }\n\n @Watch('swiperWrapper')\n watchSwiperWrapper (newVal?: HTMLElement) {\n if (!this.isWillLoadCalled) return\n if (!newVal) return\n this.el.appendChild = <T extends Node>(newChild: T): T => {\n return newVal.appendChild(newChild)\n }\n this.el.insertBefore = <T extends Node>(newChild: T, refChild: Node | null): T => {\n return newVal.insertBefore(newChild, refChild)\n }\n this.el.replaceChild = <T extends Node>(newChild: Node, oldChild: T): T => {\n return newVal.replaceChild(newChild, oldChild)\n }\n this.el.removeChild = <T extends Node>(oldChild: T): T => {\n return newVal.removeChild(oldChild)\n }\n this.el.addEventListener('DOMNodeInserted', this.handleSwiperSize)\n this.el.addEventListener('DOMNodeRemoved', this.handleSwiperSize)\n }\n\n @Watch(\"circular\")\n watchCircular () {\n if (this.swiper) {\n this.swiper.destroy()\n this.handleInit()\n }\n }\n\n @State() observer: MutationObserver\n @State() observerFirst: MutationObserver\n @State() observerLast: MutationObserver\n\n componentWillLoad () {\n this.isWillLoadCalled = true\n }\n\n componentDidLoad () {\n this.handleInit()\n if (!this.swiper || !this.circular) return\n\n const wrapper = this.swiper.$wrapperEl?.[0]\n this.observer = new MutationObserver(this.handleSwiperLoopListen)\n\n this.observer.observe(wrapper, {\n childList: true\n })\n }\n\n componentWillUpdate () {\n if (!this.swiper) return\n if (this.autoplay && !this.swiper.autoplay?.running) {\n this.swiper.autoplay?.start()\n }\n this.swiper.update() // 更新子元素\n }\n\n componentDidRender () {\n this.handleSwiperLoop()\n }\n\n disconnectedCallback () {\n this.el.removeEventListener('DOMNodeInserted', this.handleSwiperSize)\n this.el.removeEventListener('DOMNodeRemoved', this.handleSwiperSize)\n this.observer?.disconnect?.()\n this.observerFirst?.disconnect?.()\n this.observerLast?.disconnect?.()\n }\n\n handleSwiperLoopListen = () => {\n this.observerFirst?.disconnect && this.observerFirst.disconnect()\n this.observerLast?.disconnect && this.observerLast.disconnect()\n this.observerFirst = new MutationObserver(this.handleSwiperLoop)\n this.observerLast = new MutationObserver(this.handleSwiperLoop)\n const wrapper = this.swiper.$wrapperEl?.[0]\n const list = wrapper.querySelectorAll('taro-swiper-item-core:not(.swiper-slide-duplicate)')\n if (list.length >= 1) {\n this.observerFirst.observe(list[0], {\n characterData: true\n })\n } else if (list.length >= 2) {\n this.observerLast.observe(list[list.length - 1], {\n characterData: true\n })\n }\n }\n\n handleSwiperLoop = debounce(() => {\n if (this.swiper && this.circular) {\n // @ts-ignore\n this.swiper.loopDestroy()\n // @ts-ignore\n this.swiper.loopCreate()\n }\n }, 500)\n\n handleSwiperSize = debounce(() => {\n if (this.swiper && !this.circular) {\n this.swiper.updateSlides()\n }\n }, 50)\n\n handleInit () {\n const {\n autoplay,\n circular,\n current,\n displayMultipleItems,\n duration,\n interval,\n vertical\n } = this\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this\n\n const options: any = {\n pagination: { el: `.taro-swiper-${this._id} > .swiper-container > .swiper-pagination` },\n direction: vertical ? 'vertical' : 'horizontal',\n loop: circular,\n slidesPerView: displayMultipleItems,\n initialSlide: current,\n speed: duration,\n observer: true,\n observeParents: true,\n zoom: this.zoom,\n on: {\n slideTo () {\n that.current = this.realIndex\n },\n // slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替\n slideChangeTransitionStart (_swiper: ISwiper) {\n if (that.circular) {\n if (_swiper.isBeginning || _swiper.isEnd) {\n _swiper.slideToLoop(this.realIndex, 0) // 更新下标\n return\n }\n }\n that.onChange.emit({\n current: this.realIndex,\n source: ''\n })\n },\n transitionEnd () {\n that.onAnimationFinish.emit({\n current: this.realIndex,\n source: ''\n })\n },\n observerUpdate (_swiper: ISwiper, e) {\n const target = e.target\n const className = target && typeof target.className === 'string' ? target.className : ''\n if (className.includes('taro_page') && target.style.display !== 'none') {\n if (that.autoplay && target.contains(_swiper.$el[0])) {\n if (that.circular) {\n _swiper.slideToLoop(this.realIndex, 0) // 更新下标\n } else {\n _swiper.slideTo(this.realIndex)\n }\n }\n }\n }\n }\n }\n\n // 自动播放\n if (autoplay) {\n options.autoplay = {\n delay: interval,\n disableOnInteraction: false\n }\n }\n\n this.swiper = new SwiperJS(`.taro-swiper-${this._id} > .swiper-container`, options)\n this.swiperWrapper = this.el.querySelector(`.taro-swiper-${this._id} > .swiper-container > .swiper-wrapper`)\n }\n\n render () {\n const {\n vertical,\n indicatorDots,\n indicatorColor,\n indicatorActiveColor\n } = this\n\n const hostStyle: Record<string, string> = { overflow: 'hidden' }\n const style: Record<string, string> = { overflow: 'visible' }\n if (this.full) {\n hostStyle.height = '100%'\n style.height = '100%'\n }\n\n const [, previousMargin] = /^(\\d+)px/.exec(this.previousMargin) || []\n const [, nextMargin] = /^(\\d+)px/.exec(this.nextMargin) || []\n const pM = parseInt(previousMargin) || 0\n const nM = parseInt(nextMargin) || 0\n if (vertical) {\n style.marginTop = `${pM}px`\n style.marginBottom = `${nM}px`\n } else {\n style.marginRight = `${nM}px`\n style.marginLeft = `${pM}px`\n }\n\n return (\n <Host class={`taro-swiper-${this._id}`} style={hostStyle}>\n <div class='swiper-container' style={style}>\n <style type='text/css'>\n {`\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ${indicatorColor} }\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ${indicatorActiveColor} }\n `}\n </style>\n <div class='swiper-wrapper'>\n <slot />\n </div>\n <div class={classNames('swiper-pagination',\n {\n 'swiper-pagination-hidden': !indicatorDots,\n 'swiper-pagination-bullets': indicatorDots\n }\n )} />\n </div>\n </Host>\n )\n }\n}\n"]}
1
+ {"version":3,"file":"swiper.js","sourceRoot":"","sources":["../../../src/components/swiper/swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAsB,IAAI,EAAE,KAAK,EAAgB,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACxH,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,QAAQ,MAAM,6BAA6B,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,IAAI,WAAW,GAAG,CAAC,CAAA;AAQnB,MAAM,OAAO,MAAM;;IACT,QAAG,GAAG,WAAW,EAAE,CAAA;IA6M3B,2BAAsB,GAAG,GAAG,EAAE;;MAC5B,CAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,UAAU,KAAI,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAA;MACjE,CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,UAAU,KAAI,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAA;MAC/D,IAAI,CAAC,aAAa,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;MAChE,IAAI,CAAC,YAAY,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;MAC/D,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,UAAU,0CAAG,CAAC,CAAC,CAAA;MAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,oDAAoD,CAAC,CAAA;MAC3F,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;QACpB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;UAClC,aAAa,EAAE,IAAI;SACpB,CAAC,CAAA;OACH;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, ComponentInterface, Prop, Event, EventEmitter, Watch, Host, Element, State } from '@stencil/core'\nimport classNames from 'classnames'\nimport type ISwiper from 'swiper'\nimport SwiperJS from 'swiper/swiper-bundle.esm.js'\n\nimport { debounce } from '../../utils'\n\nlet INSTANCE_ID = 0\n\n@Component({\n tag: 'taro-swiper-core',\n styleUrls: [\n './style/index.scss'\n ]\n})\nexport class Swiper implements ComponentInterface {\n private _id = INSTANCE_ID++\n\n @Element() el: HTMLElement\n @State() swiperWrapper: HTMLElement | null\n @State() private swiper: ISwiper\n @State() isWillLoadCalled = false\n /**\n * 是否显示面板指示点\n */\n @Prop() indicatorDots = false\n\n /**\n * 指示点颜色\n */\n @Prop() indicatorColor = 'rgba(0, 0, 0, .3)'\n\n /**\n * 当前选中的指示点颜色\n */\n @Prop() indicatorActiveColor = '#000000'\n\n /**\n * 是否自动切换\n */\n @Prop() autoplay = false\n\n /**\n * 当前所在滑块的 index\n */\n @Prop() current = 0\n\n /**\n * 自动切换时间间隔\n */\n @Prop() interval = 5000\n\n /**\n * 滑动动画时长\n */\n @Prop() duration = 500\n\n /**\n * 是否采用衔接滑动\n */\n @Prop() circular = false\n\n /**\n * 滑动方向是否为纵向\n */\n @Prop() vertical = false\n\n /**\n * 前边距,可用于露出前一项的一小部分,接受 px 值\n */\n @Prop() previousMargin = '0px'\n\n /**\n * 后边距,可用于露出后一项的一小部分,接受 px 值\n */\n @Prop() nextMargin = '0px'\n\n /**\n * 同时显示的滑块数量\n */\n @Prop() displayMultipleItems = 1\n\n /**\n * 给 previewImage API 使用,全屏显示 swiper\n */\n @Prop() full = false\n\n /**\n * 给 previewImage API 使用,缩放支持\n */\n @Prop() zoom = false\n\n @Event({\n eventName: 'change'\n }) onChange: EventEmitter\n\n @Event({\n eventName: 'animationfinish'\n }) onAnimationFinish: EventEmitter\n\n @Watch('current')\n watchCurrent (newVal) {\n if (!this.isWillLoadCalled) return\n\n const n = parseInt(newVal, 10)\n if (isNaN(n)) return\n\n if (this.circular) {\n if (!this.swiper.isBeginning && !this.swiper.isEnd) {\n this.swiper.slideToLoop(n) // 更新下标\n }\n } else {\n this.swiper.slideTo(n) // 更新下标\n }\n }\n\n @Watch('autoplay')\n watchAutoplay (newVal) {\n if (!this.isWillLoadCalled || !this.swiper) return\n\n const swiperAutoplay = this.swiper.autoplay\n if (swiperAutoplay) {\n if (swiperAutoplay.running === newVal) return\n \n if (newVal) {\n if (this.swiper.params && typeof this.swiper.params.autoplay === 'object') {\n if (this.swiper.params.autoplay.disableOnInteraction === true) {\n this.swiper.params.autoplay.disableOnInteraction = false\n }\n this.swiper.params.autoplay.delay = this.interval\n }\n swiperAutoplay.start()\n } else {\n swiperAutoplay.stop()\n }\n }\n }\n\n @Watch('duration')\n watchDuration (newVal) {\n if (!this.isWillLoadCalled) return\n this.swiper.params.speed = newVal\n }\n\n @Watch('interval')\n watchInterval (newVal) {\n if (!this.isWillLoadCalled) return\n\n if (typeof this.swiper.params.autoplay === 'object') {\n this.swiper.params.autoplay.delay = newVal\n }\n }\n\n @Watch('swiperWrapper')\n watchSwiperWrapper (newVal?: HTMLElement) {\n if (!this.isWillLoadCalled) return\n if (!newVal) return\n this.el.appendChild = <T extends Node>(newChild: T): T => {\n return newVal.appendChild(newChild)\n }\n this.el.insertBefore = <T extends Node>(newChild: T, refChild: Node | null): T => {\n return newVal.insertBefore(newChild, refChild)\n }\n this.el.replaceChild = <T extends Node>(newChild: Node, oldChild: T): T => {\n return newVal.replaceChild(newChild, oldChild)\n }\n this.el.removeChild = <T extends Node>(oldChild: T): T => {\n return newVal.removeChild(oldChild)\n }\n this.el.addEventListener('DOMNodeInserted', this.handleSwiperSize)\n this.el.addEventListener('DOMNodeRemoved', this.handleSwiperSize)\n }\n\n @Watch(\"circular\")\n watchCircular () {\n if (this.swiper) {\n this.swiper.destroy()\n this.handleInit()\n }\n }\n\n @State() observer: MutationObserver\n @State() observerFirst: MutationObserver\n @State() observerLast: MutationObserver\n\n componentWillLoad () {\n this.isWillLoadCalled = true\n }\n\n componentDidLoad () {\n this.handleInit()\n if (!this.swiper || !this.circular) return\n\n const wrapper = this.swiper.$wrapperEl?.[0]\n this.observer = new MutationObserver(this.handleSwiperLoopListen)\n\n this.observer.observe(wrapper, {\n childList: true\n })\n }\n\n componentWillUpdate () {\n if (!this.swiper) return\n if (this.autoplay && !this.swiper.autoplay?.running) {\n this.swiper.autoplay?.start()\n }\n this.swiper.update() // 更新子元素\n }\n\n componentDidRender () {\n this.handleSwiperLoop()\n }\n\n disconnectedCallback () {\n this.el.removeEventListener('DOMNodeInserted', this.handleSwiperSize)\n this.el.removeEventListener('DOMNodeRemoved', this.handleSwiperSize)\n this.observer?.disconnect?.()\n this.observerFirst?.disconnect?.()\n this.observerLast?.disconnect?.()\n }\n\n handleSwiperLoopListen = () => {\n this.observerFirst?.disconnect && this.observerFirst.disconnect()\n this.observerLast?.disconnect && this.observerLast.disconnect()\n this.observerFirst = new MutationObserver(this.handleSwiperLoop)\n this.observerLast = new MutationObserver(this.handleSwiperLoop)\n const wrapper = this.swiper.$wrapperEl?.[0]\n const list = wrapper.querySelectorAll('taro-swiper-item-core:not(.swiper-slide-duplicate)')\n if (list.length >= 1) {\n this.observerFirst.observe(list[0], {\n characterData: true\n })\n } else if (list.length >= 2) {\n this.observerLast.observe(list[list.length - 1], {\n characterData: true\n })\n }\n }\n\n handleSwiperLoop = debounce(() => {\n if (this.swiper && this.circular) {\n // @ts-ignore\n this.swiper.loopFix()\n }\n }, 50)\n\n handleSwiperSize = debounce(() => {\n if (this.swiper && !this.circular) {\n this.swiper.updateSlides()\n }\n }, 50)\n\n handleInit () {\n const {\n autoplay,\n circular,\n current,\n displayMultipleItems,\n duration,\n interval,\n vertical\n } = this\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this\n\n const options: any = {\n pagination: { el: `.taro-swiper-${this._id} > .swiper-container > .swiper-pagination` },\n direction: vertical ? 'vertical' : 'horizontal',\n loop: circular,\n slidesPerView: displayMultipleItems,\n initialSlide: current,\n speed: duration,\n observer: true,\n observeParents: true,\n zoom: this.zoom,\n on: {\n slideTo () {\n that.current = this.realIndex\n },\n // slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替\n slideChangeTransitionStart (_swiper: ISwiper) {\n if (that.circular) {\n if (_swiper.isBeginning || _swiper.isEnd) {\n // _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标\n return\n }\n }\n that.onChange.emit({\n current: this.realIndex,\n source: ''\n })\n },\n transitionEnd () {\n that.onAnimationFinish.emit({\n current: this.realIndex,\n source: ''\n })\n },\n observerUpdate (_swiper: ISwiper, e) {\n const target = e.target\n const className = target && typeof target.className === 'string' ? target.className : ''\n if (className.includes('taro_page') && target.style.display !== 'none') {\n if (that.autoplay && target.contains(_swiper.$el[0])) {\n if (that.circular) {\n _swiper.slideToLoop(this.realIndex, 0) // 更新下标\n } else {\n _swiper.slideTo(this.realIndex)\n }\n }\n }\n }\n }\n }\n\n // 自动播放\n if (autoplay) {\n options.autoplay = {\n delay: interval,\n disableOnInteraction: false\n }\n }\n\n this.swiper = new SwiperJS(`.taro-swiper-${this._id} > .swiper-container`, options)\n this.swiperWrapper = this.el.querySelector(`.taro-swiper-${this._id} > .swiper-container > .swiper-wrapper`)\n }\n\n render () {\n const {\n vertical,\n indicatorDots,\n indicatorColor,\n indicatorActiveColor\n } = this\n\n const hostStyle: Record<string, string> = { overflow: 'hidden' }\n const style: Record<string, string> = { overflow: 'visible' }\n if (this.full) {\n hostStyle.height = '100%'\n style.height = '100%'\n }\n\n const [, previousMargin] = /^(\\d+)px/.exec(this.previousMargin) || []\n const [, nextMargin] = /^(\\d+)px/.exec(this.nextMargin) || []\n const pM = parseInt(previousMargin) || 0\n const nM = parseInt(nextMargin) || 0\n if (vertical) {\n style.marginTop = `${pM}px`\n style.marginBottom = `${nM}px`\n } else {\n style.marginRight = `${nM}px`\n style.marginLeft = `${pM}px`\n }\n\n return (\n <Host class={`taro-swiper-${this._id}`} style={hostStyle}>\n <div class='swiper-container' style={style}>\n <style type='text/css'>\n {`\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ${indicatorColor} }\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ${indicatorActiveColor} }\n `}\n </style>\n <div class='swiper-wrapper'>\n <slot />\n </div>\n <div class={classNames('swiper-pagination',\n {\n 'swiper-pagination-hidden': !indicatorDots,\n 'swiper-pagination-bullets': indicatorDots\n }\n )} />\n </div>\n </Host>\n )\n }\n}\n"]}
@@ -9882,11 +9882,9 @@ const Swiper = class {
9882
9882
  this.handleSwiperLoop = debounce(() => {
9883
9883
  if (this.swiper && this.circular) {
9884
9884
  // @ts-ignore
9885
- this.swiper.loopDestroy();
9886
- // @ts-ignore
9887
- this.swiper.loopCreate();
9885
+ this.swiper.loopFix();
9888
9886
  }
9889
- }, 500);
9887
+ }, 50);
9890
9888
  this.handleSwiperSize = debounce(() => {
9891
9889
  if (this.swiper && !this.circular) {
9892
9890
  this.swiper.updateSlides();
@@ -10043,7 +10041,7 @@ const Swiper = class {
10043
10041
  slideChangeTransitionStart(_swiper) {
10044
10042
  if (that.circular) {
10045
10043
  if (_swiper.isBeginning || _swiper.isEnd) {
10046
- _swiper.slideToLoop(this.realIndex, 0); // 更新下标
10044
+ // _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标
10047
10045
  return;
10048
10046
  }
10049
10047
  }