javascript - freeze scrolling for period of time -


wanna make scroll on this link. problem can't prevent scrolling 1 sec after switching different zone. wrote some code below already, works, have couple of bugs (in example above can't scrolling while zone transition happening. in code can. need disable non-pause-transition).

working on problem while, grateful help.

var zoneheight = $('#zone1').height(); zoneheight += 10; //border   var lastscrolltop = 0; $(window).scroll(function(event){   var scrollposition = $(window).scrolltop();    disablescroll();   if (scrollposition > lastscrolltop){        // downscroll code        if(scrollposition > 0 && scrollposition < zoneheight){         window.scrollto(0, zoneheight);               }       else if(scrollposition > zoneheight && scrollposition < zoneheight * 2){         window.scrollto(0, zoneheight * 2);       }   } else {       // upscroll code        if(scrollposition < zoneheight * 2 && scrollposition > zoneheight){         window.scrollto(0, zoneheight);             }             else if(scrollposition < zoneheight && scrollposition > 0){         window.scrollto(0, 0);         }    }    settimeout(function(){enablescroll()}, 1000);   lastscrolltop = scrollposition; });   // left: 37, up: 38, right: 39, down: 40, // spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36 var keys = {37: 1, 38: 1, 39: 1, 40: 1};  function preventdefault(e) {   e = e || window.event;   if (e.preventdefault)       e.preventdefault();   e.returnvalue = false;   }  function preventdefaultforscrollkeys(e) {     if (keys[e.keycode]) {         preventdefault(e);         return false;     } }  function disablescroll() {   if (window.addeventlistener) // older ff       window.addeventlistener('dommousescroll', preventdefault, false);   window.onwheel = preventdefault; // modern standard   window.onmousewheel = document.onmousewheel = preventdefault; // older browsers, ie   window.ontouchmove  = preventdefault; // mobile   document.onkeydown  = preventdefaultforscrollkeys; }  function enablescroll() {     if (window.removeeventlistener)         window.removeeventlistener('dommousescroll', preventdefault, false);     window.onmousewheel = document.onmousewheel = null;      window.onwheel = null;      window.ontouchmove = null;       document.onkeydown = null;   } 


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -