From 364aede3e92d98b1a96c13d9b2c68fe43f75bc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 22 May 2021 00:37:14 +0200 Subject: [PATCH] Fix: Progressive loading in cards --- dist/plex-meets-homeassistant.js | 4 ++-- src/plex-meets-homeassistant.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 91dba2e..9cbdbb5 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19628,8 +19628,8 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.loadInitialData = async () => { 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 && this.renderedItems > 0) { + const height = Math.max(this.content.scrollHeight, this.content.offsetHeight, this.content.clientHeight, this.content.scrollHeight, this.content.offsetHeight); + if (window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 && this.renderedItems > 0) { this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.renderMovieElems(); this.calculatePositions(); diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index f5ffa71..9662d9c 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -105,13 +105,13 @@ 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 + this.content.scrollHeight, + this.content.offsetHeight, + this.content.clientHeight, + this.content.scrollHeight, + this.content.offsetHeight ); - if (window.innerHeight + window.scrollY > height - 300 && this.renderedItems > 0) { + if (window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 && this.renderedItems > 0) { this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.renderMovieElems();