many new components, renames and yays

This commit is contained in:
2026-02-04 15:21:47 +00:00
parent 9bd2ea980a
commit 227fcadda6
10 changed files with 127 additions and 56 deletions

View File

@@ -0,0 +1,51 @@
<template>
<div ref="container" class="overflow-y-auto">
<slot />
</div>
</template>
<script setup>
import { useTemplateRef, onMounted, onBeforeUnmount } from "vue";
const container = useTemplateRef("container");
const SPEED = 1; // px per frame
const PAUSE = 2000; // ms at top/bottom
const FRAME_TIME = 50; // ms at top/bottom
let direction = 1; // 1 = down, -1 = up
let paused = false;
let rafId;
let timeoutId;
function tick() {
const el = container.value;
el.scrollTop += SPEED * direction;
const reachedBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 1;
const reachedTop = el.scrollTop <= 0;
if (reachedBottom || reachedTop) {
direction *= -1;
timeoutId = setTimeout(() => {
paused = false;
rafId = setTimeout(tick, FRAME_TIME);
}, PAUSE);
return;
}
rafId = setTimeout(tick, FRAME_TIME);
}
onMounted(() => {
rafId = setTimeout(tick, FRAME_TIME);
});
onBeforeUnmount(() => {
clearTimeout(rafId);
clearTimeout(timeoutId);
});
</script>