以下、vuejs syntax に従って書くと...
mounted() {
window.addEventListener('scroll', this.wheelDelta)
},
data() {
return {
currentPosition: 0,
previousPosition: 0,
scrollDelta: 0
}
},
methods: {
wheelDelta() {
this.currentPosition = document.documentElement.scrollTop
if(this.currentPosition > this.previousPosition) {
this.scrollDelta = 1
} else {
this.scrollDelta = 0
}
this.previousPosition = this.currentPosition
}
参考:
https://stackoverflow.com/questions/4670834/capturing-the-scroll-down-event/46339008#46339008
https://stackoverflow.com/questions/4670834/capturing-the-scroll-down-event/46339008#46339008