Skip to content

Unexpected page load on reload when using trigger mode #886

@Patta

Description

@Patta

Bug report

When using Infinite Ajax Scroll in trigger mode (i.e., loading the next page via a button click rather than loadOnScroll), an unexpected behavior occurs:

If a user scrolls down to the trigger button or link without activating it, and then reloads the page, the next page is automatically loaded — even though the trigger was never clicked.

This behavior contradicts the expected functionality of trigger mode, where content should only load upon explicit user interaction. It appears that the scroll position at reload is incorrectly interpreted as a trigger activation.

Steps to Reproduce:

  • Configure IAS with loadOnScroll: false and enable trigger mode.
  • Scroll down until the trigger button/link becomes visible.
  • Reload the page without clicking the trigger.
  • Observe that the next page loads automatically after reload.

Code and configuration snippets that reproduces the problem

const ias = new InfiniteAjaxScroll('.news.list', {
    logger: false,
    item: 'article',
    next: 'div.pagination a:nth-last-child(2)',
    pagination: '.news.list nav',
    negativeMargin: 200,
    spinner: {
        element: '.ias-spinner',
        show: function (element) {
            element.style.display = 'block';
        },
        hide: function (element) {
            element.style.display = 'none';
        },
    },
    trigger: {
        element: '.ias-trigger',
        show: function (element) {
            element.style.display = 'block';
        },
        hide: function (element) {
            element.style.display = 'none';
        },
    },
});

Expected behavior

The next page should only load when the user explicitly clicks the trigger button/link.

Actual Behavior: The next page loads automatically after reload if the trigger was visible before the reload.

Environment

  • Infinite Ajax Scroll version: 3.1.0
  • Browser + version: latest edge, firefox or chrome
  • Operating System: Windows 11 Pro 24H2

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