index-legacy.9d5cae73.js 8.1 KB

1
  1. !function(){function t(t,a){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var i,n,r=[],o=!0,c=!1;try{for(a=a.call(t);!(o=(i=a.next()).done)&&(r.push(i.value),!e||r.length!==e);o=!0);}catch(l){c=!0,n=l}finally{try{o||null==a.return||a.return()}finally{if(c)throw n}}return r}(t,a)||function(t,a){if(!t)return;if("string"==typeof t)return e(t,a);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return e(t,a)}(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=new Array(e);a<e;a++)i[a]=t[a];return i}var a=document.createElement("style");a.innerHTML=":root{--van-swipe-indicator-size: .16rem;--van-swipe-indicator-margin: var(--van-padding-sm);--van-swipe-indicator-active-opacity: 1;--van-swipe-indicator-inactive-opacity: .3;--van-swipe-indicator-active-background-color: var(--van-primary-color);--van-swipe-indicator-inactive-background-color: var(--van-border-color)}.van-swipe{position:relative;overflow:hidden;transform:translateZ(0);cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.van-swipe__track{display:flex;height:100%}.van-swipe__track--vertical{flex-direction:column}.van-swipe__indicators{position:absolute;bottom:var(--van-swipe-indicator-margin);left:50%;display:flex;transform:translate(-50%)}.van-swipe__indicators--vertical{top:50%;bottom:auto;left:var(--van-swipe-indicator-margin);flex-direction:column;transform:translateY(-50%)}.van-swipe__indicators--vertical .van-swipe__indicator:not(:last-child){margin-bottom:var(--van-swipe-indicator-size)}.van-swipe__indicator{width:var(--van-swipe-indicator-size);height:var(--van-swipe-indicator-size);background-color:var(--van-swipe-indicator-inactive-background-color);border-radius:100%;opacity:var(--van-swipe-indicator-inactive-opacity);transition:opacity var(--van-animation-duration-fast),background-color var(--van-animation-duration-fast)}.van-swipe__indicator:not(:last-child){margin-right:var(--van-swipe-indicator-size)}.van-swipe__indicator--active{background-color:var(--van-swipe-indicator-active-background-color);opacity:var(--van-swipe-indicator-active-opacity)}.van-swipe-item{position:relative;flex-shrink:0;width:100%;height:100%}\n",document.head.appendChild(a),System.register(["./ResizeObserver.es-legacy.44b91b4c.js"],(function(e){"use strict";var a,i,n,r,o,c,l,u,v,s,f,d,p,h,w,g,m,y,b,_,k,S,x,z,C,M,T,I;return{setters:[function(t){a=t.E,i=t.H,n=t.G,r=t.ab,o=t.d,c=t.U,l=t.S,u=t.ai,v=t.aj,s=t.W,f=t.ak,d=t.a3,p=t.al,h=t.am,w=t.an,g=t.V,m=t.ao,y=t.ap,b=t.a9,_=t.a5,k=t.j,S=t.ag,x=t.X,z=t.aq,C=t.ar,M=t.as,T=t.O,I=t.at}],execute:function(){var O=t(a("swipe"),2),A=O[0],j=O[1],X={loop:i,width:n,height:n,vertical:Boolean,autoplay:r(0),duration:r(500),touchable:i,lazyRender:Boolean,initialSwipe:r(0),indicatorColor:String,showIndicators:i,stopPropagation:i},Y=Symbol(A),E=o({name:A,props:X,emits:["change"],setup:function(t,e){var a,i,n=e.emit,r=e.slots,o=c(),T=l({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),I=u(),O=v(Y),A=O.children,X=O.linkChildren,E=s((function(){return A.length})),D=s((function(){return T[t.vertical?"height":"width"]})),H=s((function(){return t.vertical?I.deltaY.value:I.deltaX.value})),R=s((function(){return T.rect?(t.vertical?T.rect.height:T.rect.width)-D.value*E.value:0})),B=s((function(){return Math.ceil(Math.abs(R.value)/D.value)})),P=s((function(){return E.value*D.value})),U=s((function(){return(T.active+E.value)%E.value})),V=s((function(){var e=t.vertical?"vertical":"horizontal";return I.direction.value===e})),W=s((function(){var e={transitionDuration:"".concat(T.swiping?0:t.duration,"ms"),transform:"translate".concat(t.vertical?"Y":"X","(").concat(T.offset,"px)")};if(D.value){var a=t.vertical?"height":"width",i=t.vertical?"width":"height";e[a]="".concat(P.value,"px"),e[i]=t[i]?"".concat(t[i],"px"):""}return e})),q=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e*D.value;t.loop||(i=Math.min(i,-R.value));var n=a-i;return t.loop||(n=M(n,R.value,0)),n},G=function(e){var a=e.pace,i=void 0===a?0:a,r=e.offset,o=void 0===r?0:r,c=e.emitChange;if(!(E.value<=1)){var l=T.active,u=function(e){var a=T.active;return e?t.loop?M(a+e,-1,E.value):M(a+e,0,B.value):a}(i),v=q(u,o);if(t.loop){if(A[0]&&v!==R.value){var s=v<R.value;A[0].setOffset(s?P.value:0)}if(A[E.value-1]&&0!==v){var f=v>0;A[E.value-1].setOffset(f?-P.value:0)}}T.active=u,T.offset=v,c&&u!==l&&n("change",U.value)}},L=function(){T.swiping=!0,T.active<=-1?G({pace:E.value}):T.active>=E.value&&G({pace:-E.value})},Z=function(){L(),I.reset(),C((function(){T.swiping=!1,G({pace:1,emitChange:!0})}))},$=function(){return clearTimeout(a)},F=function e(){$(),t.autoplay>0&&E.value>1&&(a=setTimeout((function(){Z(),e()}),+t.autoplay))},J=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:+t.initialSwipe;if(o.value){var a=function(){var a,i;if(!S(o)){var n={width:o.value.offsetWidth,height:o.value.offsetHeight};T.rect=n,T.width=+(null!=(a=t.width)?a:n.width),T.height=+(null!=(i=t.height)?i:n.height)}E.value&&(e=Math.min(E.value-1,e)),T.active=e,T.swiping=!0,T.offset=q(e),A.forEach((function(t){t.setOffset(0)})),F()};S(o)?x().then(a):a()}},K=function(){return J(T.active)},N=function(e){t.touchable&&(I.start(e),i=Date.now(),$(),L())},Q=function(e){t.touchable&&T.swiping&&(I.move(e),V.value&&(z(e,t.stopPropagation),G({offset:H.value})))},tt=function(){if(t.touchable&&T.swiping){var e=Date.now()-i,a=H.value/e;if((Math.abs(a)>.25||Math.abs(H.value)>D.value/2)&&V.value){var n=t.vertical?I.offsetY.value:I.offsetX.value,r=0;r=t.loop?n>0?H.value>0?-1:1:0:-Math[H.value>0?"ceil":"floor"](H.value/D.value),G({pace:r,emitChange:!0})}else H.value&&G({pace:0});T.swiping=!1,F()}},et=function(e,a){var i=a===U.value,n=i?{backgroundColor:t.indicatorColor}:void 0;return k("i",{style:n,class:j("indicator",{active:i})},null)};return f({prev:function(){L(),I.reset(),C((function(){T.swiping=!1,G({pace:-1,emitChange:!0})}))},next:Z,state:T,resize:K,swipeTo:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};L(),I.reset(),C((function(){var i;i=t.loop&&e===E.value?0===T.active?0:e:e%E.value,a.immediate?C((function(){T.swiping=!1})):T.swiping=!1,G({pace:i-T.active,emitChange:!0})}))}}),X({size:D,props:t,count:E,activeIndicator:U}),d((function(){return t.initialSwipe}),(function(t){return J(+t)})),d(E,(function(){return J(T.active)})),d((function(){return t.autoplay}),F),d([p,h],K),d(w(),(function(t){"visible"===t?F():$()})),g(J),m((function(){return J(T.active)})),y((function(){return J(T.active)})),b($),_($),function(){var e;return k("div",{ref:o,class:j()},[k("div",{style:W.value,class:j("track",{vertical:t.vertical}),onTouchstart:N,onTouchmove:Q,onTouchend:tt,onTouchcancel:tt},[null==(e=r.default)?void 0:e.call(r)]),r.indicator?r.indicator({active:U.value,total:E.value}):t.showIndicators&&E.value>1?k("div",{class:j("indicators",{vertical:t.vertical})},[Array(E.value).fill("").map(et)]):void 0])}}}),D=(e("S",T(E)),t(a("swipe-item"),2)),H=D[0],R=D[1],B=o({name:H,setup:function(t,e){var a,i=e.slots,n=l({offset:0,inited:!1,mounted:!1}),r=I(Y),o=r.parent,c=r.index;if(o){var u=s((function(){var t={},e=o.props.vertical;return o.size.value&&(t[e?"height":"width"]="".concat(o.size.value,"px")),n.offset&&(t.transform="translate".concat(e?"Y":"X","(").concat(n.offset,"px)")),t})),v=s((function(){var t=o.props,e=t.loop;if(!t.lazyRender||a)return!0;if(!n.mounted)return!1;var i=o.activeIndicator.value,r=o.count.value-1,l=0===i&&e?r:i-1,u=i===r&&e?0:i+1;return a=c.value===i||c.value===l||c.value===u}));return g((function(){x((function(){n.mounted=!0}))})),f({setOffset:function(t){n.offset=t}}),function(){var t;return k("div",{class:R(),style:u.value},[v.value?null==(t=i.default)?void 0:t.call(i):null])}}console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.")}});e("a",T(B))}}}))}();