From 0828f1c2d5746b38961945dbe9d7a41a2be42db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Fri, 21 May 2021 23:27:55 +0200 Subject: [PATCH] Add: Scroll handler --- dist/plex-meets-homeassistant.js | 6 ++++++ src/plex-meets-homeassistant.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index d31ef40..b353b09 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19624,6 +19624,12 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.previousPositions = []; this.contentBGHeight = 0; this.loadInitialData = async () => { + window.addEventListener('scroll', () => { + 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) { + console.log('scrolled'); + } + }); this.loading = true; this.renderPage(); try { diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index fd3c82c..78c54ff 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -98,6 +98,18 @@ class PlexMeetsHomeAssistant extends HTMLElement { } loadInitialData = async (): Promise => { + window.addEventListener('scroll', () => { + 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) { + console.log('scrolled'); + } + }); this.loading = true; this.renderPage(); try {