naive-ui/packages/mixins/withsecondlightbar.js
2019-09-04 11:26:24 +08:00

36 lines
922 B
JavaScript

export default {
data () {
return {
showSecondLightBar: false,
secondLightBarTop: 0,
secondLightBarVanishTimerId: null
}
},
computed: {
secondLightBarStyleTop () {
return this.secondLightBarTop + 'px'
}
},
beforeDestory () {
window.clearTimeout(this.secondLightBarVanishTimerId)
},
methods: {
updateSecondLightBarPosition (el) {
if (this.active) {
if (this.secondLightBarVanishTimerId) {
window.clearTimeout(this.secondLightBarVanishTimerId)
this.secondLightBarVanishTimerId = null
}
this.showSecondLightBar = true
this.secondLightBarTop = el.offsetTop
}
},
hideSecondLightBar (delay = 100) {
window.clearTimeout(this.secondLightBarVanishTimerId)
this.secondLightBarVanishTimerId = window.setTimeout(() => {
this.showSecondLightBar = false
}, delay)
}
}
}