2
0
Fork 0

terminal: disable auto scroll and reload on user interaction

This commit is contained in:
Florian Sorg 2022-05-21 22:23:31 +02:00
parent 160c006a28
commit f290c45b9c
1 changed files with 11 additions and 1 deletions

View File

@ -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)
});
</script>
</head>