1
我想處理滾動,當我向下滾動我要滾動全viewport.height
和高達相同的,但相反的方式:在滾動,滾動100vh向下/向上作品一旦
它正在與此,但它僅適用於工作一次向下滾動和備份一次(也有一段時間了,而我不能滾動,如果我去向下和向上一段時間後,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>