1 |
- import{t as e,A as a,d as t,E as o,r as s,ad as r,$ as l,k as n,a9 as c,H as i,ar as d,ax as f,a as u,R as p,a5 as b,ap as m,U as g,ae as h,x as w}from"./index-610f082f.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(),S=o(),j=s({show:!0,offset:0,duration:0}),A=t=>{"closeable"===e.mode&&(j.show=!1,a("close",t))},I=()=>{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},T=()=>{j.offset=y,j.duration=0,g((()=>{m((()=>{j.offset=-x,j.duration=(x+y)/+e.speed,a("replay")}))}))},B=()=>{const a=!1===e.scrollable&&!e.wrapable,o={transform:j.offset?"translateX(".concat(j.offset,"px)"):"",transitionDuration:"".concat(j.duration,"s")};return u("div",{ref:k,role:"marquee","class":v("wrap")},[u("div",{ref:S,style:o,"class":[v("content"),{"van-ellipsis":a}],onTransitionend:T},[t["default"]?t["default"]():e.text])])},E=()=>{const{delay:a,speed:t,scrollable:o}=e,s=h(a)?1e3*+a:0;y=0,x=0,j.offset=0,j.duration=0,clearTimeout(w),w=setTimeout((()=>{if(!k.value||!S.value||!1===o)return;const e=b(k).width,a=b(S).width;(o||a>e)&&m((()=>{y=e,x=a,j.offset=-x,j.duration=x/+t}))}),s)};return r(E),l(E),n("pageshow",E),c({reset:E}),i((()=>[e.text,e.scrollable]),E),()=>{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,B(),I()]),[[f,j.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};
|