@tarojs/components-react 4.0.4 → 4.0.5-alpha.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.
@@ -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,314 @@ 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
+ that.props.autoplay && _swiper.autoplay.pause();
138
+ },
139
+ slideChange(_swiper) {
140
+ if (__classPrivateFieldGet(that, _SwiperInner_swiperResetting, "f") || __classPrivateFieldGet(that, _SwiperInner_lastSwiperActiveIndex, "f") === _swiper.realIndex) return;
141
+ __classPrivateFieldSet(that, _SwiperInner_lastSwiperActiveIndex, _swiper.realIndex, "f");
142
+ const e = createEvent('touchend');
143
+ try {
144
+ const currentId = that.getCurrentId(_swiper);
145
+ Object.defineProperty(e, 'detail', {
146
+ enumerable: true,
147
+ value: {
148
+ current: this.realIndex,
149
+ source: __classPrivateFieldGet(that, _SwiperInner_source, "f"),
150
+ currentId
151
+ }
152
+ });
153
+ } catch (err) {} // eslint-disable-line no-empty
154
+ that.handleOnChange(e);
155
+ },
156
+ autoplay(_swiper) {
157
+ // Note: 修复 autoplay 时,切换到其他页面再切回来,autoplay 会停止的问题
158
+ _swiper.animating = false;
159
+ __classPrivateFieldSet(that, _SwiperInner_source, 'autoplay', "f");
160
+ }
161
+ }
162
+ });
163
+ // 自动播放
164
+ if (autoplay) {
165
+ opt.autoplay = {
166
+ delay: parseInt(String(interval), 10),
167
+ disableOnInteraction: false
168
+ };
169
+ }
170
+ _this.swiper = new Swipers(_this.$el, opt);
171
+ if (_this.getNeedFixLoop()) {
74
172
  // @ts-ignore
75
- this.mySwiper.loopDestroy();
173
+ const minTranslate = _this.swiper.minTranslate.bind(_this.swiper);
76
174
  // @ts-ignore
77
- this.mySwiper.loopCreate();
175
+ const maxTranslate = _this.swiper.maxTranslate.bind(_this.swiper);
176
+ if (centeredSlides && _this.getSlidersList().length < 4) {
177
+ // @ts-ignore
178
+ _this.swiper.minTranslate = () => minTranslate() + _this.parseMargin()[1];
179
+ // @ts-ignore
180
+ _this.swiper.maxTranslate = () => maxTranslate() - _this.parseMargin()[0];
181
+ } else {
182
+ // @ts-ignore
183
+ _this.swiper.minTranslate = () => minTranslate() - _this.parseMargin()[0];
184
+ // @ts-ignore
185
+ _this.swiper.maxTranslate = () => maxTranslate() + _this.parseMargin()[1];
186
+ }
187
+ }
188
+ _this.setState({
189
+ swiperWrapper: _this.swiper.wrapperEl
190
+ });
191
+ };
192
+ this.handleSwiperSizeDebounce = debounce(() => {
193
+ if (!this.swiper) return;
194
+ if (this.props.circular) {
195
+ if (__classPrivateFieldGet(this, _SwiperInner_domChangeByOutSide, "f")) {
196
+ this.reset();
197
+ __classPrivateFieldSet(this, _SwiperInner_domChangeByOutSide, false, "f");
198
+ }
199
+ } else {
200
+ this.swiper.update();
201
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, false, "f");
78
202
  }
79
- }, 500);
203
+ }, 50);
204
+ this.reset = () => {
205
+ if (!this.swiper) return;
206
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, true, "f");
207
+ __classPrivateFieldSet(this, _SwiperInner_lastSwiperActiveIndex, this.swiper.realIndex, "f");
208
+ this.swiper.destroy();
209
+ this.handleInit(true);
210
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, false, "f");
211
+ };
212
+ this.getSlidersList = () => {
213
+ var _a, _b;
214
+ return ((_b = (_a = this.$el) === null || _a === void 0 ? void 0 : _a.querySelectorAll) === null || _b === void 0 ? void 0 : _b.call(_a, '.swiper-slide')) || [];
215
+ };
216
+ this.getNeedFixLoop = () => {
217
+ const margins = this.parseMargin();
218
+ const hasMargin = margins.filter(Boolean).length > 0;
219
+ return this.props.circular && hasMargin;
220
+ };
221
+ this.parseMargin = () => {
222
+ const {
223
+ previousMargin = '0px',
224
+ nextMargin = '0px'
225
+ } = this.props;
226
+ const [, pM] = /^(\d+)px/.exec(previousMargin) || [];
227
+ const [, nN] = /^(\d+)px/.exec(nextMargin) || [];
228
+ return [parseInt(pM) || 0, parseInt(nN) || 0];
229
+ };
230
+ this.state = {
231
+ swiperWrapper: null
232
+ };
80
233
  }
81
234
  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
