I wanted to have a page that load the content only when it reached that section by scrolling, just like what pinterest website was doing.

What is the design of implementing it or are there a plugin to do that? Please help.

share|improve this question
1  
I've heard it referred to as infinite scrolling. You might want to search for tutorials on that. – Bill Aug 28 '12 at 0:43
Oh yea you are right... infinite scrolling. – Simon Aug 28 '12 at 0:59
What have you tried? This has two pieces--Figuring out when the user has reached a point on the page and loading and appending the new data. Check out the waypoints plugin if you're having trouble with the first part. – Andrew Whitaker Aug 28 '12 at 1:17

2 Answers

$(window).on( "scroll" , function() {

     var $document = $(document);
     var $window = $(this);

     if( $document.scrollTop() >= $document.height() - $window.height() - 400 ) {
         // do something
     }

 });

Where 400 is your offset from the bottom of the page. There are plugins that do this but this is some simple code to do it. I recommend using underscorejs to throttle this function because this function will fire every time the scroll top changes. So for every pixel it will trigger. Generally I throttle it to only run every 60 frames per second.

share|improve this answer

There is a Lazy Load Plugin for jQuery if you want to try that:

http://www.appelsiini.net/projects/lazyload

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.