【发布时间】:2023-04-10 05:02:02
【问题描述】:
我想处理滚动,因为当我向下滚动时我想滚动完整 viewport.height 和向上相同但相反的方式:
它正在使用它,但它只能用于向下滚动和一次备份(此外,它有一段时间我无法滚动,如果我在一段时间后向下和向上移动,ig 向下等待并再次向上) :
function viewport() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}
var height = viewport().height;
$(document).on('wheel', function(e) {
var delta = e.originalEvent.deltaY;
if(delta > 0) $('html, body').animate({scrollTop: height+'px'});
else $('html, body').animate({scrollTop: '-'+height+'px'});
return false;
});
body{min-height: 300vh; overflow: auto;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
【问题讨论】:
标签: javascript jquery