- }
235
+ this.handleInit();
236
+ }
237
+ hackSwiperWrapDomAction() {
238
+ if (!this.state.swiperWrapper || !this.swiper) return;
239
+ const appendChild = this.state.swiperWrapper.appendChild.bind(this.state.swiperWrapper);
240
+ const removeChild = this.state.swiperWrapper.removeChild.bind(this.state.swiperWrapper);
241
+ const replaceChild = this.state.swiperWrapper.replaceChild.bind(this.state.swiperWrapper);
242
+ const insertBefore = this.state.swiperWrapper.insertBefore.bind(this.state.swiperWrapper);
243
+ const beforeAction = () => {
244
+ if (!this.state.swiperWrapper || !this.swiper) return;
245
+ __classPrivateFieldSet(this, _SwiperInner_swiperResetting, true, "f");
246
+ if (!__classPrivateFieldGet(this, _SwiperInner_domChangeByOutSide, "f") && this.props.circular) {
247
+ __classPrivateFieldSet(this, _SwiperInner_domChangeByOutSide, true, "f");
248
+ this.swiper.loopDestroy();
249
+ this.swiper.params.loop = false;
150
250
  }
151
251
  };
152
- // 自动播放
153
- if (autoplay) {
154
- opt.autoplay = {
155
- delay: parseInt(String(interval), 10),
156
- disableOnInteraction: false
157
- };
252
+ // eslint-disable-next-line react/no-direct-mutation-state
253
+ this.state.swiperWrapper.appendChild = function () {
254
+ beforeAction();
255
+ return appendChild(...arguments);
256
+ };
257
+ // eslint-disable-next-line react/no-direct-mutation-state
258
+ this.state.swiperWrapper.removeChild = function () {
259
+ beforeAction();
260
+ return removeChild(...arguments);
261
+ };
262
+ // eslint-disable-next-line react/no-direct-mutation-state
263
+ this.state.swiperWrapper.replaceChild = function () {
264
+ beforeAction();
265
+ return replaceChild(...arguments);
266
+ };
267
+ // eslint-disable-next-line react/no-direct-mutation-state
268
+ this.state.swiperWrapper.insertBefore = function () {
269
+ beforeAction();
270
+ return insertBefore(...arguments);
271
+ };
272
+ }
273
+ componentDidUpdate(prevProps, pervState) {
274
+ if (!this.swiper || !this.state.swiperWrapper) return;
275
+ if (pervState.swiperWrapper !== this.state.swiperWrapper && this.state.swiperWrapper) {
276
+ this.observer && this.observer.disconnect();
277
+ this.observer = new MutationObserver(this.handleSwiperSizeDebounce);
278
+ this.observer.observe(this.state.swiperWrapper, {
279
+ childList: true
280
+ });
281
+ this.hackSwiperWrapDomAction();
158
282
  }
159
- // 两端距离
160
- if (spaceBetween) {
161
- opt.spaceBetween = spaceBetween;
283
+ if (prevProps.circular !== this.props.circular || prevProps.displayMultipleItems !== this.props.displayMultipleItems) {
284
+ this.reset();
162
285
  }
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
- }
286
+ if (prevProps.interval !== this.props.interval) {
287
+ if (typeof this.swiper.params.autoplay === 'object') {
288
+ this.swiper.params.autoplay.delay = this.props.interval;
289
+ }
290
+ }
291
+ if (prevProps.duration !== this.props.duration) {
292
+ this.swiper.params.speed = this.props.duration;
293
+ }
294
+ if (prevProps.current !== this.props.current && !this.props.currentItemId) {
295
+ const n = parseInt(String(this.props.current), 10);
296
+ if (isNaN(n) || n === this.swiper.realIndex) return;
297
+ __classPrivateFieldSet(this, _SwiperInner_source, '', "f");
298
+ if (this.props.circular) {
299
+ this.swiper.slideToLoop(n); // 更新下标
300
+ this.props.autoplay && this.swiper.autoplay.pause();
301
+ // @ts-ignore
302
+ this.swiper.loopFix();
303
+ this.props.autoplay && this.swiper.autoplay.start();
183
304
  } else {
184
- this.mySwiper.slideTo(parseInt(nextCurrent, 10) + 1); // 更新下标
305
+ this.swiper.slideTo(n); // 更新下标
185
306
  }
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);
307
+ }
308
+ if (prevProps.autoplay !== this.props.autoplay) {
309
+ const swiperAutoplay = this.swiper.autoplay;
310
+ if (swiperAutoplay) {
311
+ if (swiperAutoplay.running === this.props.autoplay) return;
312
+ if (this.props.autoplay) {
313
+ if (this.swiper.params && typeof this.swiper.params.autoplay === 'object') {
314
+ if (this.swiper.params.autoplay.disableOnInteraction === true) {
315
+ this.swiper.params.autoplay.disableOnInteraction = false;
316
+ }
317
+ this.swiper.params.autoplay.delay = this.props.interval;
193
318
  }
194
- autoplay.start();
319
+ swiperAutoplay.start();
195
320
  } else {
196
- autoplay.stop();
321
+ swiperAutoplay.stop();
197
322
  }
198
323
  }
199
- this.mySwiper.update(); // 更新子元素
200
324
  }
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();
325
+ if (prevProps.currentItemId !== this.props.currentItemId) {
326
+ let itemIdIndex = 0;
327
+ this.getSlidersList().forEach((swiperItem, index) => {
328
+ const itemId = swiperItem.getAttribute('item-id');
329
+ // @ts-ignore
330
+ if (itemId === this.props.currentItemId) {
331
+ if (this.props.circular) {
332
+ itemIdIndex = Number(swiperItem.getAttribute('data-swiper-slide-index'));
333
+ } else {
334
+ itemIdIndex = index;
335
+ }
336
+ }
337
+ });
338
+ if (isNaN(itemIdIndex) || itemIdIndex === this.swiper.realIndex) return;
339
+ __classPrivateFieldSet(this, _SwiperInner_source, '', "f");
340
+ if (this.props.circular) {
341
+ this.swiper.slideToLoop(itemIdIndex); // 更新下标
342
+ this.props.autoplay && this.swiper.autoplay.pause();
343
+ // @ts-ignore
344
+ this.swiper.loopFix();
345
+ this.props.autoplay && this.swiper.autoplay.start();
346
+ } else {
347
+ this.swiper.slideTo(itemIdIndex); // 更新下标
211
348
  }
212
349
  }
213
- this._$width = this.mySwiper.width;
214
- this._$height = this.mySwiper.height;
215
350
  }
