Infinite Scroll hooks

I am afraid that the feature that you are requesting is not possible to implement by default. Once you refresh the page, the state is lost, therefore there is no way for the infinite scroll to know what was loaded before. And we cannot asume that if the user is on page 2, he wants to load all the previous pages just by default, because the user could also be in page 345, and that behaviour would be probably not desired.

You may be able to implement on your own a way to fetch those pages automatically when the list is not loaded in the first page if that is the behaviour you actually want.

2 Likes

Yes, but it would be much easier if your plugin expose some functions to do that, eg. fetchPrev similar to fetchNext.

Let’s say I want to add a button which will load the previous page. It should be visible only if user directly loaded other page than the first one. To do it I need to basically repeat the whole logic of your plugin, but in other direction - not fetching next, but previous page.

Within Frontity you already have the previous page, since it’s still available from when you were there.
Unless you hard refresh the page, at which point you also don’t know what the previous page was.

Using an internal pagination is actually the only solution. This way both the URI and state of each page gets stored, and even when someone would go there from an external source or hard refresh, it would still load the “current” results.

Only interesting design choice would be, how to handle scrolling upwards?

2 Likes