Archipelago — open-source initial import

This commit is contained in:
Archipelago
2026-08-12 10:55:50 +00:00
commit b67e1527a2
2068 changed files with 472303 additions and 0 deletions
@@ -0,0 +1,41 @@
import { onMounted, onUnmounted, type Ref } from 'vue'
const scrollPositions = new Map<string, number>()
export function useScrollMemory(key: string, elementRef: Ref<HTMLElement | null>) {
function savePosition() {
const el = elementRef.value
if (el) {
scrollPositions.set(key, el.scrollTop)
}
}
function restorePosition() {
const el = elementRef.value
if (!el) return
const saved = scrollPositions.get(key)
if (saved !== undefined) {
requestAnimationFrame(() => {
el.scrollTop = saved
})
}
}
onMounted(() => {
restorePosition()
const el = elementRef.value
if (el) {
el.addEventListener('scroll', savePosition, { passive: true })
}
})
onUnmounted(() => {
savePosition()
const el = elementRef.value
if (el) {
el.removeEventListener('scroll', savePosition)
}
})
return { savePosition, restorePosition }
}