1

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.

3
  • 1
    I've heard it referred to as infinite scrolling. You might want to search for tutorials on that. Commented Aug 28, 2012 at 0:43
  • Oh yea you are right... infinite scrolling. Commented Aug 28, 2012 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. Commented Aug 28, 2012 at 1:17

2 Answers 2

3
$(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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.