DemuMesDataV/components/fullScreenContainer/index.vue

69 lines
1.3 KiB
Vue
Raw Permalink Normal View History

2018-12-13 18:48:54 +08:00
<template>
2019-01-16 16:56:11 +08:00
<div id="dv-full-screen-container" ref="full-screen-container">
<slot></slot>
2018-12-13 18:48:54 +08:00
</div>
</template>
<script>
export default {
2019-01-16 16:56:11 +08:00
name: 'FullScreenContainer',
2018-12-13 18:48:54 +08:00
data () {
return {
scale: 0,
datavRoot: ''
}
},
methods: {
init () {
const { initConfig, setAppScale, bindReSizeEventHandler } = this
initConfig()
setAppScale()
bindReSizeEventHandler()
},
initConfig () {
const { width, height } = screen
this.allWidth = width
2019-01-16 16:56:11 +08:00
const datavRoot = this.datavRoot = this.$refs['full-screen-container']
2018-12-13 18:48:54 +08:00
datavRoot.style.width = `${width}px`
datavRoot.style.height = `${height}px`
},
setAppScale () {
const { allWidth, datavRoot } = this
const currentWidth = document.body.clientWidth
datavRoot.style.transform = `scale(${currentWidth / allWidth})`
},
bindReSizeEventHandler () {
const { debounce, setAppScale } = this
if (!debounce) return
window.addEventListener('resize', debounce(100, setAppScale))
}
},
mounted () {
const { init } = this
init()
}
}
</script>
<style lang="less">
2019-01-16 16:56:11 +08:00
#dv-full-screen-container {
position: fixed;
top: 0px;
left: 0px;
2018-12-13 18:48:54 +08:00
overflow: hidden;
2019-01-16 16:56:11 +08:00
transform-origin: left top;
z-index: 999;
2018-12-13 18:48:54 +08:00
}
</style>