Skip Navigation

[Resolved] Infinite scroll should adjust and respect URL as well

This thread is resolved. Here is a description of the problem and solution.

Problem:
I want infinite scrool to adjust the URL when scrolling.

Solution:
It is not possible.
https://toolset.com/forums/topic/infinite-scroll-should-adjust-and-respect-url-as-well/#post-1078320

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by adrianM-6 6 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1077200

Hello,

We have one problem with infinite scroll: the correct results are not loaded again, after coming back to the page.

* The users scrolls, let's say to page 3 and clicks the last entry
* now he uses the back function of his browsers
-> only the first page is loaded using infinite scroll:

Solution:

* contain scrolling information within the url
* after coming back: reload all scrolled elements

a little bit improved: also store the clicked element and page it was on, so this could be loaded first and all other pages lazy loaded after that.

#1078320

I understand the reasons, but this is by design, I will explain here why (and why we should not change it)

Infinite scrolling (I believe since 1.11) uses history.replaceState, since it needs to:
- Adjust the URL to the current pagination page
- Not generate history points, because it is quite difficult to compose/keep/cache the View content on the previous page.
- We could have implemented it to be using the current caching method we have in Toolset Views, but imagine:
A 100+ pages View (or more?), and dealing with the cache of 99+(or more?) infinite scrolling states, which basically containg the same data over and over.
It cannot be done this way, in infinite scroll.

We assumed (kind of what we see elsewhere on infinite scrolls) that when a user is in a page A, enters a page B with infinite scrolling and then goes back in his browser, he expects to get to page A again, not been taken to his previous scroll point (Going back in the browser may in this case take long, and it's all to be cached)

Any other effect but Infinite Scroll uses history.pushState so a new history point is generated.
Clicking back provides the "right" URL, and to apply the right View content we will use the same method we use when actually getting the current (-1) page.
Combined with our caching system, this can be done without any further server call!

Hence, we had to restrict the Infinite Scroll to this behaviour:
If a user in page A that then gest to a page with a View with manual AJAX pagination with an effect of infinite scrolling, and scrolls, clicking the back button will take him to the previous page A.
In any other pagination effect, back means, going back one page (paginated page in this case)

I hope it is clear why we cannot change this, and Please let me know if there are any doubts left

#1081109

Hello Beda,

Thank you for the clarification. I still hope that you will find an improved solution for infinite scrolling and leaving the page, as this would be really nice.

Thanks,

Adrian