deep-clone-101f8332.js 1.9 KB

1
  1. import{x as e,D as a,d as t,H as o,r as s,ah as r,a3 as l,W as n,ad as i,j as c,av as d,aB as f,a as u,V as p,a9 as b,at as m,Y as g,ai as h,w}from"./index-d31722d5.js";const[y,v]=e("notice-bar"),x=w(t({name:y,props:{text:String,mode:String,color:String,delay:a(1),speed:a(60),leftIcon:String,wrapable:Boolean,background:String,scrollable:{type:Boolean,"default":null}},emits:["close","replay"],setup(e,{emit:a,slots:t}){let w,y=0,x=0;const k=o(),j=o(),S=s({show:!0,offset:0,duration:0}),A=t=>{"closeable"===e.mode&&(S.show=!1,a("close",t))},B=()=>{if(t["right-icon"])return t["right-icon"]();const a="closeable"===e.mode?"cross":"link"===e.mode?"arrow":void 0;return a?u(p,{name:a,"class":v("right-icon"),onClick:A},null):void 0},I=()=>{S.offset=y,S.duration=0,g((()=>{m((()=>{S.offset=-x,S.duration=(x+y)/+e.speed,a("replay")}))}))},T=()=>{const a=!1===e.scrollable&&!e.wrapable,o={transform:S.offset?"translateX(".concat(S.offset,"px)"):"",transitionDuration:"".concat(S.duration,"s")};return u("div",{ref:k,role:"marquee","class":v("wrap")},[u("div",{ref:j,style:o,"class":[v("content"),{"van-ellipsis":a}],onTransitionend:I},[t["default"]?t["default"]():e.text])])},D=()=>{const{delay:a,speed:t,scrollable:o}=e,s=h(a)?1e3*+a:0;y=0,x=0,S.offset=0,S.duration=0,clearTimeout(w),w=setTimeout((()=>{if(!k.value||!j.value||!1===o)return;const e=b(k).width,a=b(j).width;(o||a>e)&&m((()=>{y=e,x=a,S.offset=-x,S.duration=x/+t}))}),s)};return r(D),l(D),n("pageshow",D),i({reset:D}),c((()=>[e.text,e.scrollable]),D),()=>{const{color:a,wrapable:o,background:s}=e;return d(u("div",{role:"alert","class":v({wrapable:o}),style:{color:a,background:s}},[t["left-icon"]?t["left-icon"]():e.leftIcon?u(p,{"class":v("left-icon"),name:e.leftIcon},null):void 0,T(),B()]),[[f,S.show]])}}})),k=e=>{if(null===e)return null;const a=Object.assign({},e);return Object.keys(a).forEach((t=>a[t]="object"==typeof e[t]?k(e[t]):e[t])),Array.isArray(e)?(a.length=e.length,Array.from(a)):a};export{x as N,k as d};