mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-12 12:25:16 +08:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
// import HollowOutStyleManager from '../utils/HollowOutStyleManager'
|
|
|
|
export default {
|
|
watch: {
|
|
synthesizedTheme (value) {
|
|
if (this.avoidHollowOut) return
|
|
this.$nextTick().then(() => {
|
|
this.updateHollowOutStyle(value)
|
|
})
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
ascendantBackgroundColor: null,
|
|
hollowOutColorTransitionDisabled: true
|
|
}
|
|
},
|
|
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) {
|
|
this.ascendantBackgroundColor = backgroundColorHint
|
|
break
|
|
}
|
|
const backgroundColor = getComputedStyle(cursor).backgroundColor
|
|
if (backgroundColor && backgroundColor !== 'rgba(0, 0, 0, 0)') {
|
|
this.ascendantBackgroundColor = backgroundColor
|
|
break
|
|
}
|
|
}
|
|
}
|
|
},
|
|
mounted () {
|
|
if (this.avoidHollowOut) return
|
|
this.updateHollowOutStyle()
|
|
this.$nextTick().then(() => {
|
|
this.hollowOutColorTransitionDisabled = false
|
|
})
|
|
}
|
|
}
|