2019-11-28 14:42:11 +08:00
|
|
|
// import HollowOutStyleManager from '../utils/HollowOutStyleManager'
|
2019-09-19 11:13:05 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
watch: {
|
|
|
|
synthesizedTheme (value) {
|
|
|
|
if (this.avoidHollowOut) return
|
|
|
|
this.$nextTick().then(() => {
|
|
|
|
this.updateHollowOutStyle(value)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2020-01-05 15:20:35 +08:00
|
|
|
ascendantBackgroundColor: null,
|
|
|
|
hollowOutColorTransitionDisabled: true
|
2019-09-19 11:13:05 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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()
|
2020-01-05 15:20:35 +08:00
|
|
|
this.$nextTick().then(() => {
|
|
|
|
this.hollowOutColorTransitionDisabled = false
|
|
|
|
})
|
2019-09-19 11:13:05 +08:00
|
|
|
}
|
|
|
|
}
|