From 35e588831eb1c50dfa336520f0d4ecc4205d5c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 12 Jun 2021 21:07:09 +0200 Subject: [PATCH] Add: Disable scroll on details when not needed --- dist/plex-meets-homeassistant.js | 19 +++++++++++++------ src/plex-meets-homeassistant.ts | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 13bd535..dda11ab 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -20047,12 +20047,19 @@ class PlexMeetsHomeAssistant extends HTMLElement { top: detailTop }); } - else if (detailBottom && - window.innerHeight < detailBottom - detailTop && - this.getTop() + window.innerHeight > detailBottom) { - window.scroll({ - top: detailBottom - window.innerHeight - }); + else if (detailBottom) { + if (window.innerHeight < detailBottom - detailTop) { + if (detailBottom && this.getTop() + window.innerHeight > detailBottom) { + window.scroll({ + top: detailBottom - window.innerHeight + }); + } + } + else { + window.scroll({ + top: detailTop + }); + } } } this.renderNewElementsIfNeeded(); diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 2f19741..1a4284d 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -170,14 +170,18 @@ class PlexMeetsHomeAssistant extends HTMLElement { window.scroll({ top: detailTop }); - } else if ( - detailBottom && - window.innerHeight < detailBottom - detailTop && - this.getTop() + window.innerHeight > detailBottom - ) { - window.scroll({ - top: detailBottom - window.innerHeight - }); + } else if (detailBottom) { + if (window.innerHeight < detailBottom - detailTop) { + if (detailBottom && this.getTop() + window.innerHeight > detailBottom) { + window.scroll({ + top: detailBottom - window.innerHeight + }); + } + } else { + window.scroll({ + top: detailTop + }); + } } }