cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
2 lines (1 loc) • 7.03 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=require("vue");require("./otherFile/Bubble.js"),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:"CoWordCloudStd",props:{width:{type:String},height:{type:String},wordCloudType:{type:String},list:{type:Object,default:()=>{}},speed:{type:Number,default:400},direction:{type:String,default:"-1"},directionAngle:{type:Number,default:135},webJumpType:{type:String,default:"1"},fontSize:{type:Number,default:15},fontFamily:{type:String},letterSpacing:{type:Number},fontWeight:{type:String,default:"normal"},fontColor:{type:String,default:"rgba(255,255,255,1)"},activeBgColor:{type:String,default:"rgba(255, 255, 0,1)"},density:{type:Number,default:18},isScale:{type:Boolean,default:!1},moveUp:{type:Number,default:0},circleDeviation:{type:Number,default:60}},setup(t){const l=e.ref(t.list),o=()=>{var e=[],o="",r=[],u="",i=[],c="";l.value.data.forEach(((l,o)=>{e.push(l.text),r.push(l.webUrl),"bubble"===t.wordCloudType&&i.push(l.width)})),o=e.join(",")+",",a.value=o.repeat(t.density).slice(0,-1).split(","),u=r.join(",")+",",n.value=u.repeat(t.density).slice(0,-1).split(","),"bubble"===t.wordCloudType&&(c=i.join(",")+",",w.value=c.repeat(t.density).slice(0,-1).split(","))},a=e.ref([]),n=e.ref([]),r=e.ref(),u=e.ref(),i=e.ref(0),c=e.ref(!0),d=e.ref(-1),s=e.ref(0);var p=0,v=0;const m=()=>{o(),e.nextTick((()=>{var e,l;r.value=a.value.map((()=>({x:0,y:0,z:0,style:{}}))),i.value=u.value.offsetWidth,p=null==(e=u.value.children[0])?void 0:e.offsetWidth,v=null==(l=u.value.children[0])?void 0:l.offsetHeight;const o=(i.value-t.circleDeviation)/2,n=(i.value-t.circleDeviation)/2;r.value=[];for(let t=0;t<a.value.length;t+=1){const e=(2*(t+1)-1)/a.value.length-1,l=Math.acos(e),u=l*Math.sqrt(a.value.length*Math.PI),i={x:o*Math.sin(l)*Math.cos(u),y:n*Math.sin(l)*Math.sin(u),z:o*Math.cos(l),style:{}};r.value.push(i)}y()}))},y=()=>{b(),f(),h(),s.value=requestAnimationFrame(y)},b=()=>{const e=["-1","1"].includes(t.direction)?Math.PI/(1/0):Math.PI/(Number(t.direction)/2*Number(t.speed)),l=Math.cos(e),o=Math.sin(e);r.value=r.value.map((e=>{const t=e.y*l-e.z*o,a=e.z*l+e.y*o;return{...e,y:t,z:a}}))},f=()=>{const e=["-2","2"].includes(t.direction)?Math.PI/(1/0):Math.PI/(Number(t.direction)*Number(t.speed)),l=Math.cos(e),o=Math.sin(e);r.value=r.value.map((e=>{const t=e.x*l-e.z*o,a=e.z*l+e.x*o;return{...e,x:t,z:a}}))},h=()=>{const e=i.value/2,t=i.value/2;r.value=r.value.map((l=>{const{x:o,y:a,z:n}=l,r=i.value,u=i.value/2,c=r/(r-n),d=(n+u)/(2*u),s=`translate(${o+e-p/2+"px"}, ${a+t-v+"px"}) scale(${c})`;return{x:o,y:a,z:n,style:{...l.style,opacity:d+.5,zIndex:parseInt((100*c).toString(),10),transform:s}}}))},g=e.ref(!0),w=e.ref([]),k=e.ref(),T=e.ref(500),S=e.ref(),C=e.ref(120),x=e.ref(),_=e.ref(!0),B=()=>{e.nextTick((()=>{S.value=k.value.offsetWidth,C.value=120+.34*(S.value-T.value),window.tagcloud({selector:`.word-cloud__tagcloud${x.value}`,radius:C.value||120,mspeed:t.speed,ispeed:t.speed/10,direction:t.directionAngle,keep:!1,isIntervel:_.value,activeScale:t.isScale})}))},M=()=>{"3D"===t.wordCloudType?(cancelAnimationFrame(s.value),m()):"bubble"===t.wordCloudType&&(g.value=!1,e.nextTick((()=>{g.value=!0,o(),B()})))};return e.watch((()=>t.density),(()=>{"3D"===t.wordCloudType?(cancelAnimationFrame(s.value),m()):"bubble"===t.wordCloudType&&(g.value=!1,e.nextTick((()=>{o(),g.value=!0,B()})))})),e.watch((()=>t.list),(()=>{l.value=t.list,M()})),e.watch((()=>t.fontSize),(()=>{M()})),e.watch((()=>t.letterSpacing),(()=>{M()})),e.watch((()=>t.circleDeviation),(()=>{M()})),e.watch((()=>t.speed),(()=>{"bubble"===t.wordCloudType&&(g.value=!1,e.nextTick((()=>{g.value=!0,B()})))})),e.watch((()=>t.directionAngle),(()=>{"bubble"===t.wordCloudType&&(g.value=!1,e.nextTick((()=>{g.value=!0,B()})))})),e.watch((()=>t.isScale),(()=>{"bubble"===t.wordCloudType&&(g.value=!1,e.nextTick((()=>{g.value=!0,B()})))})),e.onMounted((()=>{"3D"===t.wordCloudType?m():"bubble"===t.wordCloudType&&(x.value=(new Date).getTime(),o(),e.nextTick((()=>{B()})))})),e.onUnmounted((()=>{"3D"===t.wordCloudType?cancelAnimationFrame(s.value):"bubble"===t.wordCloudType&&(_.value=!1,B())})),{listData:l,data:a,contentEle:r,active:c,num:d,tagBall:u,isBubble:g,bubbleWidth:w,wrapper:k,initTimer:x,mouseoutFn:()=>{y()},mouseoverFn:()=>{cancelAnimationFrame(s.value)},webJumpFn:e=>{"1"===t.webJumpType?window.open(n.value[e]):"0"===t.webJumpType&&(window.location.href=n.value[e])},RESET_VIEW:()=>{"3D"===t.wordCloudType?(cancelAnimationFrame(s.value),m()):"bubble"===t.wordCloudType&&(g.value=!1,e.nextTick((()=>{g.value=!0,B()})))},updataList:e=>{l.value=e,M()},...e.toRefs(t)}}}),o=["onMouseover","onClick"],a={key:1,class:"word-cloud-std__tagBall"},n={key:0,class:"word-cloud-std__wrapper",ref:"wrapper"},r=["onClick"];var u=t.default(l,[["render",function(t,l,u,i,c,d){return e.openBlock(),e.createElementBlock("div",{class:"co-word-cloud-std",style:e.normalizeStyle({width:t.width||"100%",height:t.height||"100%"})},["3D"===t.wordCloudType?(e.openBlock(),e.createElementBlock("div",{key:0,class:"word-cloud-std__tagBall",style:e.normalizeStyle({position:"absolute",top:-t.moveUp+"px"}),ref:"tagBall",onMouseover:l[1]||(l[1]=(...e)=>t.mouseoverFn&&t.mouseoverFn(...e)),onMouseout:l[2]||(l[2]=(...e)=>t.mouseoutFn&&t.mouseoutFn(...e))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data,((a,n)=>(e.openBlock(),e.createElementBlock("span",{class:"word-cloud-std__tag",key:n,style:e.normalizeStyle({color:t.listData.color[n%t.listData.color.length],backgroundColor:t.num==n?t.activeBgColor:"unset",cursor:t.num==n?"pointer":"auto",fontSize:t.fontSize+"px",fontFamily:t.fontFamily,letterSpacing:t.letterSpacing+"px",fontWeight:t.fontWeight,...t.contentEle[n].style}),onMouseover:e=>t.num=n,onMouseout:l[0]||(l[0]=e=>t.num=-1),onClick:e=>t.webJumpFn(n)},e.toDisplayString(a),45,o)))),128))],36)):e.createCommentVNode("",!0),"bubble"===t.wordCloudType?(e.openBlock(),e.createElementBlock("div",a,[t.isBubble?(e.openBlock(),e.createElementBlock("div",n,[e.createElementVNode("div",{class:e.normalizeClass(`word-cloud__tagcloud word-cloud__tagcloud${t.initTimer}`)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data,((l,o)=>(e.openBlock(),e.createElementBlock("div",{class:"b01 co01",key:o,style:e.normalizeStyle({background:`linear-gradient(to bottom, rgba(255,255,255,1) 0%, ${t.listData.color[o%t.listData.color.length]} 100%)`,width:t.bubbleWidth[o]+"px",height:t.bubbleWidth[o]+"px",color:t.fontColor,fontSize:t.fontSize+"px",fontFamily:t.fontFamily,letterSpacing:t.letterSpacing+"px",cursor:"0"===t.webJumpType||"1"===t.webJumpType?"pointer":"auto"}),onClick:e=>t.webJumpFn(o)},[e.createElementVNode("span",null,e.toDisplayString(l),1)],12,r)))),128))],2)],512)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],4)}],["__scopeId","data-v-21e4e620"]]);exports.default=u;