Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bing image search paging - infinite scroll

When you search for images on the Bing search engine, the result is displayed like this:

http://www.bing.com/images/search?q=stack+overflow

Notice how you can keep scrolling and scrolling and there is not "normal" paging.

My question is: How do they do this? I can see there is some ajax/javascript events happening, but the code is not easy to read. I especially would like to know how they know when an "empty box" is inside the users view port.

like image 910
Espo Avatar asked Jul 02 '09 05:07

Espo


2 Answers

After some searching and reading I found this very good site:

http://www.infinite-scroll.com/

It includes downloadable WordPress and jQuery -plugins and also explains pros/cons of using "Infinite scroll/autopagerize/unpaginate/endless pages"

Sample pseudo/jQuery code to load more data when user has scrolled all the way to the bottom:

$(window).scroll(function(){
        if  ($(window).scrollTop() == $(document).height() - $(window).height()){
           loadMoreRows();
        }
});
like image 131
Espo Avatar answered Nov 11 '22 17:11

Espo


Here's an article about that technology :

Eliminate paging results by using JavaScript (ala DZone) : Using Javascript, prototype and PHP.

like image 1
Moayad Mardini Avatar answered Nov 11 '22 16:11

Moayad Mardini