Skip to content

Instantly share code, notes, and snippets.

@hpawe01
hpawe01 / infinite-scroll.js
Last active March 10, 2023 06:07
Shopify Dawn Infinite Scroll for Collections (modern plain javascript)
class InfiniteScroll extends HTMLElement {
constructor() {
super();
this.productsContainerSelector = this.getAttribute('data-products-container');
this.paginationSelector = this.getAttribute('data-pagination-selector');
this.nextPageSelector = this.getAttribute('data-next-page-selector');
this.productsContainerEl = this.querySelector(this.productsContainerSelector);
this.paginationEl = this.querySelector(this.paginationSelector);
this.loadingIndicator = this.querySelector('.loading-overlay-wrapper');