fix[Charts]: fix charts resize in keep-alive bug
This commit is contained in:
parent
088f64eecc
commit
e138bbe9c1
|
@ -7,20 +7,17 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.__resizeHandler = debounce(() => {
|
this.initListener()
|
||||||
if (this.chart) {
|
},
|
||||||
this.chart.resize()
|
activated() {
|
||||||
}
|
this.resize()
|
||||||
}, 100)
|
this.initListener()
|
||||||
window.addEventListener('resize', this.__resizeHandler)
|
|
||||||
|
|
||||||
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
|
|
||||||
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
window.removeEventListener('resize', this.__resizeHandler)
|
this.destroyListener()
|
||||||
|
},
|
||||||
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
|
deactivated() {
|
||||||
|
this.destroyListener()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// use $_ for mixins properties
|
// use $_ for mixins properties
|
||||||
|
@ -29,6 +26,25 @@ export default {
|
||||||
if (e.propertyName === 'width') {
|
if (e.propertyName === 'width') {
|
||||||
this.__resizeHandler()
|
this.__resizeHandler()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
initListener() {
|
||||||
|
this.__resizeHandler = debounce(() => {
|
||||||
|
this.resize()
|
||||||
|
}, 100)
|
||||||
|
window.addEventListener('resize', this.__resizeHandler)
|
||||||
|
|
||||||
|
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
|
||||||
|
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
|
||||||
|
},
|
||||||
|
destroyListener() {
|
||||||
|
window.removeEventListener('resize', this.__resizeHandler)
|
||||||
|
|
||||||
|
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
|
||||||
|
},
|
||||||
|
resize() {
|
||||||
|
if (this.chart) {
|
||||||
|
this.chart.resize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue