我试图在桌面上运行滚动功能。我执行计算以根据用户的屏幕尺寸在页面上定位块。
我向四面八方看,当我调整屏幕大小重启功能时,我看不出怎么做。
methods: {
handleScroll: function() {
let hW = $(window).height();
let WW = $(window).width();
let position = $(window).scrollTop();
$(window).scroll(function() {
let scroll = $(window).scrollTop();
if (
scroll > position
&& WW >= 768
){
// thing...
console.log('down');
} else if(
scroll < position
&& WW >= 768
// thing...
){
// thing...
console.log('up')
}
position = scroll;
});
}
},
mounted () {
this.handleScroll();
}