From f290c45b9c523bcc5a51d4f7b0733116651a0be9 Mon Sep 17 00:00:00 2001 From: Florian Sorg Date: Sat, 21 May 2022 22:23:31 +0200 Subject: [PATCH] terminal: disable auto scroll and reload on user interaction --- shiftregister/signage/templates/terminal.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/shiftregister/signage/templates/terminal.html b/shiftregister/signage/templates/terminal.html index 3ca225b..66bf8b0 100644 --- a/shiftregister/signage/templates/terminal.html +++ b/shiftregister/signage/templates/terminal.html @@ -33,6 +33,10 @@ const max = document.body.scrollHeight - window.innerHeight; let current = 0; let interval; + let interacted = false; + + window.addEventListener('click', () => interacted = true); + window.addEventListener('touchstart', () => interacted = true); setTimeout(() => { window.scrollTo({top: 0}); @@ -40,12 +44,15 @@ if (max > 0) { setTimeout(() => { + if (interacted) return; interval = setInterval(() => { + if (interacted) return; current += 1; window.scrollTo({top: current}); if (window.scrollY >= max) { + if (interacted) return; clearInterval(interval); setTimeout(() => { window.location.reload(); @@ -55,7 +62,10 @@ }, 5000) } - setTimeout(window.location.reload, 120 * 1000) + setTimeout(() => { + if (interacted) return; + window.location.reload(); + }, 120 * 1000) });