Skip to content

Scroll up page decrement bug after nav away/back #887

@Swallowtail23

Description

@Swallowtail23
  1. Are you using the latest version of Infinite Ajax Scroll? YES
  2. Have you searched for existing issues, before creating a new one? YES

Bug report
When navigating back to a paged results URL (e.g. ?page=4) and scrolling upward, IAS loads back through results to page 1 but the page event never updates to page=1. The first page decrement appears delayed, and the URL only gets to page=2 at the very top. This only occurs after back/forward navigation to a non‑page‑1 entry point; normal scroll within the same page session works as expected.

Alternatively, same behaviour results from just navigating directly to a page (e.g. &page=6), and then scrolling up - the first decrement appears to miss.

Code and configuration snippets that reproduces the problem

<script>
$(document).ready(function () {
  let ias = new InfiniteAjaxScroll('.wrap', {
    item: '.item',
    next: '.next',
    prev: '.prev',
    pagination: '.pagination',
    negativeMargin: 250,
    spinner: {
      element: '.spinner',
      delay: 600,
      show: function(el){ el.style.opacity='1'; },
      hide: function(el){ el.style.opacity='0'; }
    }
  });

  ias.on('page', (e) => {
    history.replaceState(history.state, e.title, e.url);
  });
});
</script>

Repro steps:

Load a paged results URL, e.g. index.php?...&page=4 (infinite scroll enabled).
Scroll down 1–2 pages (IAS appends).
Click into a detail page (normal navigation).
Use browser Back to return to index.php?...&page=4.
Scroll upward to the top, letting IAS prepend earlier pages - first decrement appears to 'miss', and page 4 remains through page 3, then single decrements down to minimum page=2

Expected behavior
After page 1 has been loaded and the top is reached, the page event should update the URL to page=1

Environment

  • Infinite Ajax Scroll version: 3.1.0
  • Browser + version: Chrome 143.0.7499.170
  • Operating System: server - RHEL 9, Apache 2.4.62. Client - Win11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions