2019-08-19 15:25:41 +08:00
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
showLightBar: false,
|
2019-09-04 11:26:24 +08:00
|
|
|
lightBarTop: 0,
|
|
|
|
lightBarVanishTimerId: null
|
2019-08-19 15:25:41 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
lightBarStyleTop () {
|
|
|
|
return this.lightBarTop + 'px'
|
|
|
|
}
|
|
|
|
},
|
2019-09-04 11:26:24 +08:00
|
|
|
beforeDestory () {
|
|
|
|
window.clearTimeout(this.lightBarVanishTimerId)
|
|
|
|
},
|
2019-08-19 15:25:41 +08:00
|
|
|
methods: {
|
|
|
|
updateLightBarPosition (el) {
|
|
|
|
if (this.active) {
|
2019-09-04 11:26:24 +08:00
|
|
|
if (this.lightBarVanishTimerId) {
|
|
|
|
window.clearTimeout(this.lightBarVanishTimerId)
|
|
|
|
this.lightBarVanishTimerId = null
|
|
|
|
}
|
2019-08-19 15:25:41 +08:00
|
|
|
this.showLightBar = true
|
|
|
|
this.lightBarTop = el.offsetTop
|
|
|
|
}
|
|
|
|
},
|
2019-09-04 11:26:24 +08:00
|
|
|
hideLightBar (delay = 80) {
|
|
|
|
window.clearTimeout(this.lightBarVanishTimerId)
|
|
|
|
this.lightBarVanishTimerId = window.setTimeout(() => {
|
|
|
|
this.showLightBar = false
|
|
|
|
}, delay)
|
2019-09-06 12:11:39 +08:00
|
|
|
},
|
|
|
|
hideLightBarSync () {
|
|
|
|
this.showLightBar = false
|
2019-08-19 15:25:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|