"Infinite" scroll need overworking
When the small "addon" is enabled, more content is being loaded when users scroll down. So far so good. But if they scroll more down, more is being added to the DOM document which results in a growing browser procress and a slow-down due to the device has to handle more content.
I would prefer that the content in opposite scroll direction is being removed to allow smooth usage of the device (desktop PCs with low RAM will suffer greatly). If the user changes scroll direction, again content on the opposite direction is being removed.
Roland Häder🇩🇪 likes this.
Rabuzarus
in reply to Roland Häder🇩🇪 • •Three ideas/problems come to my mind.
- it should work in both directions
- the code should be modular to make it possible to use it in the future also at other places where we need to load/add content.
- at the present time we don't have the possibility to "just remove one network page" in the DOM document.
Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Rabuzarus
in reply to Roland Häder🇩🇪 • •Yesterday I had a look at the jquery plugins you mentioned. github.com/pixelcog/parallax.j… is not about infinite scrolling. It is about to have a prallax effect. And github.com/fredwu/jquery-endle… doesn't do that much more than our implementation already do (OK it can load previous pages).
The problem isn't to load next or previous pages through ajax. That would be very simple.
The problems we would have to deal with are:
The whole topic is very complex. I think this is not something which is easy to implement. I don't want to say that it is unsolvable, I just want to highlight that this "extended" infinite scrolling is more than just adding and removing content
Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Just using a request parameter, like "page" is not helpful, then you will may see duplicate posts as "page=2" will change when new posts are being added. #GNUSocial uses here something like "lastPostId" which is the id number of the last post that has been loaded and so displayed.
Maybe I better make an example on how I think how it can be done:
1) Load page and embed "last post id" directly into page
2) Send request out: "POST /ajax/network/?lastPostId=12345&page=current"
3) This returns the posts (lastPostId - postsPerPage) that just be displayed right away including a new lastPostId
4) The user scrolls up, send another request out: "POST /ajax/network/?lastPostId=12335&page=up" (I assumed 10 posts per page and again a new lastPostId is included)
5) On any of those requests, check that more can be loaded, if not, the new lastPostId should be empty, indicating that no more can beloaded
6) Similar when the user scrolls down, then &page=down is given
Maybe not perfect but newly added posts can be found out the same way:
"POST /ajax/network/?lastPostId=12345&page=up (as newer posts are added on top)
The JavaScript then needs to handle empty lastPostId (when < postsPerPage has been found) and removing/adding content.