216
351
  componentWillUnmount() {
217
- var _a, _b, _c, _d, _e, _f;
352
+ var _a, _b, _c, _d;
218
353
  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);
354
+ (_b = (_a = this.swiper) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
355
+ (_d = (_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
356
+ this.setState({
357
+ swiperWrapper: null
358
+ });
223
359
  }
224
360
  handleOnChange(e) {
225
361
  const func = this.props.onChange;
@@ -229,17 +365,23 @@ class SwiperInner extends React__default.Component {
229
365
  const func = this.props.onAnimationFinish;
230
366
  typeof func === 'function' && func(e);
231
367
  }
232
- parsePX() {
233
- let s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0px';
234
- return parseFloat(s.replace(/r*px/i, ''));
368
+ getLoopAdditionalSlides() {
369
+ const slidersLength = this.getSlidersList().length;
370
+ if (!this.$el || !this.getNeedFixLoop() || slidersLength < ONE_ADDITIONAL_SLIDES_THRESHOLD) return 0;
371
+ if (slidersLength <= TWO_ADDITIONAL_SLIDES_THRESHOLD) return 1;
372
+ return 2;
373
+ }
374
+ getCurrentId(swiper) {
375
+ const slides = swiper.slides;
376
+ const activeIndex = swiper.activeIndex;
377
+ const currentSlide = slides[activeIndex];
378
+ return currentSlide.getAttribute('item-id');
235
379
  }
236
380
  render() {
237
381
  const {
238
382
  className,
239
383
  style,
240
384
  vertical,
241
- previousMargin,
242
- nextMargin,
243
385
  indicatorColor,
244
386
  indicatorActiveColor,
245
387
  forwardedRef
@@ -248,12 +390,13 @@ class SwiperInner extends React__default.Component {
248
390
  const defaultIndicatorActiveColor = indicatorActiveColor || '#000';
249
391
  const cls = classNames(`taro-swiper-${this._id}`, className);
250
392
  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
393
  overflow: 'hidden'
256
394
  }, style);
395
+ if (this.props.full) {
396
+ sty.height = '100%';
397
+ }
398
+ const [pM, nM] = this.parseMargin();
399
+ 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
400
  const paginationCls = classNames('swiper-pagination', {
258
401
  'swiper-pagination-hidden': !this.props.indicatorDots,
259
402
  'swiper-pagination-bullets': this.props.indicatorDots
@@ -279,6 +422,7 @@ class SwiperInner extends React__default.Component {
279
422
  __html: `<style type='text/css'>
280
423
  .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ${defaultIndicatorColor} }
281
424
  .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ${defaultIndicatorActiveColor} }
425
+ .taro-swiper-${this._id} > .swiper-container { ${swiperContainerStyleList.join('')} }
282
426
  </style>`
283
427
  }
284
428
  }), /*#__PURE__*/jsx("div", {
@@ -291,6 +435,7 @@ class SwiperInner extends React__default.Component {
291
435
  });
292
436
  }
293
437
  }
438
+ _SwiperInner_source = new WeakMap(), _SwiperInner_swiperResetting = new WeakMap(), _SwiperInner_lastSwiperActiveIndex = new WeakMap(), _SwiperInner_domChangeByOutSide = new WeakMap();
294
439
  const Swiper = createForwardRefComponent(SwiperInner);
295
440
  const SwiperItem = createForwardRefComponent(SwiperItemInner);
296
441