diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index c8f6326..91dba2e 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19629,7 +19629,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { window.addEventListener('scroll', () => { const loadAdditionalRowsCount = 2; // todo: make this configurable const height = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); - if (window.innerHeight + window.scrollY > height - 300) { + if (window.innerHeight + window.scrollY > height - 300 && this.renderedItems > 0) { this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.renderMovieElems(); this.calculatePositions(); @@ -19749,9 +19749,8 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.columnsCount = this.renderedItems - 1; } lastRowTop = movieElem.getBoundingClientRect().top; - if (!isScrolledIntoView(movieElem) && !this.maxRenderCount) { + if (!isScrolledIntoView(movieElem) && !this.maxRenderCount && this.renderedItems > 0) { this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * loadAdditionalRowsCount; - console.log(`Set max render this.renderedItems to ${this.maxRenderCount}`); } } } diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 7069bfd..f5ffa71 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -111,7 +111,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { document.documentElement.scrollHeight, document.documentElement.offsetHeight ); - if (window.innerHeight + window.scrollY > height - 300) { + if (window.innerHeight + window.scrollY > height - 300 && this.renderedItems > 0) { this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.renderMovieElems(); @@ -244,9 +244,8 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.columnsCount = this.renderedItems - 1; } lastRowTop = movieElem.getBoundingClientRect().top; - if (!isScrolledIntoView(movieElem) && !this.maxRenderCount) { + if (!isScrolledIntoView(movieElem) && !this.maxRenderCount && this.renderedItems > 0) { this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * loadAdditionalRowsCount; - console.log(`Set max render this.renderedItems to ${this.maxRenderCount}`); } } } else {