@tarojs/components 3.3.17 → 3.3.18

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.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-7464647f.js');
6
6
  const index$1 = require('./index-cde74e58.js');
7
7
 
8
- const indexCss = "img[src=\"\"]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;font-size:0;width:320px;height:240px}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{width:100%;position:absolute;bottom:0}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;height:100%;right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}";
8
+ const indexCss = "img[src=\"\"]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;font-size:0;width:auto;height:auto}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{width:100%;position:absolute;bottom:0}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;height:100%;right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}";
9
9
 
10
10
  Promise.resolve().then(function () { return require('./intersection-observer-dc4cfcef.js'); });
11
11
  let Image = class {
@@ -44,7 +44,7 @@ let Image = class {
44
44
  this.onError.emit();
45
45
  }
46
46
  render() {
47
- const { src, mode, lazyLoad, aspectFillMode, imageOnLoad, imageOnError, nativeProps } = this;
47
+ const { src, mode = 'scaleToFill', lazyLoad = false, aspectFillMode = 'width', imageOnLoad, imageOnError, nativeProps } = this;
48
48
  const cls = index$1.classnames({
49
49
  'taro-img__widthfix': mode === 'widthFix'
50
50
  });
@@ -9943,6 +9943,11 @@ let Swiper = class {
9943
9943
  this.swiper.loopCreate();
9944
9944
  }
9945
9945
  }, 500);
9946
+ this.handleSwiperSize = debounce(() => {
9947
+ if (this.swiper && !this.circular) {
9948
+ this.swiper.updateSlides();
9949
+ }
9950
+ }, 50);
9946
9951
  }
