mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
41 lines
916 B
JavaScript
41 lines
916 B
JavaScript
|
|
import zIndexManager from '../utils/dom/zIndexManager'
|
|
|
|
/**
|
|
* watch active on component,
|
|
* acquire new z-index on content when active is set to true
|
|
*
|
|
* dependency:
|
|
* $refs.contentContainer
|
|
* $vm.active
|
|
* $vm.detached
|
|
*/
|
|
export default {
|
|
mounted () {
|
|
if (!this.detached) return
|
|
zIndexManager.registerElement(this._getZindexableContent())
|
|
},
|
|
watch: {
|
|
active (value) {
|
|
if (!this.detached) return
|
|
console.debug('[zindexable.watch.active]:', value)
|
|
if (value) {
|
|
zIndexManager.setNewZIndex(this._getZindexableContent())
|
|
}
|
|
}
|
|
},
|
|
beforeDestroy () {
|
|
if (!this.detached) return
|
|
zIndexManager.unregisterElement(this._getZindexableContent())
|
|
},
|
|
methods: {
|
|
_getZindexableContent () {
|
|
if (this.$refs.contentContainer) {
|
|
return this.$refs.contentContainer
|
|
} else {
|
|
return this.getZindexableContent()
|
|
}
|
|
}
|
|
}
|
|
}
|