Archived topic
Infinitescrolling and the back button
3 replies · Started by Mathieu on May 12, 2020
Hi Tom,
I've just notified that when a user scroll through a list of posts with your implementation of InfiniteScroll and press the back button, they aren't coming back where they were.
I tried to fix it with appending the URL (/page/2 , etc) on a page refresh using that code :
jQuery(document).ready(function($) {
var $maintain_navigation_infinite_scroll = $('#main article').first().parent();
$maintain_navigation_infinite_scroll.on('load.infiniteScroll', function(event, response, path) {
history.replaceState(null, '', path);
});
});
And it's better because they are coming back within the same rang of posts but I wonder if it's something you already noticed or if you have a better fix? Because my solution doesn't always work. Sometimes you press back and it goes to the bottom of the page and you also lost the opportunity to move to higher posts.
Regards,
Hi there,
It seems infinite scroll has an option for this: https://infinite-scroll.com/options.html#history
Unfortunately, the args we add in our javascript aren't filterable, so it's not possible to adjust them. I've made a note to filter these in 1.11.0 so things can be added/removed.
Thanks Tom.
Have a nice week. Stay safe.
Thank you! You too :)