9947
9952
  watchCurrent(newVal) {
9948
9953
  if (!this.isWillLoadCalled)
@@ -10006,6 +10011,8 @@ let Swiper = class {
10006
10011
  this.el.removeChild = (oldChild) => {
10007
10012
  return newVal.removeChild(oldChild);
10008
10013
  };
10014
+ this.el.addEventListener('DOMNodeInserted', this.handleSwiperSize);
10015
+ this.el.addEventListener('DOMNodeRemoved', this.handleSwiperSize);
10009
10016
  }
10010
10017
  watchCircular() {
10011
10018
  if (this.swiper) {
@@ -10039,6 +10046,8 @@ let Swiper = class {
10039
10046
  }
10040
10047
  disconnectedCallback() {
10041
10048
  var _a, _b, _c, _d, _e, _f;
10049
+ this.el.removeEventListener('DOMNodeInserted', this.handleSwiperSize);
10050
+ this.el.removeEventListener('DOMNodeRemoved', this.handleSwiperSize);
10042
10051
  (_b = (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
10043
10052
  (_d = (_c = this.observerFirst) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
10044
10053
  (_f = (_e = this.observerLast) === null || _e === void 0 ? void 0 : _e.disconnect) === null || _f === void 0 ? void 0 : _f.call(_e);
@@ -10082,7 +10091,7 @@ let Swiper = class {
10082
10091
  observerUpdate(_swiper, e) {
10083
10092
  const target = e.target;
10084
10093
  const className = target && typeof target.className === 'string' ? target.className : '';
10085
- if (className.includes('taro_page') && target.style.display === 'block') {
10094
+ if (className.includes('taro_page') && target.style.display !== 'none') {
10086
10095
  if (that.autoplay && target.contains(_swiper.$el[0])) {
10087
10096
  _swiper.slideTo(that.current);
10088
10097
  }
@@ -34,7 +34,7 @@ export class Image {
34
34
  this.onError.emit();
35
35
  }
36
36
  render() {
37
- const { src, mode, lazyLoad, aspectFillMode, imageOnLoad, imageOnError, nativeProps } = this;
37
+ const { src, mode = 'scaleToFill', lazyLoad = false, aspectFillMode = 'width', imageOnLoad, imageOnError, nativeProps } = this;
38
38
  const cls = classNames({
39
39
  'taro-img__widthfix': mode === 'widthFix'
40
40
  });
@@ -7,8 +7,8 @@ taro-image-core {
7
7
  overflow: hidden;
8
8
  position: relative;
9
9
  font-size: 0;
10
- width: 320px;
11
- height: 240px;
10
+ width: auto;
11
+ height: auto;
12
12
  }
13
13
 
14
14
  .taro-img.taro-img__widthfix {
@@ -86,6 +86,11 @@ export class Swiper {
86
86
  this.swiper.loopCreate();
87
87
  }
88
88
  }, 500);
89
+ this.handleSwiperSize = debounce(() => {
90
+ if (this.swiper && !this.circular) {
91
+ this.swiper.updateSlides();
92
+ }
93
+ }, 50);
89
94
  }
90
95
  watchCurrent(newVal) {
91
96
  if (!this.isWillLoadCalled)
@@ -149,6 +154,8 @@ export class Swiper {
149
154
  this.el.removeChild = (oldChild) => {
150
155
  return newVal.removeChild(oldChild);
151
156
  };
157
+ this.el.addEventListener('DOMNodeInserted', this.handleSwiperSize);
158
+ this.el.addEventListener('DOMNodeRemoved', this.handleSwiperSize);
152
159
  }
153
160
  watchCircular() {
154
161
  if (this.swiper) {
@@ -182,6 +189,8 @@ export class Swiper {
182
189
  }
183
190
  disconnectedCallback() {
184
191
  var _a, _b, _c, _d, _e, _f;
192
+ this.el.removeEventListener('DOMNodeInserted', this.handleSwiperSize);
193
+ this.el.removeEventListener('DOMNodeRemoved', this.handleSwiperSize);
185
194
  (_b = (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
186
195
  (_d = (_c = this.observerFirst) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
187
196
  (_f = (_e = this.observerLast) === null || _e === void 0 ? void 0 : _e.disconnect) === null || _f === void 0 ? void 0 : _f.call(_e);
@@ -225,7 +234,7 @@ export class Swiper {
225
234
  observerUpdate(_swiper, e) {
226
235
  const target = e.target;
227
236
  const className = target && typeof target.className === 'string' ? target.className : '';
228
- if (className.includes('taro_page') && target.style.display === 'block') {
237
+ if (className.includes('taro_page') && target.style.display !== 'none') {
229
238
  if (that.autoplay && target.contains(_swiper.$el[0])) {
230
239
  _swiper.slideTo(that.current);
231
240
  }
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-165a6222.js';
2
2
  import { c as classnames } from './index-85e10859.js';
3
3
 
4
- const indexCss = "img[src=\"\"]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;font-size:0;width:320px;height:240px}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{width:100%;position:absolute;bottom:0}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;height:100%;right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}";
4
+ const indexCss = "img[src=\"\"]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;font-size:0;width:auto;height:auto}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{width:100%;position:absolute;bottom:0}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;height:100%;right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}";
5
5
 
6
6
  import('./intersection-observer-8e4c7135.js');
7
7
  let Image = class {
@@ -40,7 +40,7 @@ let Image = class {
40
40
  this.onError.emit();
41
41
  }
42
42
  render() {
43
- const { src, mode, lazyLoad, aspectFillMode, imageOnLoad, imageOnError, nativeProps } = this;
43
+ const { src, mode = 'scaleToFill', lazyLoad = false, aspectFillMode = 'width', imageOnLoad, imageOnError, nativeProps } = this;
44
44
  const cls = classnames({
45
45
  'taro-img__widthfix': mode === 'widthFix'
46
46
  });
@@ -9939,6 +9939,11 @@ let Swiper = class {
9939
9939
  this.swiper.loopCreate();
9940
9940
  }
9941
9941
  }, 500);
9942
+ this.handleSwiperSize = debounce(() => {
9943
+ if (this.swiper && !this.circular) {
9944
+ this.swiper.updateSlides();
9945
+ }
9946
+ }, 50);
9942
9947
  }
9943
9948
  watchCurrent(newVal) {
9944
9949
  if (!this.isWillLoadCalled)
@@ -10002,6 +10007,8 @@ let Swiper = class {
10002
10007
  this.el.removeChild = (oldChild) => {
10003
10008
  return newVal.removeChild(oldChild);
10004
10009
  };
10010
+ this.el.addEventListener('DOMNodeInserted', this.handleSwiperSize);
10011
+ this.el.addEventListener('DOMNodeRemoved', this.handleSwiperSize);
10005
10012
  }
10006
10013
  watchCircular() {
10007
10014
  if (this.swiper) {
@@ -10035,6 +10042,8 @@ let Swiper = class {
10035
10042
  }
10036
10043
  disconnectedCallback() {
10037
10044
  var _a, _b, _c, _d, _e, _f;
10045
+ this.el.removeEventListener('DOMNodeInserted', this.handleSwiperSize);
10046
+ this.el.removeEventListener('DOMNodeRemoved', this.handleSwiperSize);
10038
10047
  (_b = (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
10039
10048
  (_d = (_c = this.observerFirst) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
10040
10049
  (_f = (_e = this.observerLast) === null || _e === void 0 ? void 0 : _e.disconnect) === null || _f === void 0 ? void 0 : _f.call(_e);
@@ -10078,7 +10087,7 @@ let Swiper = class {
10078
10087
  observerUpdate(_swiper, e) {
10079
10088
  const target = e.target;
10080
10089
  const className = target && typeof target.className === 'string' ? target.className : '';
10081
- if (className.includes('taro_page') && target.style.display === 'block') {
10090
+ if (className.includes('taro_page') && target.style.display !== 'none') {
10082
10091
  if (that.autoplay && target.contains(_swiper.$el[0])) {
10083
10092
  _swiper.slideTo(that.current);
10084
10093
  }
@@ -1 +1 @@
1
- import{r as registerInstance,c as createEvent,h,H as Host}from"./index-165a6222.js";import{c as classnames}from"./index-85e10859.js";var indexCss='img[src=""]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;font-size:0;width:320px;height:240px}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{width:100%;position:absolute;bottom:0}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;height:100%;right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}';import("./intersection-observer-8e4c7135.js");var Image=function(){function t(t){registerInstance(this,t);this.onLoad=createEvent(this,"load",7);this.onError=createEvent(this,"error",7);this.mode="scaleToFill";this.lazyLoad=false;this.nativeProps={};this.aspectFillMode="width"}t.prototype.componentDidLoad=function(){var t=this;if(!this.lazyLoad)return;var i=new IntersectionObserver((function(o){if(o[o.length-1].isIntersecting){i.unobserve(t.imgRef);t.imgRef.src=t.src}}),{rootMargin:"300px 0px"});i.observe(this.imgRef)};t.prototype.imageOnLoad=function(){var t=this.imgRef,i=t.width,o=t.height,e=t.naturalWidth,r=t.naturalHeight;this.onLoad.emit({width:i,height:o});this.aspectFillMode=e>r?"width":"height"};t.prototype.imageOnError=function(){this.onError.emit()};t.prototype.render=function(){var t;var i=this;var o=this,e=o.src,r=o.mode,a=o.lazyLoad,s=o.aspectFillMode,n=o.imageOnLoad,m=o.imageOnError,g=o.nativeProps;var d=classnames({"taro-img__widthfix":r==="widthFix"});var l=classnames("taro-img__mode-"+r.toLowerCase().replace(/\s/g,""),(t={},t["taro-img__mode-aspectfill--"+s]=r==="aspectFill",t));return h(Host,{class:d},a?h("img",Object.assign({ref:function(t){return i.imgRef=t},class:l,onLoad:n.bind(this),onError:m.bind(this)},g)):h("img",Object.assign({ref:function(t){return i.imgRef=t},class:l,src:e,onLoad:n.bind(this),onError:m.bind(this)},g)))};return t}();Image.style=indexCss;export{Image as taro_image_core};
1
+ import{r as registerInstance,c as createEvent,h,H as Host}from"./index-165a6222.js";import{c as classnames}from"./index-85e10859.js";var indexCss='img[src=""]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;font-size:0;width:auto;height:auto}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{width:100%;position:absolute;bottom:0}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;height:100%;right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}';import("./intersection-observer-8e4c7135.js");var Image=function(){function t(t){registerInstance(this,t);this.onLoad=createEvent(this,"load",7);this.onError=createEvent(this,"error",7);this.mode="scaleToFill";this.lazyLoad=false;this.nativeProps={};this.aspectFillMode="width"}t.prototype.componentDidLoad=function(){var t=this;if(!this.lazyLoad)return;var i=new IntersectionObserver((function(o){if(o[o.length-1].isIntersecting){i.unobserve(t.imgRef);t.imgRef.src=t.src}}),{rootMargin:"300px 0px"});i.observe(this.imgRef)};t.prototype.imageOnLoad=function(){var t=this.imgRef,i=t.width,o=t.height,e=t.naturalWidth,r=t.naturalHeight;this.onLoad.emit({width:i,height:o});this.aspectFillMode=e>r?"width":"height"};t.prototype.imageOnError=function(){this.onError.emit()};t.prototype.render=function(){var t;var i=this;var o=this,e=o.src,r=o.mode,a=r===void 0?"scaleToFill":r,s=o.lazyLoad,n=s===void 0?false:s,m=o.aspectFillMode,d=m===void 0?"width":m,g=o.imageOnLoad,l=o.imageOnError,c=o.nativeProps;var f=classnames({"taro-img__widthfix":a==="widthFix"});var p=classnames("taro-img__mode-"+a.toLowerCase().replace(/\s/g,""),(t={},t["taro-img__mode-aspectfill--"+d]=a==="aspectFill",t));return h(Host,{class:f},n?h("img",Object.assign({ref:function(t){return i.imgRef=t},class:p,onLoad:g.bind(this),onError:l.bind(this)},c)):h("img",Object.assign({ref:function(t){return i.imgRef=t},class:p,src:e,onLoad:g.bind(this),onError:l.bind(this)},c)))};return t}();Image.style=indexCss;export{Image as taro_image_core};