1 |
- import{E as P,ab as v,d as B,U as b,S as L,ap as W,aa as C,af as D,ak as O,a3 as $,a6 as j,aF as A,j as l,N as k,Y as x,ar as I,au as F,M as U,O as V}from"./ResizeObserver.es.39b48a47.js";const[X,d]=P("notice-bar"),Y={text:String,mode:String,color:String,delay:v(1),speed:v(60),leftIcon:String,wrapable:Boolean,background:String,scrollable:{type:Boolean,default:null}};var _=B({name:X,props:Y,emits:["close","replay"],setup(e,{emit:f,slots:a}){let o=0,t=0,u;const m=b(),h=b(),n=L({show:!0,offset:0,duration:0}),y=()=>{if(a["left-icon"])return a["left-icon"]();if(e.leftIcon)return l(k,{class:d("left-icon"),name:e.leftIcon},null)},R=()=>{if(e.mode==="closeable")return"cross";if(e.mode==="link")return"arrow"},T=r=>{e.mode==="closeable"&&(n.show=!1,f("close",r))},E=()=>{if(a["right-icon"])return a["right-icon"]();const r=R();if(r)return l(k,{name:r,class:d("right-icon"),onClick:T},null)},S=()=>{n.offset=o,n.duration=0,F(()=>{I(()=>{n.offset=-t,n.duration=(t+o)/+e.speed,f("replay")})})},N=()=>{const r=e.scrollable===!1&&!e.wrapable,c={transform:n.offset?`translateX(${n.offset}px)`:"",transitionDuration:`${n.duration}s`};return l("div",{ref:m,role:"marquee",class:d("wrap")},[l("div",{ref:h,style:c,class:[d("content"),{"van-ellipsis":r}],onTransitionend:S},[a.default?a.default():e.text])])},i=()=>{const{delay:r,speed:c,scrollable:w}=e,M=U(r)?+r*1e3:0;o=0,t=0,n.offset=0,n.duration=0,clearTimeout(u),u=setTimeout(()=>{if(!m.value||!h.value||w===!1)return;const p=x(m).width,g=x(h).width;(w||g>p)&&I(()=>{o=p,t=g,n.offset=-t,n.duration=t/+c})},M)};return W(i),C(i),D("pageshow",i),O({reset:i}),$(()=>[e.text,e.scrollable],i),()=>{const{color:r,wrapable:c,background:w}=e;return j(l("div",{role:"alert",class:d({wrapable:c}),style:{color:r,background:w}},[y(),N(),E()]),[[A,n.show]])}}});const G=V(_);var q={exports:{}},s=q.exports={};s.nextTick=function(){var e=typeof window!="undefined"&&window.setImmediate,f=typeof window!="undefined"&&window.postMessage&&window.addEventListener;if(e)return function(o){return window.setImmediate(o)};if(f){var a=[];return window.addEventListener("message",function(o){var t=o.source;if((t===window||t===null)&&o.data==="process-tick"&&(o.stopPropagation(),a.length>0)){var u=a.shift();u()}},!0),function(t){a.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}();s.title="browser";s.browser=!0;s.env={};s.argv=[];s.binding=function(e){throw new Error("process.binding is not supported")};s.cwd=function(){return"/"};s.chdir=function(e){throw new Error("process.chdir is not supported")};export{G as N,q as b};
|