cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
2 lines (1 loc) • 7.66 kB
JavaScript
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=require("vue");require("./index.vue_vue_type_style_index_0_scoped_true_lang.js");var t=require("../../_virtual/plugin-vue_export-helper.js");const l=e.defineComponent({name:"CoLabelText",props:{value:{type:String,required:!0},fontSize:{type:[Number,String],default:16},fontWeight:{type:String,default:"normal"},fontFamily:{type:String,default:"微软雅黑"},letterSpacing:{type:Number,defalt:2},lineHeight:{type:Number,default:16},textAlign:{type:String,default:"center"},justifyContent:{type:String,default:"center"},color:{type:String,default:"#fff"},backgroundColor:{type:String,default:""},opacity:{type:Number,default:1},style:{type:Object,defalut:{}},showScoll:{type:Boolean,default:!1},showLink:{type:Boolean,default:!0},link:{type:String,default:""},currentPage:{type:Boolean,default:!1},direction:{type:String,default:"left"},runTime:{type:Number,default:10},textOneWidth:{type:Number},singleLineText:{type:Boolean},linearGradientShow:{type:Boolean},linearGradient:{type:String},linearGradientColorOne:{type:String},linearGradientColorTwo:{type:String},moreText:{type:Boolean},titleText:{type:Boolean},highText:{type:Boolean},linkText:{type:Boolean},scollText:{type:Boolean}},setup(t){const l=e.ref(),n=e.ref(),o=e.ref(),a=e.ref(),r=e.ref(),i=e.ref(),u=e.ref(0),s=e.ref(0),c=e.ref(0),f=e.ref(0),d=e.ref(0),v=e.ref(40),h=e.ref(40),p=e.ref(1e3*t.runTime),g=e.ref(!1),x=e.ref(!0),_=e.ref(t.justifyContent),y=e.computed((()=>({fontSize:t.fontSize+"px",fontWeight:t.fontWeight,fontFamily:t.fontFamily,letterSpacing:t.letterSpacing+"px",textAlign:t.textAlign,backgroundColor:t.backgroundColor,lineHeight:t.lineHeight+"px",width:t.textOneWidth+"px",height:("top"===t.direction||"bottom"===t.direction)&&(g.value||x.value)?"unset":"100%",color:t.color,backgroundClip:"text",opacity:t.opacity,justifyContent:t.justifyContent,...t.style}))),b=e.computed((()=>{let e={whiteSpace:"unset"},l={color:"unset",borderBottom:"unset",backgroundImage:"unset"};switch(t.singleLineText&&(l.color=t.color,e.whiteSpace="nowrap"),t.direction){case"left":return{left:u.value+"px",top:"unset",right:"unset",bottom:"unset",...e,...l};case"right":return{right:s.value+"px",top:"unset",left:"unset",bottom:"unset",...e,...l};case"top":return{top:c.value+"px",left:"unset",right:"unset",bottom:"unset",...e,...l};case"bottom":return{bottom:f.value+"px",left:"unset",right:"unset",top:"unset",...e,...l}}})),m=e.computed((()=>{let e={color:"unset",borderBottom:"unset",backgroundImage:"unset","-webkit-background-clip":"unset",cursor:"defualt"};return t.linearGradientShow?(e.backgroundImage=`linear-gradient(to ${t.linearGradient},${t.linearGradientColorOne},${t.linearGradientColorTwo})`,e.color="transparent",e["-webkit-background-clip"]="text"):e.color=t.color,""!=t.link&&(e.color=t.color,e.cursor="pointer",t.showLink&&(e.borderBottom=`1px solid ${t.color}`),t.linearGradientShow&&(e.backgroundImage=`linear-gradient(to ${t.linearGradient},${t.linearGradientColorOne},${t.linearGradientColorTwo})`,e.color="transparent",e["-webkit-background-clip"]="text")),(t.moreText||t.highText||t.linkText||t.scollText)&&(e.color=t.color),{...e}}));e.watch((()=>t.showScoll),(()=>{i.value&&clearInterval(i.value),u.value=0,s.value=0,c.value=0,f.value=0,t.showScoll&&0!=t.runTime&&(p.value=1e3*t.runTime,S())})),e.watch((()=>t.runTime),(()=>{i.value&&clearInterval(i.value),0!=t.runTime&&(p.value=1e3*t.runTime,S())})),e.watch((()=>t.value),(()=>{i.value&&clearInterval(i.value),t.highText&&(_.value=t.justifyContent)})),e.watch((()=>t.justifyContent),(()=>{i.value&&clearInterval(i.value),t.highText&&(_.value=t.justifyContent)}));const S=()=>{let e=l.value;n.value;let _=o.value;a.value;let y=r.value;switch(t.direction){case"left":case"right":_.offsetWidth<e.offsetWidth?(v.value=e.offsetWidth-_.offsetWidth,y.style.width=v.value+"px",d.value=p.value/e.offsetWidth):(y.style.width=v.value+"px",d.value=p.value/_.offsetWidth);break;case"top":case"bottom":x.value=!1,_.offsetHeight<e.offsetHeight?(h.value=e.offsetHeight-_.offsetHeight,y.style.height=h.value+"px",d.value=p.value/e.offsetHeight,g.value=!1):(y.style.height=h.value+"px",d.value=p.value/(_.offsetHeight+h.value),g.value=!0),"bottom"==t.direction&&(f.value=_.offsetHeight+h.value)}i.value=setInterval((()=>{switch(t.direction){case"left":u.value--,Math.abs(u.value)>=_.offsetWidth+v.value&&(u.value=0);break;case"right":s.value--,Math.abs(s.value)>=_.offsetWidth+v.value&&(s.value=0);break;case"top":c.value--,Math.abs(c.value)>_.offsetHeight+h.value&&(c.value=0);break;case"bottom":f.value--,Math.abs(f.value)>=_.offsetHeight+h.value&&(f.value=_.offsetHeight);break;default:clearInterval(i.value)}}),d.value)},w=e.computed((()=>{let e={justifyContent:"unset"};return e.justifyContent=t.justifyContent,{...e}})),C=e.computed((()=>{let e={justifyContent:"unset"};return e.justifyContent=_.value,{...e}}));return e.onMounted((()=>{p.value=1e3*t.runTime,t.showScoll&&S()})),e.onUnmounted((()=>{clearInterval(i.value)})),{textRef:l,textChildRef:n,textContentChildOneRef:o,textContentChildTowRef:a,contentBoxRef:r,attrs:y,styleMove:b,spanContent:m,contentWidth:v,contentHeight:h,singleLineTextSpanContent:w,highMoreTextSpanContent:C,clickText:()=>{""===t.link||0!==t.link.indexOf("http://")&&0!==t.link.indexOf("https://")||(1==t.currentPage?window.location.href=t.link:window.open(t.link))},textScroll:S,...e.toRefs(t)}}}),n={ref:"contentBoxRef",style:{"{\r\n width":"contentWidth",height:"contentHeight"}};var o=t.default(l,[["render",function(t,l,o,a,r,i){return e.openBlock(),e.createElementBlock("div",{class:"co-label-text",ref:"textRef",type:"text",onClick:l[0]||(l[0]=(...e)=>t.clickText&&t.clickText(...e))},[e.createElementVNode("div",{class:e.normalizeClass(["label-text__value",t.showScoll?"left"!=t.direction&&"right"!=t.direction||!t.showScoll?"label-text__value__wrap":"label-text__value__nowrap":"label-text__value__aa"]),ref:"textChildRef",style:e.normalizeStyle(t.styleMove)},[e.createElementVNode("div",{ref:"textContentChildOneRef",class:e.normalizeClass(["label-text__value__content",t.showScoll?"left"!=t.direction&&"right"!=t.direction||!t.showScoll?"label-text__value__contentBlock":"label-text__value__content":"label-text__value__aa"]),style:e.normalizeStyle({...t.attrs,...t.spanContent})},[e.createElementVNode("span",{class:e.normalizeClass(["label-text__value__spanContent",t.moreText||t.highText?"label-text__value__wrapMore":"label-text__value__nowrap"]),style:e.normalizeStyle(t.singleLineText||t.titleText?t.singleLineTextSpanContent:t.highMoreTextSpanContent)},e.toDisplayString(t.value),7)],6),e.createElementVNode("div",{class:e.normalizeClass(t.showScoll?"left"!=t.direction&&"right"!=t.direction||!t.showScoll?"contentBox__block":"contentBox__inlineBlock":"contentBox__none")},[e.createElementVNode("span",n,null,512)],2),e.withDirectives(e.createElementVNode("div",{ref:"textContentChildTowRef",class:e.normalizeClass(["label-text__value__content",t.showScoll?"left"!=t.direction&&"right"!=t.direction||!t.showScoll?"label-text__value__contentBlock":"label-text__value__content":"label-text__value__aa"]),style:e.normalizeStyle({...t.attrs,...t.spanContent})},[e.createElementVNode("span",{class:e.normalizeClass(["label-text__value__spanContent",t.moreText||t.highText?"label-text__value__wrapMore":"label-text__value__nowrap"]),style:e.normalizeStyle(t.singleLineText||t.titleText?t.singleLineTextSpanContent:t.highMoreTextSpanContent)},e.toDisplayString(t.value),7)],6),[[e.vShow,t.showScoll]])],6)],512)}],["__scopeId","data-v-aab2e48c"]]);exports.default=o;