Print scroll height during jQuery scroll animation

Can jQuery animate send scrollheight as it animates, or do I need to create a separate function, and if the latter, how will this function work?

http://jsfiddle.net/A2s9Q/

+3
source share
3 answers

You can use the scroll handler to update the label.

$(document).scroll(function(){
    $("#scrollHeight").html($(document).scrollTop());
});

http://jsfiddle.net/A2s9Q/7/

+2
source

Use setTimeout:

(function updateScrollheight(){
    if(animating){
        $('#scrollHeight').html($(document).scrollTop());
        setTimeout( updateScrollheight, 200 );
    }
})();

Here is the DEMO :

+1
source

you can use the step parameter from .animate (properties, parameters) where tihs goes into the parameters array along with your other parameters

step: function( now, fx ){$('#scrollHeight').html(now)}
+1
source

All Articles