Add body class when dashboard is scrolled

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-08-24 14:34:43 +02:00 committed by Roeland Jago Douma
parent d4502823f4
commit fe3374d843
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 11 additions and 0 deletions

View File

@ -235,6 +235,7 @@ export default {
}, },
mounted() { mounted() {
this.updateGlobalStyles() this.updateGlobalStyles()
window.addEventListener('scroll', this.handleScroll)
setInterval(() => { setInterval(() => {
this.timer = new Date() this.timer = new Date()
@ -244,6 +245,9 @@ export default {
window.addEventListener('scroll', this.disableFirstrunHint) window.addEventListener('scroll', this.disableFirstrunHint)
} }
}, },
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
},
methods: { methods: {
/** /**
* Method to register panels that will be called by the integrating apps * Method to register panels that will be called by the integrating apps
@ -361,6 +365,13 @@ export default {
} }
this.saveStatuses() this.saveStatuses()
}, },
handleScroll() {
if (window.scrollY > 50) {
document.body.classList.add('dashboard--scrolled')
} else {
document.body.classList.remove('dashboard--scrolled')
}
},
}, },
} }
</script> </script>