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(u){c=!0,n=u}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:-webkit-grab;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(["./index-legacy.b903c881.js"],(function(e){"use strict";var a,i,n,r,o,c,u,l,v,s,f,d,p,h,w,g,m,y,b,_,k,x,S,z,C,M,T,A;return{setters:[function(t){a=t.A,i=t.G,n=t.E,r=t.aa,o=t.d,c=t.S,u=t.Q,l=t.ah,v=t.ai,s=t.V,f=t.aj,d=t.a2,p=t.ak,h=t.al,w=t.am,g=t.U,m=t.an,y=t.ao,b=t.a8,_=t.a4,k=t.j,x=t.af,S=t.W,z=t.ap,C=t.aq,M=t.ar,T=t.N,A=t.as}],execute:function(){var I=t(a("swipe"),2),j=I[0],O=I[1],Y={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},E=Symbol(j),X=o({name:j,props:Y,emits:["change"],setup:function(t,e){var a,i,n=e.emit,r=e.slots,o=c(),T=u({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),A=l(),I=v(E),j=I.children,Y=I.linkChildren,X=s((function(){return j.length})),D=s((function(){return T[t.vertical?"height":"width"]})),B=s((function(){return t.vertical?A.deltaY.value:A.deltaX.value})),H=s((function(){return T.rect?(t.vertical?T.rect.height:T.rect.width)-D.value*X.value:0})),P=s((function(){return Math.ceil(Math.abs(H.value)/D.value)})),R=s((function(){return X.value*D.value})),U=s((function(){return(T.active+X.value)%X.value})),V=s((function(){var e=t.vertical?"vertical":"horizontal";return A.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(R.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,-H.value));var n=a-i;return t.loop||(n=M(n,H.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(!(X.value<=1)){var u=T.active,l=function(e){var a=T.active;return e?t.loop?M(a+e,-1,X.value):M(a+e,0,P.value):a}(i),v=q(l,o);if(t.loop){if(j[0]&&v!==H.value){var s=v<H.value;j[0].setOffset(s?R.value:0)}if(j[X.value-1]&&0!==v){var f=v>0;j[X.value-1].setOffset(f?-R.value:0)}}T.active=l,T.offset=v,c&&l!==u&&n("change",U.value)}},L=function(){T.swiping=!0,T.active<=-1?G({pace:X.value}):T.active>=X.value&&G({pace:-X.value})},N=function(){L(),A.reset(),C((function(){T.swiping=!1,G({pace:1,emitChange:!0})}))},Q=function(){return clearTimeout(a)},Z=function e(){Q(),t.autoplay>0&&X.value>1&&(a=setTimeout((function(){N(),e()}),+t.autoplay))},$=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:+t.initialSwipe;if(o.value){var a=function(){var a,i;if(!x(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)}X.value&&(e=Math.min(X.value-1,e)),T.active=e,T.swiping=!0,T.offset=q(e),j.forEach((function(t){t.setOffset(0)})),Z()};x(o)?S().then(a):a()}},F=function(){return $(T.active)},J=function(e){t.touchable&&(A.start(e),i=Date.now(),Q(),L())},K=function(e){t.touchable&&T.swiping&&(A.move(e),V.value&&(z(e,t.stopPropagation),G({offset:B.value})))},tt=function(){if(t.touchable&&T.swiping){var e=Date.now()-i,a=B.value/e;if((Math.abs(a)>.25||Math.abs(B.value)>D.value/2)&&V.value){var n=t.vertical?A.offsetY.value:A.offsetX.value,r=0;r=t.loop?n>0?B.value>0?-1:1:0:-Math[B.value>0?"ceil":"floor"](B.value/D.value),G({pace:r,emitChange:!0})}else B.value&&G({pace:0});T.swiping=!1,Z()}},et=function(e,a){var i=a===U.value,n=i?{backgroundColor:t.indicatorColor}:void 0;return k("i",{style:n,class:O("indicator",{active:i})},null)};return f({prev:function(){L(),A.reset(),C((function(){T.swiping=!1,G({pace:-1,emitChange:!0})}))},next:N,state:T,resize:F,swipeTo:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};L(),A.reset(),C((function(){var i;i=t.loop&&e===X.value?0===T.active?0:e:e%X.value,a.immediate?C((function(){T.swiping=!1})):T.swiping=!1,G({pace:i-T.active,emitChange:!0})}))}}),Y({size:D,props:t,count:X,activeIndicator:U}),d((function(){return t.initialSwipe}),(function(t){return $(+t)})),d(X,(function(){return $(T.active)})),d((function(){return t.autoplay}),Z),d([p,h],F),d(w(),(function(t){"visible"===t?Z():Q()})),g($),m((function(){return $(T.active)})),y((function(){return $(T.active)})),b(Q),_(Q),function(){var e;return k("div",{ref:o,class:O()},[k("div",{style:W.value,class:O("track",{vertical:t.vertical}),onTouchstart:J,onTouchmove:K,onTouchend:tt,onTouchcancel:tt},[null==(e=r.default)?void 0:e.call(r)]),r.indicator?r.indicator({active:U.value,total:X.value}):t.showIndicators&&X.value>1?k("div",{class:O("indicators",{vertical:t.vertical})},[Array(X.value).fill("").map(et)]):void 0])}}}),D=(e("S",T(X)),t(a("swipe-item"),2)),B=D[0],H=D[1],P=o({name:B,setup:function(t,e){var a,i=e.slots,n=u({offset:0,inited:!1,mounted:!1}),r=A(E),o=r.parent,c=r.index;if(o){var l=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,u=0===i&&e?r:i-1,l=i===r&&e?0:i+1;return a=c.value===i||c.value===u||c.value===l}));return g((function(){S((function(){n.mounted=!0}))})),f({setOffset:function(t){n.offset=t}}),function(){var t;return k("div",{class:H(),style:l.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(P))}}}))}();
|