From bdbaac382fcdd175a24f83cba4a0b21ed4747193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Fri, 11 Jun 2021 15:21:37 +0200 Subject: [PATCH] Add: Disable scrolling above details element top when opened --- dist/plex-meets-homeassistant.js | 7 +++++++ src/plex-meets-homeassistant.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index d704e3d..036283b 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -20015,6 +20015,13 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; this.loadInitialData = async () => { window.addEventListener('scroll', () => { + if (this.detailsShown && + this.activeMovieElem && + this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) { + window.scroll({ + top: getOffset(this.activeMovieElem).top - 80 + }); + } this.renderNewElementsIfNeeded(); }); window.addEventListener('resize', () => { diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 5cf5e21..03ff8ef 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -149,6 +149,15 @@ class PlexMeetsHomeAssistant extends HTMLElement { loadInitialData = async (): Promise => { window.addEventListener('scroll', () => { + if ( + this.detailsShown && + this.activeMovieElem && + this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10) + ) { + window.scroll({ + top: getOffset(this.activeMovieElem as Element).top - 80 + }); + } this.renderNewElementsIfNeeded(); }); window.addEventListener('resize', () => {