javascript - How can I determine the direction of a jQuery scroll event? -


i'm looking effect:

$(window).scroll(function(event){    if (/* magic code*/ ){        // upscroll code    } else {       // downscroll code    } }); 

any ideas?

check current scrolltop vs previous scrolltop

var lastscrolltop = 0; $(window).scroll(function(event){    var st = $(this).scrolltop();    if (st > lastscrolltop){        // downscroll code    } else {       // upscroll code    }    lastscrolltop = st; }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -