naive-ui/packages/mixins/zindexable.js

28 lines
609 B
JavaScript
Raw Normal View History

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:
* $refs.contentContainer
2019-07-26 16:26:59 +08:00
* $vm.active
*/
export default {
mounted () {
zIndexManager.registerElement(this.$refs.contentContainer)
2019-07-26 16:26:59 +08:00
},
watch: {
active (newActive) {
console.debug('[zindexable.watch.active]:', newActive)
2019-07-26 16:26:59 +08:00
if (newActive) {
zIndexManager.setNewZIndex(this.$refs.contentContainer)
2019-07-26 16:26:59 +08:00
}
}
},
beforeDestroy () {
zIndexManager.unregisterElement(this.$refs.contentContainer)
2019-07-26 16:26:59 +08:00
}
}