From 31d5d12625b7961d9028e25a98f9142af4a903d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mai=20Minh=20Ho=C3=A0ng?= <135428813+Hoang130203@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:53:18 +0700 Subject: [PATCH] fix(prefill): respect loadOnScroll flag in _prefillNext to prevent auto-load in trigger mode (#886) When using trigger mode, Trigger.bind() calls ias.disableLoadOnScroll() during the BINDED event. However, prefill._prefillNext() was calling ias.next() directly without checking the loadOnScroll flag, bypassing trigger mode entirely. This caused an unwanted automatic page load on reload when: 1. The user configured trigger mode (no loadOnScroll: false explicitly) 2. The browser restored scroll position near the sentinel 3. Prefill ran and saw distance <= 0, firing next() unconditionally Fix: guard _prefillNext() with a loadOnScroll check so that when trigger mode (or any other mechanism) disables auto-loading, prefill respects it. --- src/prefill.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/prefill.js b/src/prefill.js index 292c75d4..aea6acc3 100644 --- a/src/prefill.js +++ b/src/prefill.js @@ -22,6 +22,16 @@ export default class Prefill { } _prefillNext() { + // Respect the loadOnScroll flag. When trigger mode is active, + // Trigger.bind() calls disableLoadOnScroll() during the BINDED event, + // which fires before prefill runs. Without this guard, prefill would + // call next() unconditionally and bypass trigger mode, causing an + // unexpected auto-load on reload when the scroll position is restored + // near the sentinel. See: https://github.com/webcreate/infinite-ajax-scroll/issues/886 + if (!this.ias.loadOnScroll) { + return; + } + let distance = this.ias.distance(); if (distance > 0) {