Check sticky on menu close

pull/2207/head
Cagatay Civici 2022-02-24 01:04:24 +03:00
parent beccd06fb8
commit a2aface1a4
1 changed files with 12 additions and 8 deletions

View File

@ -67,6 +67,9 @@ export default {
this.unbindScrollListener(); this.unbindScrollListener();
} }
}, },
updated() {
this.checkSticky();
},
methods: { methods: {
isDarkTheme() { isDarkTheme() {
return this.$appState.darkTheme === true; return this.$appState.darkTheme === true;
@ -78,14 +81,9 @@ export default {
this.menuActive = !this.menuActive; this.menuActive = !this.menuActive;
}, },
bindScrollListener() { bindScrollListener() {
if (!this.scrollListener) { if (!this.scrollListener && this.container) {
if (this.container) {
this.scrollListener = () => { this.scrollListener = () => {
if (window.scrollY > 0) this.checkSticky();
this.container.classList.add('landing-header-sticky');
else
this.container.classList.remove('landing-header-sticky');
}
} }
} }
window.addEventListener('scroll', this.scrollListener); window.addEventListener('scroll', this.scrollListener);
@ -99,6 +97,12 @@ export default {
containerRef(el) { containerRef(el) {
this.container = el; this.container = el;
}, },
checkSticky() {
if (window.scrollY > 0)
this.container.classList.add('landing-header-sticky');
else
this.container.classList.remove('landing-header-sticky');
}
} }
} }
</script> </script>