0

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);
    }
}
Avi Mosseri
  • 1,258
  • 1
  • 18
  • 35
  • Can you better explain what is going wrong? Also, what browser are you doing this in? Wheel deltas can differ between browsers. [See this question](http://stackoverflow.com/q/5527601/691711) – zero298 Jan 27 '15 at 16:29
  • it keeps jolting back extremely rapidly between the first and second page on scroll. this is in chrome – Avi Mosseri Jan 27 '15 at 16:32

0 Answers0