|
|
-import{c as D,b as g,d as W,r as v,x as C,bQ as E,bo as P,a4 as q,a3 as L,w as M,g as $,v as A,a as c,I as R,a5 as I,aR as y,aD as O,a2 as Q,k as V}from"./index-94a8cf5c.js";const[X,i]=D("notice-bar"),_={text:String,mode:String,color:String,delay:g(1),speed:g(60),leftIcon:String,wrapable:Boolean,background:String,scrollable:{type:Boolean,default:null}};var j=W({name:X,props:_,emits:["close","replay"],setup(e,{emit:m,slots:a}){let l=0,o=0,h;const d=v(),u=v(),t=C({show:!0,offset:0,duration:0}),k=()=>{if(a["left-icon"])return a["left-icon"]();if(e.leftIcon)return c(R,{class:i("left-icon"),name:e.leftIcon},null)},x=()=>{if(e.mode==="closeable")return"cross";if(e.mode==="link")return"arrow"},p=n=>{e.mode==="closeable"&&(t.show=!1,m("close",n))},N=()=>{if(a["right-icon"])return a["right-icon"]();const n=x();if(n)return c(R,{name:n,class:i("right-icon"),onClick:p},null)},S=()=>{t.offset=l,t.duration=0,O(()=>{y(()=>{t.offset=-o,t.duration=(o+l)/+e.speed,m("replay")})})},T=()=>{const n=e.scrollable===!1&&!e.wrapable,r={transform:t.offset?`translateX(${t.offset}px)`:"",transitionDuration:`${t.duration}s`};return c("div",{ref:d,role:"marquee",class:i("wrap")},[c("div",{ref:u,style:r,class:[i("content"),{"van-ellipsis":n}],onTransitionend:S},[a.default?a.default():e.text])])},s=()=>{const{delay:n,speed:r,scrollable:f}=e,B=Q(n)?+n*1e3:0;l=0,o=0,t.offset=0,t.duration=0,clearTimeout(h),h=setTimeout(()=>{if(!d.value||!u.value||f===!1)return;const w=I(d).width,b=I(u).width;(f||b>w)&&y(()=>{l=w,o=b,t.offset=-o,t.duration=o/+r})},B)};return E(s),P(s),q("pageshow",s),L({reset:s}),M(()=>[e.text,e.scrollable],s),()=>{const{color:n,wrapable:r,background:f}=e;return $(c("div",{role:"alert",class:i({wrapable:r}),style:{color:n,background:f}},[k(),T(),N()]),[[A,t.show]])}}});const F=V(j);export{F as N};
|
|
|
+import{c as D,b as g,d as W,r as v,x as C,bQ as E,bo as P,a4 as q,a3 as L,w as M,g as $,v as A,a as c,I as R,a5 as I,aR as y,aD as O,a2 as Q,k as V}from"./index-5aaf3a2b.js";const[X,i]=D("notice-bar"),_={text:String,mode:String,color:String,delay:g(1),speed:g(60),leftIcon:String,wrapable:Boolean,background:String,scrollable:{type:Boolean,default:null}};var j=W({name:X,props:_,emits:["close","replay"],setup(e,{emit:m,slots:a}){let l=0,o=0,h;const d=v(),u=v(),t=C({show:!0,offset:0,duration:0}),k=()=>{if(a["left-icon"])return a["left-icon"]();if(e.leftIcon)return c(R,{class:i("left-icon"),name:e.leftIcon},null)},x=()=>{if(e.mode==="closeable")return"cross";if(e.mode==="link")return"arrow"},p=n=>{e.mode==="closeable"&&(t.show=!1,m("close",n))},N=()=>{if(a["right-icon"])return a["right-icon"]();const n=x();if(n)return c(R,{name:n,class:i("right-icon"),onClick:p},null)},S=()=>{t.offset=l,t.duration=0,O(()=>{y(()=>{t.offset=-o,t.duration=(o+l)/+e.speed,m("replay")})})},T=()=>{const n=e.scrollable===!1&&!e.wrapable,r={transform:t.offset?`translateX(${t.offset}px)`:"",transitionDuration:`${t.duration}s`};return c("div",{ref:d,role:"marquee",class:i("wrap")},[c("div",{ref:u,style:r,class:[i("content"),{"van-ellipsis":n}],onTransitionend:S},[a.default?a.default():e.text])])},s=()=>{const{delay:n,speed:r,scrollable:f}=e,B=Q(n)?+n*1e3:0;l=0,o=0,t.offset=0,t.duration=0,clearTimeout(h),h=setTimeout(()=>{if(!d.value||!u.value||f===!1)return;const w=I(d).width,b=I(u).width;(f||b>w)&&y(()=>{l=w,o=b,t.offset=-o,t.duration=o/+r})},B)};return E(s),P(s),q("pageshow",s),L({reset:s}),M(()=>[e.text,e.scrollable],s),()=>{const{color:n,wrapable:r,background:f}=e;return $(c("div",{role:"alert",class:i({wrapable:r}),style:{color:n,background:f}},[k(),T(),N()]),[[A,t.show]])}}});const F=V(j);export{F as N};
|