mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
// import HollowOutStyleManager from '../utils/HollowOutStyleManager'
|
|
|
|
export default {
|
|
watch: {
|
|
synthesizedTheme (value) {
|
|
if (this.avoidHollowOut) return
|
|
this.$nextTick().then(() => {
|
|
console.log('update style')
|
|
this.updateHollowOutStyle(value)
|
|
})
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
ascendantBackgroundColor: null
|
|
}
|
|
},
|
|
methods: {
|
|
setHollowOutAffect () {
|
|
this.updateHollowOutStyle()
|
|
},
|
|
updateHollowOutStyle (theme) {
|
|
let cursor = this.$el
|
|
theme = theme || this.synthesizedTheme
|
|
while (cursor.parentElement) {
|
|
cursor = cursor.parentElement
|
|
const backgroundColorHint = cursor.getAttribute(`n-${theme}-theme-background-color-hint`)
|
|
if (backgroundColorHint === 'transparent') continue
|
|
if (backgroundColorHint) {
|
|
// console.log(cursor, backgroundColorHint, theme)
|
|
this.ascendantBackgroundColor = backgroundColorHint
|
|
break
|
|
}
|
|
const backgroundColor = getComputedStyle(cursor).backgroundColor
|
|
if (backgroundColor && backgroundColor !== 'rgba(0, 0, 0, 0)') {
|
|
// console.log(cursor, backgroundColor)
|
|
this.ascendantBackgroundColor = backgroundColor
|
|
break
|
|
}
|
|
}
|
|
// HollowOutStyleManager.registerComponent(this.hollowOutBackgroundColorId, this.ascendantBackgroundColor)
|
|
}
|
|
},
|
|
mounted () {
|
|
// this.hollowOutBackgroundColorId = 'x' + Math.random().toString(16).slice(9)
|
|
// this.$el.setAttribute('n-hollowoutable-id', this.hollowOutBackgroundColorId)
|
|
if (this.avoidHollowOut) return
|
|
this.updateHollowOutStyle()
|
|
},
|
|
beforeDestroy () {
|
|
// const id = this.hollowOutBackgroundColorId
|
|
// HollowOutStyleManager.unregisterComponent(id, 1000)
|
|
}
|
|
}
|