From 664aa8de3ad9e3c2841e02608a103b4b7d6d697d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 2 Oct 2021 13:48:57 +0200 Subject: [PATCH] Fix: Edge case where a second row was displayed in horizontal scroll mode --- dist/plex-meets-homeassistant.js | 11 ++++------- src/plex-meets-homeassistant.ts | 7 ++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index ff6d18a..1c9ae31 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19128,10 +19128,6 @@ const getHeight = (el) => { const height = Math.max(el.scrollHeight, el.offsetHeight, el.clientHeight, el.scrollHeight, el.offsetHeight); return height; }; -const getWidth = (el) => { - const width = Math.max(el.scrollWidth, el.offsetWidth, el.clientWidth, el.scrollWidth, el.offsetWidth); - return width; -}; const getOffset = (el) => { let x = 0; let y = 0; @@ -21989,13 +21985,14 @@ class PlexMeetsHomeAssistant extends HTMLElement { if (count > this.renderedItems) { this.contentContainer.appendChild(movieElem); if (this.useHorizontalScroll) { + const marginRight = 10; if (lodash.isEmpty(this.contentContainer.style.width)) { - this.contentContainer.style.width = `${getWidth(movieElem) + 10}px`; + this.contentContainer.style.width = `${parseFloat(movieElem.style.width) + marginRight}px`; } else { this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) + - getWidth(movieElem) + - 10.15}px`; + parseFloat(movieElem.style.width) + + marginRight}px`; } } this.renderedItems += 1; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 987081c..af9e051 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -604,12 +604,13 @@ class PlexMeetsHomeAssistant extends HTMLElement { if (count > this.renderedItems) { this.contentContainer.appendChild(movieElem); if (this.useHorizontalScroll) { + const marginRight = 10; if (_.isEmpty(this.contentContainer.style.width)) { - this.contentContainer.style.width = `${getWidth(movieElem) + 10}px`; + this.contentContainer.style.width = `${parseFloat(movieElem.style.width) + marginRight}px`; } else { this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) + - getWidth(movieElem) + - 10.15}px`; + parseFloat(movieElem.style.width) + + marginRight}px`; } }