2019-07-26 16:26:59 +08:00
|
|
|
|
|
|
|
import zIndexManager from '../utils/dom/zIndexManager'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* watch active on component,
|
|
|
|
* acquire new z-index on content when active is set to true
|
|
|
|
*
|
|
|
|
* dependency:
|
2019-08-16 16:45:26 +08:00
|
|
|
* $refs.contentContainer
|
2019-07-26 16:26:59 +08:00
|
|
|
* $vm.active
|
2019-10-19 20:26:07 +08:00
|
|
|
* $vm.detached
|
2019-07-26 16:26:59 +08:00
|
|
|
*/
|
|
|
|
export default {
|
|
|
|
mounted () {
|
2019-10-19 20:26:07 +08:00
|
|
|
if (!this.detached) return
|
2019-09-02 18:30:53 +08:00
|
|
|
zIndexManager.registerElement(this._getZindexableContent())
|
2019-07-26 16:26:59 +08:00
|
|
|
},
|
|
|
|
watch: {
|
2019-12-02 20:57:09 +08:00
|
|
|
active (value) {
|
2019-10-19 20:26:07 +08:00
|
|
|
if (!this.detached) return
|
2019-12-02 20:57:09 +08:00
|
|
|
console.debug('[zindexable.watch.active]:', value)
|
|
|
|
if (value) {
|
2019-09-02 18:30:53 +08:00
|
|
|
zIndexManager.setNewZIndex(this._getZindexableContent())
|
2019-07-26 16:26:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy () {
|
2019-10-19 20:26:07 +08:00
|
|
|
if (!this.detached) return
|
2019-09-02 18:30:53 +08:00
|
|
|
zIndexManager.unregisterElement(this._getZindexableContent())
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
_getZindexableContent () {
|
|
|
|
if (this.$refs.contentContainer) {
|
|
|
|
return this.$refs.contentContainer
|
|
|
|
} else {
|
|
|
|
return this.getZindexableContent()
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 16:26:59 +08:00
|
|
|
}
|
|
|
|
}
|