infinite-scroll icon indicating copy to clipboard operation
infinite-scroll copied to clipboard

Prevent Infinite Scroll "Preload" Runaway

Open Archmonger opened this issue 4 years ago • 0 comments

Description When preloading, it is currently possible to get stuck in an infinite loop of preload. InfiniteScroll will either need to be able to detect this situations and wait it out, or have a maxPreload value.

Reproduce In order to set up the situation, put a InfiniteScroll'd masonry into an iFrame. But prior to the iFrame loading, make the iFrame have a display: none; attribute. When in this situation, the height of any "infinite-scrollers" on the page are presumably forced to 0 due to display: none, so preload will preload forever.

Can be reproduced by putting Conreq into an Organizr iframe tab, then immediately clicking on a different tab before Conreq loads.

Struggled to create a codepen for this.

Potential Resolutions

  1. Have a maxPreload value where the user can enforce a maximum amount of pages that are allowed to be preloaded.
  2. If infinite scroll container height stays 0 across the first two preloads, then InfiniteScroll should resort to polling the container and waiting for its height to become a real value.
  3. Detect if the user is in an iFrame and/or if the browser window does not have focus. Do not preload until focus is obtained.

Archmonger avatar Apr 28 '21 20:04 Archmonger