From 5b3928b03100f568e6124c84c138f8b912efd091 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 7 Dec 2023 14:27:12 +0100 Subject: [PATCH] fix ooc autoscroll --- webAO/client/appendICLog.ts | 2 +- webAO/packets/handlers/handleCT.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/webAO/client/appendICLog.ts b/webAO/client/appendICLog.ts index 307009c6..2d3564c2 100644 --- a/webAO/client/appendICLog.ts +++ b/webAO/client/appendICLog.ts @@ -49,7 +49,7 @@ export function appendICLog( clientLog.appendChild(entry); if (clientLog.scrollTop+clientLog.offsetHeight+120>clientLog.scrollHeight) - clientLog.scrollTo(0, clientLog.scrollHeight); + clientLog.scrollTo(0, clientLog.scrollHeight); setLastICMessageTime(new Date()); } \ No newline at end of file diff --git a/webAO/packets/handlers/handleCT.ts b/webAO/packets/handlers/handleCT.ts index 84329d38..f85b5aad 100644 --- a/webAO/packets/handlers/handleCT.ts +++ b/webAO/packets/handlers/handleCT.ts @@ -15,9 +15,8 @@ export const handleCT = (args: string[]) => { message = message.replace(/\n/g, "
"); oocLog.innerHTML += `${username}: ${message}
`; - if (oocLog.scrollTop > oocLog.scrollHeight - 600) { - oocLog.scrollTop = oocLog.scrollHeight; - } + if (oocLog.scrollTop+oocLog.offsetHeight+120>oocLog.scrollHeight) + oocLog.scrollTo(0, oocLog.scrollHeight); } }