terminal: disable auto scroll and reload on user interaction
This commit is contained in:
parent
160c006a28
commit
f290c45b9c
|
@ -33,6 +33,10 @@
|
||||||
const max = document.body.scrollHeight - window.innerHeight;
|
const max = document.body.scrollHeight - window.innerHeight;
|
||||||
let current = 0;
|
let current = 0;
|
||||||
let interval;
|
let interval;
|
||||||
|
let interacted = false;
|
||||||
|
|
||||||
|
window.addEventListener('click', () => interacted = true);
|
||||||
|
window.addEventListener('touchstart', () => interacted = true);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.scrollTo({top: 0});
|
window.scrollTo({top: 0});
|
||||||
|
@ -40,12 +44,15 @@
|
||||||
|
|
||||||
if (max > 0) {
|
if (max > 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (interacted) return;
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
|
if (interacted) return;
|
||||||
current += 1;
|
current += 1;
|
||||||
|
|
||||||
window.scrollTo({top: current});
|
window.scrollTo({top: current});
|
||||||
|
|
||||||
if (window.scrollY >= max) {
|
if (window.scrollY >= max) {
|
||||||
|
if (interacted) return;
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
@ -55,7 +62,10 @@
|
||||||
}, 5000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(window.location.reload, 120 * 1000)
|
setTimeout(() => {
|
||||||
|
if (interacted) return;
|
||||||
|
window.location.reload();
|
||||||
|
}, 120 * 1000)
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in New Issue