Igor Martins
Igor Martins

Reputation: 2047

How to detect if user scroll a certain distance

How to detect if a user rolled the bar a certain distance?

I want to trigger an event when user lower the bar in 1000px. thanks.

Upvotes: 0

Views: 3872

Answers (1)

Alvaro
Alvaro

Reputation: 41605

Using the scroll event combined with scrollTop function:

//when scrolling...
$(window).scroll(function() {

    //if I scroll more than 1000px...
    if($(window).scrollTop() > 1000){
         //do whatever
    }
});

Living demo: http://jsfiddle.net/NvfBc/

Upvotes: 6

Related Questions