show-notice
hide-notice

Thursday 15 August 2013

Detect Scroll Position (Up/Down) using jQuery


Introduction:

Below jQuery code detects whether user is scrolling up or down in the webpage.

Example:


var iScrollPos = 0;

$(window).scroll(function () {
    var iCurScrollPos = $(this).scrollTop();
    if (iCurScrollPos > iScrollPos) {
        //Scrolling Down
    } else {
       //Scrolling Up
    }
    iScrollPos = iCurScrollPos;
});

SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com