From b15c226e22e57e1bd7dc0c72cde16d64553ca4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 22 May 2021 00:07:16 +0200 Subject: [PATCH] Fix: A case where when using multiple cards some would not render --- dist/plex-meets-homeassistant.js | 5 ++--- src/plex-meets-homeassistant.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) 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 {