I have a web page with multiple full screen panels. For ascetic purposes, I am trying to make the user have to scroll a certain amount of wheel deltas for the body to animate to the next page. I have no idea what I am doing wrong over here:
page = document.body.scrollTop;
currentPage = 0;
tick = 0;
wheelBounds = 500;
wheelTimeout = null;
window.onmousewheel = function(e){
clearTimeout(wheelTimeout);
document.body.scrollTop = page;
tick += -e.wheelDelta;
wheelTimeout = window.setTimeout(function(){
tick = 0;
},100);
// document.body.scrollTop = window.innerHeight*(currentPage);
$("html,body").animate({
scrollTop: window.innerHeight*(currentPage)
});
if(tick > wheelBounds || tick <-wheelBounds){
page = document.body.scrollTop;
currentPage = tick > wheelBounds ? (currentPage+1): currentPage > 0 ?(currentPage-1): currentPage;
tick = 0;
console.log(currentPage);
}
}