mirror of
https://github.com/versia-pub/frontend.git
synced 2026-06-14 15:39:15 +02:00
chore: ⬆️ Upgrade to Nuxt 4
Some checks failed
Some checks failed
This commit is contained in:
parent
8debe97f63
commit
7f7cf20311
386 changed files with 2376 additions and 2332 deletions
26
app/components/timelines/timeline-scroller.vue
Normal file
26
app/components/timelines/timeline-scroller.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<template>
|
||||
<slot />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const root = useParentElement(useParentElement());
|
||||
// Store and keep y to restore it on page change
|
||||
const route = useRoute();
|
||||
const yStored = useLocalStorage("versia:scroll", {
|
||||
[route.fullPath]: 0,
|
||||
});
|
||||
const { y } = useScroll(root);
|
||||
|
||||
useEventListener("popstate", async () => {
|
||||
if (yStored.value[route.fullPath] !== undefined) {
|
||||
// Wait for the Vue component to load
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
y.value = yStored.value[route.fullPath] ?? 0;
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeRouteLeave(() => {
|
||||
yStored.value[route.fullPath] = y.value;
|
||||
yStored.value = { ...yStored.value };
|
||||
});
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue