I have implemented a method to hide a div while scrolling.
Here is my div:
<div v-if="this.scrollPosition < 20" class="container mt-3 serious">
<h2>This is a big title</h2>
</div>
The method I am using is as follows:
const app = new Vue({
el: '#app',
data: {
scrollPosition: null
},
methods: {
updateScroll() {
this.scrollPosition = window.scrollY
}
},
mounted() {
window.addEventListener('scroll', this.updateScroll);
}
})
I am encountering an issue where the div disappears and reappears if I scroll slowly. How can I resolve this problem?