Removed window ref in data, moved init to beforeMount

This commit is contained in:
euvl
2017-06-19 22:23:53 +01:00
parent 85ef8436a7
commit 620d905e29

View File

@@ -147,8 +147,8 @@
}, },
window: { window: {
width: window.innerWidth, width: 0,
height: window.innerWidth height: 0
}, },
draggableElement: false draggableElement: false
@@ -178,7 +178,7 @@
} }
} }
}, },
created () { beforeMount () {
Modal.event.$on('toggle', (name, state, params) => { Modal.event.$on('toggle', (name, state, params) => {
if (name === this.name) { if (name === this.name) {
if (typeof state === 'undefined') { if (typeof state === 'undefined') {
@@ -190,13 +190,11 @@
}); });
window.addEventListener('resize', this.onWindowResize) window.addEventListener('resize', this.onWindowResize)
this.onWindowResize()
}, },
beforeDestroy () { beforeDestroy () {
window.removeEventListener('resize', this.onWindowResize) window.removeEventListener('resize', this.onWindowResize)
}, },
beforeMount () {
this.onWindowResize()
},
computed: { computed: {
position () { position () {
const { window, modal, shift } = this const { window, modal, shift } = this