1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-09 09:19:54 +00:00

scroll bottom and top

This commit is contained in:
Laura
2025-08-23 17:43:37 +02:00
parent 3b2fbad877
commit dea725e17c
4 changed files with 29 additions and 10 deletions

View File

@@ -3,6 +3,7 @@
$messages = document.getElementById("messages"),
$chat = document.getElementById("chat"),
$message = document.getElementById("message"),
$top = document.getElementById("top"),
$bottom = document.getElementById("bottom"),
$resizeBar = document.getElementById("resize-bar"),
$attachments = document.getElementById("attachments"),
@@ -45,11 +46,8 @@
function updateScrollButton() {
const bottom = $messages.scrollHeight - ($messages.scrollTop + $messages.offsetHeight);
if (bottom >= 80) {
$bottom.classList.remove("hidden");
} else {
$bottom.classList.add("hidden");
}
$top.classList.toggle("hidden", $messages.scrollTop < 80);
$bottom.classList.toggle("hidden", bottom < 80);
}
function scroll(force = false, instant = false) {
@@ -1230,7 +1228,17 @@
});
$bottom.addEventListener("click", () => {
scroll(true);
$messages.scroll({
top: $messages.scrollHeight,
behavior: "smooth",
});
});
$top.addEventListener("click", () => {
$messages.scroll({
top: 0,
behavior: "smooth",
});
});
$resizeBar.addEventListener("mousedown", event => {