Hi, thank you for sharing this module, even in its current state. I expected this module to automatically load the next page when you scroll down, but I found that I have to click the "More ››" link in order to expand the view. Is that behavior by design, or am I doing something wrong?

If this functionality is desired, but just not written yet, I'll try to supply a patch.

Comments

marcvangend’s picture

Status: Active » Needs review
StatusFileSize
new1.73 KB

I didn't find anything in the code referring to such a functionality, so I concluded that it still needed to be written. It was quite easy, actually. Here is the patch.

I'm not a javascript/jQuery expert, so if there is a cleaner/better way to do this (eg. with regards to namespacing) please let me know.

A couple of possible ToDo's:
- create a setting in the Views UI to enable/disable this
- create a setting in the Views UI for the "preload margin", which controls how much content below the viewport must be preloaded
- re-initialize when the viewport is resized

I'm looking forward to your feedback.

marcvangend’s picture

Oops, I diffed those files the wrong way around. Here is the correct patch.

cerup’s picture

Thanks, i'll try to integrate and let you know how it goes.

cerup’s picture

Hi marcvangend, i'd like to add this in, but I'm not fluent enough yet in the Views UI to make it optional. If I'm able to get some help on how to make it an option in the UI, i'd love to add it in.

cerup’s picture

I've implemented the ability to select an infinite auto-load pager from the views UI, but the current code above operates where all 'ul.infinite-pager a' would be clicked and therefore all infinite pagers on a page would expand (instead of just the target one). So we need a way to find the target view prior to the first ajax call in order to work correctly.

cerup’s picture

Ok, this functionality has been added to v6.1.1. Try it out and see if it's working correctly. You'll need to set the pager to 'Infinite Auto Load pager'.

marcvangend’s picture

Thanks, I'll try to test it when I'm back at work.

fabioloool’s picture

Version: 6.x-0.x-dev » 6.x-1.1

Cool implamentation, but it seems that it load the next pages with a periodic timeout... I'd like to load the next page only when I scroll at the bottom of the page.
Anyone have this issue?

tnx.

cerup’s picture

It loads the page when it's 100 pixels (i'd have to check that number) from the bottom.

ericsko’s picture

Yes, it looks, like the position of the more link is not updated for a while, that is why it loads 3-4 more pages, until it stops. Then yo scroll down and it loads 3-4 pages again. I am trying to solve this issue, it does some real performance problems specially in ie7

Well, I solved it like this:

- I added following functions before viewsInfinitePagerClick() helper

var ajaxStarted;
$(window).ajaxStart(function() {
ajaxStarted = true;
});

$(window).ajaxSuccess(function() {
ajaxStarted = false;
});

- then I changed the condition inside the helper from:
if (relativePosition < viewsInfinitePagerViewHeight) {
- to this:
if (relativePosition < viewsInfinitePagerViewHeight && !started) {

It does the trick: Next page will not be loaded, while ajax is in progress.
Enjoy.

doublejosh’s picture

You should advertise this functionality on the project page.

I dinked around with the Endless View for a while because the automatic piece was a requirement.
Since Infinite Scroll is just Views 3, I didn't want to screw around with upgrading to an alpha views for Drupal 6.

Anyway, just a request.

Pls’s picture

#10, correct code would be:

var ajaxStarted;
$(window).ajaxStart(function() {
  ajaxStarted = true;
});

$(window).ajaxSuccess(function() {
  ajaxStarted = false;
});

if (relativePosition < viewsInfinitePagerViewHeight && !ajaxStarted) {
Pls’s picture

StatusFileSize
new0 bytes

Attached patch based on #10.

Pls’s picture

StatusFileSize
new1.06 KB

Attached patch based on #10.

openhairpinleft’s picture

Thanks a lot erisko, Pls. Works just fine, it'd take a day for me to work it out

Pls’s picture

openhairpinleft, can you change status to RTBC if you feel this is working right? Thanks.

amarbijay’s picture

StatusFileSize
new586 bytes

Hi fabiolool,
Cool implamentation, but it seems that it load the next pages with a periodic timeout... I'd like to load the next page only when I scroll at the bottom of the page.
Anyone have this issue?

I was having same problem and fixed the issue, please use the attached path file,

Or

just comment the conditions if (!viewsInfinitePagerClick()) { within below function in "views_infinite_pager.js" file,

Drupal.behaviors.viewsInfinitePagerAutoLoad = function() {

LINE: 199 //if (!viewsInfinitePagerClick()) {
// Bind scroll event.
$(window).bind('scroll', viewsInfinitePagerClick);
LINE:202 //}

amarbijay’s picture

StatusFileSize
new586 bytes

Hi,

Please let us know if it works for you