@tarojs/components-react 4.0.4 → 4.0.5-alpha.2

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.
@@ -1,13 +1,16 @@
1
- import { __rest } from 'tslib';
2
- import 'swiper/swiper-bundle.min.css';
1
+ import { __rest, __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
2
+ import 'swiper/swiper-bundle.css';
3
3
  import './style/index.css.js';
4
4
  import classNames from 'classnames';
5
5
  import React__default from 'react';
6
- import Swipers from 'swiper/swiper-bundle.esm.js';
6
+ import Swipers from 'swiper/bundle';
7
7
  import { debounce, createForwardRefComponent } from '../../utils/index.js';
8
8
  import { jsx, jsxs } from 'react/jsx-runtime';
9
9
 
10
+ var _SwiperInner_source, _SwiperInner_swiperResetting, _SwiperInner_lastSwiperActiveIndex, _SwiperInner_domChangeByOutSide;
10
11
  let INSTANCE_ID = 0;
12
+ const ONE_ADDITIONAL_SLIDES_THRESHOLD = 5;
13
+ const TWO_ADDITIONAL_SLIDES_THRESHOLD = 7;
11
14
  const createEvent = type => {
12
15
  let e;
13
16
  try {
@@ -45,181 +48,315 @@ class SwiperItemInner extends React__default.Component {
45
48
  }
46
49
  }
47
50
  class SwiperInner extends React__default.Component {
48
- constructor() {
49
- super(...arguments);
51
+ constructor(props) {
52
+ var _this;
53
+ super(props);
54
+ _this = this;
50
55
  this._id = 1 + INSTANCE_ID++;
51
- this._$current = 0;
52
- this._$width = 0;
53
- this._$height = 0;
54
- this.handleSwiperLoopListen = () => {
55
- var _a, _b, _c, _d;
56
- (_b = (_a = this.observerFirst) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
57
- (_d = (_c = this.observerLast) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
58
- this.observerFirst = new MutationObserver(this.handleSwiperLoop);
59
- this.observerLast = new MutationObserver(this.handleSwiperLoop);
60
- const wrapper = this.mySwiper.$wrapperEl[0];
61
- const list = wrapper.querySelectorAll('taro-swiper-item-core:not(.swiper-slide-duplicate)');
62
- if (list.length >= 1) {
63
- this.observerFirst.observe(list[0], {
64
- characterData: true
65
- });
66
- } else if (list.length >= 2) {
67
- this.observerLast.observe(list[list.length - 1], {
68
- characterData: true
69
- });
56
+ _SwiperInner_source.set(this, 'autoplay');
57
+ _SwiperInner_swiperResetting.set(this, false);
58
+ _SwiperInner_lastSwiperActiveIndex.set(this, 0);
59
+ _SwiperInner_domChangeByOutSide.set(this, false);
60
+ this.handleInit = function () {
61
+ let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
62
+ const {
63
+ autoplay = false,
64
+ circular = true,
65
+ current = 0,
66
+ displayMultipleItems = 1,
67
+ duration = 500,
68
+ interval = 5000,
69
+ currentItemId,
70
+ effectsProps = {},
71
+ vertical
72
+ } = _this.props;
73
+ let initialSlide = parseInt(String(current), 10);
74
+ if (reset) {
75
+ initialSlide = __classPrivateFieldGet(_this, _SwiperInner_lastSwiperActiveIndex, "f");
76
+ } else {
77
+ if (currentItemId) {
78
+ let itemIdIndex = 0;
79
+ _this.getSlidersList().forEach((swiperItem, index) => {
80
+ // @ts-ignore
81
+ if (swiperItem.itemId && swiperItem.itemId === currentItemId) {
82
+ itemIdIndex = index;
83
+ }
84
+ });
85
+ initialSlide = itemIdIndex;
86
+ }
70
87
  }
71
- };
72
- this.handleSwiperLoop = debounce(() => {
73
- if (this.mySwiper && this.mySwiper.$wrapperEl && this.props.circular) {
88
+ const loopAdditionalSlides = _this.getLoopAdditionalSlides();
89
+ const centeredSlides = parseFloat(String(displayMultipleItems)) === 1;
90
+ const slidesPerView = parseFloat(String(displayMultipleItems)) === 1 ? 'auto' : displayMultipleItems;
91
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
92
+ const that = _this;
93
+ const opt = Object.assign(Object.assign({
94
+ // 指示器
95
+ pagination: {
96
+ el: `.taro-swiper-${_this._id} > .swiper-container > .swiper-pagination`
97
+ },
98
+ direction: vertical ? 'vertical' : 'horizontal',
99
+ loop: circular,
100
+ slidesPerView: slidesPerView,
101
+ initialSlide,
102
+ speed: parseInt(String(duration), 10),
103
+ observer: true,
104
+ observeParents: true,
105
+ loopAdditionalSlides,
106
+ centeredSlides
107
+ }, effectsProps), {
108
+ on: {
109
+ init(_swiper) {
110
+ that.getNeedFixLoop() && _swiper.loopFix();
111
+ that.props.autoplay && _swiper.autoplay.start();
112
+ },
113
+ slideChangeTransitionEnd(_swiper) {
114
+ if (__classPrivateFieldGet(that, _SwiperInner_swiperResetting, "f")) return;
115
+ that.getNeedFixLoop() && _swiper.loopFix();
116
+ that.props.autoplay && _swiper.autoplay.start();
117
+ const e = createEvent('touchend');
118
+ try {
119
+ const currentId = that.getCurrentId(_swiper);
120
+ Object.defineProperty(e, 'detail', {
121
+ enumerable: true,
122
+ value: {
123
+ source: __classPrivateFieldGet(that, _SwiperInner_source, "f"),
124
+ current: this.realIndex,
125
+ currentId: currentId
126
+ }
127
+ });
128
+ } catch (err) {} // eslint-disable-line no-empty
129
+ that.handleOnAnimationFinish(e);
130
+ __classPrivateFieldSet(that, _SwiperInner_source, 'autoplay', "f");
131
+ },
132
+ touchEnd: _swiper => {
133
+ __classPrivateFieldSet(that, _SwiperInner_source, 'touch', "f");
134
+ that.props.autoplay && _swiper.autoplay.start();
135
+ },
136
+ touchStart: _swiper => {
137
+ __classPrivateFieldSet(that, _SwiperInner_source, 'touch', "f");
138
+ that.props.autoplay && _swiper.autoplay.pause();
139
+ },
140
+ slideChange(_swiper) {
141
+ if (__classPrivateFieldGet(that, _SwiperInner_swiperResetting, "f") || __classPrivateFieldGet(that, _SwiperInner_lastSwiperActiveIndex, "f") === _swiper.realIndex) return;
142
+ __classPrivateFieldSet(that, _SwiperInner_lastSwiperActiveIndex, _swiper.realIndex, "f");
143
+ const e = createEvent('touchend');
144
+ try {
145
+ const currentId = that.getCurrentId(_swiper);
146
+ Object.defineProperty(e, 'detail', {
147
+ enumerable: true,
148
+ value: {
149
+ current: this.realIndex,
150
+ source: __classPrivateFieldGet(that, _SwiperInner_source, "f"),
151
+ currentId
152
+ }
153
+ });
154
+ } catch (err) {} // eslint-disable-line no-empty
155
+ that.handleOnChange(e);
156
+ },
157
+ autoplay(_swiper) {
158
+ // Note: 修复 autoplay 时,切换到其他页面再切回来,autoplay 会停止的问题
159
+ _swiper.animating = false;
160
+ __classPrivateFieldSet(that, _SwiperInner_source, 'autoplay', "f");
161
+ }
162
+ }
163
+ });
164
+ // 自动播放
165
+ if (autoplay) {
166
+ opt.autoplay = {
167
+ delay: parseInt(String(interval), 10),
168
+ disableOnInteraction: false
169
+ };
170
+ }
171
+ _this.swiper = new Swipers(_this.$el, opt);
172
+ if (_this.getNeedFixLoop()) {
74
173
  // @ts-ignore
75
- this.mySwiper.loopDestroy();
174
+ const minTranslate = _this.swiper.minTranslate.bind(_this.swiper);
76
175
  // @ts-ignore
77
- this.mySwiper.loopCreate();
176
+ const maxTranslate = _this.swiper.maxTranslate.bind(_this.swiper);
177
+ if (centeredSlides && _this.getSlidersList().length < 4) {
178
+ // @ts-ignore
179
+ _this.swiper.minTranslate = () => minTranslate() + _this.parseMargin()[1];
180
+ // @ts-ignore
181
+ _this.swiper.maxTranslate = () => maxTranslate() - _this.parseMargin()[0];
182
+ } else {
183
+ // @ts-ignore
184
+ _this.swiper.minTranslate = () => minTranslate() - _this.parseMargin()[0];
185
+ // @ts-ignore
186
+ _this.swiper.maxTranslate = () => maxTranslate() + _this.parseMargin()[1];
187
+ }
188
+ }
189
+ _this.setState({
190
+ swiperWrapper: _this.swiper.wrapperEl
191
+ });
192
+ };
193
+ this.handleSwiperSizeDebounce = debounce(() => {
194
+ if (!this.swiper) return;
195
+ if (this.props.circular) {
196
+ if (__classPrivateFieldGet(this, _SwiperInner_domChangeByOutSide, "f")) {
197
+ this.reset();
198
+ __classPrivateFieldSet(this, _SwiperInner_domChangeByOutSide, false, "f");
199
+ }
200
+ } else {
201
+ this.swiper.update();
202
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, false, "f");
78
203
  }
79
- }, 500);
204
+ }, 50);
205
+ this.reset = () => {
206
+ if (!this.swiper) return;
207
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, true, "f");
208
+ __classPrivateFieldSet(this, _SwiperInner_lastSwiperActiveIndex, this.swiper.realIndex, "f");
209
+ this.swiper.destroy();
210
+ this.handleInit(true);
211
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, false, "f");
212
+ };
213
+ this.getSlidersList = () => {
214
+ var _a, _b;
215
+ return ((_b = (_a = this.$el) === null || _a === void 0 ? void 0 : _a.querySelectorAll) === null || _b === void 0 ? void 0 : _b.call(_a, '.swiper-slide')) || [];
216
+ };
217
+ this.getNeedFixLoop = () => {
218
+ const margins = this.parseMargin();
219
+ const hasMargin = margins.filter(Boolean).length > 0;
220
+ return this.props.circular && hasMargin;
221
+ };
222
+ this.parseMargin = () => {
223
+ const {
224
+ previousMargin = '0px',
225
+ nextMargin = '0px'
226
+ } = this.props;
227
+ const [, pM] = /^(\d+)px/.exec(previousMargin) || [];
228
+ const [, nN] = /^(\d+)px/.exec(nextMargin) || [];
229
+ return [parseInt(pM) || 0, parseInt(nN) || 0];
230
+ };
231
+ this.state = {
232
+ swiperWrapper: null
233
+ };
80
234
  }
81
235
  componentDidMount() {
82
- const {
83
- autoplay = false,
84
- circular = true,
85
- current = 0,
86
- displayMultipleItems = 1,
87
- duration = 500,
88
- interval = 5000,
89
- spaceBetween,
90
- vertical
91
- } = this.props;
92
- // eslint-disable-next-line @typescript-eslint/no-this-alias
93
- const that = this;
94
- const opt = {
95
- // 指示器
96
- pagination: {
97
- el: `.taro-swiper-${this._id} > .swiper-container > .swiper-pagination`
98
- },
99
- direction: vertical ? 'vertical' : 'horizontal',
100
- loop: circular,
101
- slidesPerView: parseFloat(String(displayMultipleItems)),
102
- initialSlide: parseInt(String(current), 10),
103
- speed: parseInt(String(duration), 10),
104
- observer: true,
105
- observeParents: true,
106
- on: {
107
- slideChange() {
108
- const e = createEvent('touchend');
109
- try {
110
- Object.defineProperty(e, 'detail', {
111
- enumerable: true,
112
- value: {
113
- current: this.realIndex
114
- }
115
- });
116
- } catch (err) {} // eslint-disable-line no-empty
117
- that._$current = this.realIndex;
118
- that.handleOnChange(e);
119
- },
120
- transitionEnd() {
121
- const e = createEvent('touchend');
122
- try {
123
- Object.defineProperty(e, 'detail', {
124
- enumerable: true,
125
- value: {
126
- current: this.mySwiper.realIndex
127
- }
128
- });
129
- if (this.mySwiper.isBeginning) {
130
- this.mySwiper.slideToLoop(this.props.children.length - 1, 0);
131
- } else if (this.mySwiper.isEnd) {
132
- this.mySwiper.slideToLoop(0, 0);
133
- }
134
- } catch (err) {} // eslint-disable-line no-empty
135
- that.handleOnAnimationFinish(e);
136
- },
137
- observerUpdate(_swiper, e) {
138
- const target = e.target;
139
- const className = target && typeof target.className === 'string' ? target.className : '';
140
- if (className.includes('taro_page') && target.style.display !== 'none') {
141
- if (that.props.autoplay && target.contains(_swiper.$el[0])) {
142
- if (that.props.circular) {
143
- _swiper.slideToLoop(this.realIndex, 0); // 更新下标
144
- } else {
145
- _swiper.slideTo(this.realIndex);
146
- }
147
- }
148
- }
149
- }
236
+ this.handleInit();
237
+ }
238
+ hackSwiperWrapDomAction() {
239
+ if (!this.state.swiperWrapper || !this.swiper) return;
240
+ const appendChild = this.state.swiperWrapper.appendChild.bind(this.state.swiperWrapper);
241
+ const removeChild = this.state.swiperWrapper.removeChild.bind(this.state.swiperWrapper);
242
+ const replaceChild = this.state.swiperWrapper.replaceChild.bind(this.state.swiperWrapper);
243
+ const insertBefore = this.state.swiperWrapper.insertBefore.bind(this.state.swiperWrapper);
244
+ const beforeAction = () => {
245
+ if (!this.state.swiperWrapper || !this.swiper) return;
246
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, true, "f");
247
+ if (!__classPrivateFieldGet(this, _SwiperInner_domChangeByOutSide, "f") && this.props.circular) {
248
+ __classPrivateFieldSet(this, _SwiperInner_domChangeByOutSide, true, "f");
249
+ this.swiper.loopDestroy();
250
+ this.swiper.params.loop = false;
150
251
  }
151
252
  };
152
- // 自动播放
153
- if (autoplay) {
154
- opt.autoplay = {
155
- delay: parseInt(String(interval), 10),
156
- disableOnInteraction: false
157
- };
253
+ // eslint-disable-next-line react/no-direct-mutation-state
254
+ this.state.swiperWrapper.appendChild = function () {
255
+ beforeAction();
256
+ return appendChild(...arguments);
257
+ };
258
+ // eslint-disable-next-line react/no-direct-mutation-state
259
+ this.state.swiperWrapper.removeChild = function () {
260
+ beforeAction();
261
+ return removeChild(...arguments);
262
+ };
263
+ // eslint-disable-next-line react/no-direct-mutation-state
264
+ this.state.swiperWrapper.replaceChild = function () {
265
+ beforeAction();
266
+ return replaceChild(...arguments);
267
+ };
268
+ // eslint-disable-next-line react/no-direct-mutation-state
269
+ this.state.swiperWrapper.insertBefore = function () {
270
+ beforeAction();
271
+ return insertBefore(...arguments);
272
+ };
273
+ }
274
+ componentDidUpdate(prevProps, pervState) {
275
+ if (!this.swiper || !this.state.swiperWrapper) return;
276
+ if (pervState.swiperWrapper !== this.state.swiperWrapper && this.state.swiperWrapper) {
277
+ this.observer && this.observer.disconnect();
278
+ this.observer = new MutationObserver(this.handleSwiperSizeDebounce);
279
+ this.observer.observe(this.state.swiperWrapper, {
280
+ childList: true
281
+ });
282
+ this.hackSwiperWrapDomAction();
158
283
  }
159
- // 两端距离
160
- if (spaceBetween) {
161
- opt.spaceBetween = spaceBetween;
284
+ if (prevProps.circular !== this.props.circular || prevProps.displayMultipleItems !== this.props.displayMultipleItems) {
285
+ this.reset();
162
286
  }
163
- this.mySwiper = new Swipers(this.$el, opt);
164
- setTimeout(() => {
165
- this.mySwiper.update();
166
- }, 500);
167
- if (!this.mySwiper || !this.props.circular) return;
168
- const wrapper = this.mySwiper.$wrapperEl[0];
169
- this.observer = new MutationObserver(this.handleSwiperLoopListen);
170
- this.observer.observe(wrapper, {
171
- childList: true
172
- });
173
- }
174
- UNSAFE_componentWillReceiveProps(nextProps) {
175
- if (this.mySwiper) {
176
- const nextCurrent = typeof nextProps.current === 'number' ? nextProps.current : this._$current || 0;
177
- this.handleSwiperLoop();
178
- // 是否衔接滚动模式
179
- if (nextProps.circular) {
180
- if (!this.mySwiper.isBeginning && !this.mySwiper.isEnd) {
181
- this.mySwiper.slideToLoop(parseInt(nextCurrent, 10)); // 更新下标
182
- }
287
+ if (prevProps.interval !== this.props.interval) {
288
+ if (typeof this.swiper.params.autoplay === 'object') {
289
+ this.swiper.params.autoplay.delay = this.props.interval;
290
+ }
291
+ }
292
+ if (prevProps.duration !== this.props.duration) {
293
+ this.swiper.params.speed = this.props.duration;
294
+ }
295
+ if (prevProps.current !== this.props.current && !this.props.currentItemId) {
296
+ const n = parseInt(String(this.props.current), 10);
297
+ if (isNaN(n) || n === this.swiper.realIndex) return;
298
+ __classPrivateFieldSet(this, _SwiperInner_source, '', "f");
299
+ if (this.props.circular) {
300
+ this.swiper.slideToLoop(n); // 更新下标
301
+ this.props.autoplay && this.swiper.autoplay.pause();
302
+ // @ts-ignore
303
+ this.swiper.loopFix();
304
+ this.props.autoplay && this.swiper.autoplay.start();
183
305
  } else {
184
- this.mySwiper.slideTo(parseInt(nextCurrent, 10) + 1); // 更新下标
306
+ this.swiper.slideTo(n); // 更新下标
185
307
  }
186
- const autoplay = this.mySwiper.autoplay;
187
- // 判断是否需要停止或开始自动轮播
188
- if (autoplay.running !== nextProps.autoplay) {
189
- if (nextProps.autoplay) {
190
- if (typeof this.mySwiper.params.autoplay === 'object') {
191
- this.mySwiper.params.autoplay.disableOnInteraction = false;
192
- this.mySwiper.params.autoplay.delay = parseInt(String(this.props.interval) || '3000', 10);
308
+ }
309
+ if (prevProps.autoplay !== this.props.autoplay) {
310
+ const swiperAutoplay = this.swiper.autoplay;
311
+ if (swiperAutoplay) {
312
+ if (swiperAutoplay.running === this.props.autoplay) return;
313
+ if (this.props.autoplay) {
314
+ if (this.swiper.params && typeof this.swiper.params.autoplay === 'object') {
315
+ if (this.swiper.params.autoplay.disableOnInteraction === true) {
316
+ this.swiper.params.autoplay.disableOnInteraction = false;
317
+ }
318
+ this.swiper.params.autoplay.delay = this.props.interval;
193
319
  }
194
- autoplay.start();
320
+ swiperAutoplay.start();
195
321
  } else {
196
- autoplay.stop();
322
+ swiperAutoplay.stop();
197
323
  }
198
324
  }
199
- this.mySwiper.update(); // 更新子元素
200
325
  }
201
- }
202
- componentDidUpdate(preProps) {
203
- if (preProps.children.length === 0 && this.props.children.length > 0) {
204
- this.mySwiper.loopDestroy();
205
- this.mySwiper.loopCreate();
206
- }
207
- if (!this.mySwiper) return;
208
- if (this.props.autoplay) {
209
- if (this._$width !== this.mySwiper.width || this._$height !== this.mySwiper.height) {
210
- this.mySwiper.autoplay.start();
326
+ if (prevProps.currentItemId !== this.props.currentItemId) {
327
+ let itemIdIndex = 0;
328
+ this.getSlidersList().forEach((swiperItem, index) => {
329
+ const itemId = swiperItem.getAttribute('item-id');
330
+ // @ts-ignore
331
+ if (itemId === this.props.currentItemId) {
332
+ if (this.props.circular) {
333
+ itemIdIndex = Number(swiperItem.getAttribute('data-swiper-slide-index'));
334
+ } else {
335
+ itemIdIndex = index;
336
+ }
337
+ }
338
+ });
339
+ if (isNaN(itemIdIndex) || itemIdIndex === this.swiper.realIndex) return;
340
+ __classPrivateFieldSet(this, _SwiperInner_source, '', "f");
341
+ if (this.props.circular) {
342
+ this.swiper.slideToLoop(itemIdIndex); // 更新下标
343
+ this.props.autoplay && this.swiper.autoplay.pause();
344
+ // @ts-ignore
345
+ this.swiper.loopFix();
346
+ this.props.autoplay && this.swiper.autoplay.start();
347
+ } else {
348
+ this.swiper.slideTo(itemIdIndex); // 更新下标
211
349
  }
212
350
  }
213
- this._$width = this.mySwiper.width;
214
- this._$height = this.mySwiper.height;
215
351
  }
216
352
  componentWillUnmount() {
217
- var _a, _b, _c, _d, _e, _f;
353
+ var _a, _b, _c, _d;
218
354
  this.$el = null;
219
- if (this.mySwiper) this.mySwiper.destroy();
220
- (_b = (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
221
- (_d = (_c = this.observerFirst) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
222
- (_f = (_e = this.observerLast) === null || _e === void 0 ? void 0 : _e.disconnect) === null || _f === void 0 ? void 0 : _f.call(_e);
355
+ (_b = (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
356
+ (_d = (_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
357
+ this.setState({
358
+ swiperWrapper: null
359
+ });
223
360
  }
224
361
  handleOnChange(e) {
225
362
  const func = this.props.onChange;
@@ -229,17 +366,23 @@ class SwiperInner extends React__default.Component {
229
366
  const func = this.props.onAnimationFinish;
230
367
  typeof func === 'function' && func(e);
231
368
  }
232
- parsePX() {
233
- let s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0px';
234
- return parseFloat(s.replace(/r*px/i, ''));
369
+ getLoopAdditionalSlides() {
370
+ const slidersLength = this.getSlidersList().length;
371
+ if (!this.$el || !this.getNeedFixLoop() || slidersLength < ONE_ADDITIONAL_SLIDES_THRESHOLD) return 0;
372
+ if (slidersLength <= TWO_ADDITIONAL_SLIDES_THRESHOLD) return 1;
373
+ return 2;
374
+ }
375
+ getCurrentId(swiper) {
376
+ const slides = swiper.slides;
377
+ const activeIndex = swiper.activeIndex;
378
+ const currentSlide = slides[activeIndex];
379
+ return currentSlide.getAttribute('item-id');
235
380
  }
236
381
  render() {
237
382
  const {
238
383
  className,
239
384
  style,
240
385
  vertical,
241
- previousMargin,
242
- nextMargin,
243
386
  indicatorColor,
244
387
  indicatorActiveColor,
245
388
  forwardedRef
@@ -248,12 +391,13 @@ class SwiperInner extends React__default.Component {
248
391
  const defaultIndicatorActiveColor = indicatorActiveColor || '#000';
249
392
  const cls = classNames(`taro-swiper-${this._id}`, className);
250
393
  const sty = Object.assign({
251
- paddingTop: vertical ? this.parsePX(previousMargin) : 0,
252
- paddingRight: vertical ? 0 : this.parsePX(nextMargin),
253
- paddingBottom: vertical ? this.parsePX(nextMargin) : 0,
254
- paddingLeft: vertical ? 0 : this.parsePX(previousMargin),
255
394
  overflow: 'hidden'
256
395
  }, style);
396
+ if (this.props.full) {
397
+ sty.height = '100%';
398
+ }
399
+ const [pM, nM] = this.parseMargin();
400
+ const swiperContainerStyleList = ['overflow: visible;', vertical ? `margin-top: ${pM}px; margin-bottom: ${nM}px;` : `margin-right: ${nM}px; margin-left: ${pM}px;`, this.props.full ? 'height: 100%;' : ''];
257
401
  const paginationCls = classNames('swiper-pagination', {
258
402
  'swiper-pagination-hidden': !this.props.indicatorDots,
259
403
  'swiper-pagination-bullets': this.props.indicatorDots
@@ -279,6 +423,7 @@ class SwiperInner extends React__default.Component {
279
423
  __html: `<style type='text/css'>
280
424
  .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ${defaultIndicatorColor} }
281
425
  .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ${defaultIndicatorActiveColor} }
426
+ .taro-swiper-${this._id} > .swiper-container { ${swiperContainerStyleList.join('')} }
282
427
  </style>`
283
428
  }
284
429
  }), /*#__PURE__*/jsx("div", {
@@ -291,6 +436,7 @@ class SwiperInner extends React__default.Component {
291
436
  });
292
437
  }
293
438
  }
439
+ _SwiperInner_source = new WeakMap(), _SwiperInner_swiperResetting = new WeakMap(), _SwiperInner_lastSwiperActiveIndex = new WeakMap(), _SwiperInner_domChangeByOutSide = new WeakMap();
294
440
  const Swiper = createForwardRefComponent(SwiperInner);
295
441
  const SwiperItem = createForwardRefComponent(SwiperItemInner);
296
442