Skip to main content
Topic: Infinite Scrolling Option? (Read 9403 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Infinite Scrolling Option?

I noted that Suki Breeze mod is now implementing this as an option. I wonder if this infinite scroll can be made as an option next to ordinary multiple pages button that we have? That is in message index, display, pm and all that can have multiple pages. Won't be nice or is it just a bloat which can be dealt with as a mod?

Re: Infinite Scrolling Option?

Reply #1

Thank you for the proposal. I'm not sure really, I don't really see why infinite scroll would be missed specially since people have the option to increase significant the number of posts they see per thread. But if there is interest on this, it needs an implementation that won't be pose load issues and perhaps easy switch. (just a quick thought)

Tracked: https://github.com/elkarte/Elkarte/issues/223
The best moment for testing your PR is right after you merge it. Can't miss with that one.

Re: Infinite Scrolling Option?

Reply #2

I packed emanuale's tips for this at SMF somewhere end of July this year and am wondering if this can be implemented here as a fully hook addon.

Re: Infinite Scrolling Option?

Reply #3

I don't remember the details of my trick, but thinking how it could be done, I'd say it's possible.
Actually, reading the code of Display.template.php, it looks almost like I modified it with in mind that mod... O:-)

I can give you some quick and general ideas on how I would do it (I can enter into the details in the next days).

I would hook into integrate_action_display_after and if the request is an AJAX one (i.e. index.php?topic=123.20;xml[1]), remove all the template layers and let the code do its magic.

Something like:
Code: [Select]
<?php

function infinite_scroll_integrate_action_display_after()
{
    if (isset($_REQUEST['xml']))
        Tempalte_Layers::getInstance()->removeAll();
}

Then, javascript side, require the "next page" adding the xml stuff to the url and put the returned where it should go.
It should be doable in just one go, something like:
reminder: I hate javascript and the following code is just a kind of pseudo-code that will not work in any way, you have to "write" it.
Code: [Select]
$.get(url + ';xml', function(request) {
    $('.post_wrapper').after(request);
});
actually, it may be more correct to use ;xml;api=xml, though I'm not entirely sure at the moment, this last one may require a real XML output, while the first one may allow even an html output
Bugs creator.
Features destroyer.
Template killer.

Re: Infinite Scrolling Option?

Reply #4

A bit lazy today, I'm not in the mood to package it, also because is not yet localized. O:-)

This time, instead of automatic infinite scrolling, I preferred to give the user the incumbency of clicking "load moar". :P

4 files, should be easy enough to guess where they go, and one hook:
integrate_action_display_after => Endless_Integrate::action_display_after

@ahrasis if you want to play with it feel free! ;D

Re: Infinite Scrolling Option?

Reply #5

I was about to come to this yesterday but were very sleepy. Thank you. I will try this soonest.

Re: Infinite Scrolling Option?

Reply #6

Awesome! This is working great. Will be playing with it more.

The only problem that may arise is that the load moar button is still displayed and clickable though there is no more post. If we are from page 1, when click further, it will start to call and display page two again (after the last post has been shown).

Re: Infinite Scrolling Option?

Reply #7

Oh, right... I think I put the code, but I forgot to use it... xD
Bugs creator.
Features destroyer.
Template killer.

Re: Infinite Scrolling Option?

Reply #8

I haven't visit this for quite some times though I have packaged this into a working addon package without any changes to your code @emanuele .

By the way, I am wondering whether you guys have seen this http://jscroll.com as it seems simpler to implement.

Re: Infinite Scrolling Option?

Reply #9

Cool! :D
Thanks for packing it.

About jscroll, it may be worth looking into it, though it's such a small piece of code that it may take more to understand how jscroll works. LOL
Also because reading back the code I wrote, there are some tricks specific to Elk to be taken in consideration. :(
Bugs creator.
Features destroyer.
Template killer.

Re: Infinite Scrolling Option?

Reply #10

I noted the code catches the page numbers href, but it also catches next page href, so the next page will be repeated at the end. My solution will be to hide next page for it to work properly. I can add the code in, but is it the best way to do it?

Re: Infinite Scrolling Option?

Reply #11

The Best WayTM would probably be to output some kind of css and properly track the exact page. Rely on the next url is not really a great solution, more an hack.
Though, at the moment I wouldn't know how to do it properly... I have to look at the code for a bit.
Bugs creator.
Features destroyer.
Template killer.

Re: Infinite Scrolling Option?

Reply #12

Add to mod site?

Re: Infinite Scrolling Option?

Reply #13

I will push it later on after fixing the load moar as I need to do some other things for now. For the time being, the installable package is in post #8 without the fix in it.

Re: Infinite Scrolling Option?

Reply #14

I wrote css, but I meant javascript... sorry for the confusion... O:-)
Bugs creator.
Features destroyer.
Template killer.