UNPKG

xiangyang-scale

Version:

针对数据可视化大屏自适应插件

2 lines 2.64 kB
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["xiangyang-ui"]=t():e["xiangyang-ui"]=t()})("undefined"!==typeof self?self:this,(function(){return function(){"use strict";var e={};!function(){e.d=function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})}}(),function(){e.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){e.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}(),function(){e.p=""}();var t={};if(e.r(t),e.d(t,{default:function(){return h}}),"undefined"!==typeof window){var n=window.document.currentScript,o=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);o&&(e.p=o[1])}var i=function(){var e=this,t=e._self._c;return t("div",{ref:"ScaleBox",staticClass:"ScaleBox",style:{width:e.width+"px",height:e.height+"px"}},[e._t("default")],2)},r=[],s={name:"ScaleBox",props:{width:{typeof:Number,require:!0,default:1920},height:{typeof:Number,require:!0,default:1080}},data(){return{scale:0}},mounted(){this.setScale(),window.addEventListener("resize",this.debounce(this.setScale))},methods:{getScale(){const{width:e,height:t}=this,n=window.innerHeight/t,o=window.innerWidth/e;return console.log(o<n?o:n),o<n?o:n},setScale(){this.scale=this.getScale(),this.$refs.ScaleBox&&this.$refs.ScaleBox.style.setProperty("--scale",this.scale)},debounce(e,t){const n=t||500;let o;return function(){const t=this,i=arguments;o&&clearTimeout(o),o=setTimeout((function(){o=null,e.apply(t,i)}),n)}}}},c=s;function a(e,t,n,o,i,r,s,c){var a,u="function"===typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),o&&(u.functional=!0),r&&(u._scopeId="data-v-"+r),s?(a=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},u._ssrRegister=a):i&&(a=c?function(){i.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:i),a)if(u.functional){u._injectStyles=a;var f=u.render;u.render=function(e,t){return a.call(t),f(e,t)}}else{var l=u.beforeCreate;u.beforeCreate=l?[].concat(l,a):[a]}return{exports:e,options:u}}var u=a(c,i,r,!1,null,null,null),f=u.exports;const l=[f],d=function(e){l.forEach((t=>{e.component(t.name,t)}))};var p=d,h=p;return t}()})); //# sourceMappingURL=xiangyang-ui.umd.min.js.map