aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-05-08 07:43:09 +0000
committerFuwn <[email protected]>2026-05-08 07:43:09 +0000
commit46d6ac787c8e1d6d532e8dd8d0710f90c337665c (patch)
tree61c72fce740ea9070827043097c394790fc85f72
parentstyle: apply biome formatter (diff)
downloaddue.moe-46d6ac787c8e1d6d532e8dd8d0710f90c337665c.tar.xz
due.moe-46d6ac787c8e1d6d532e8dd8d0710f90c337665c.zip
feat(scroll): add global smooth scrolling via Lenis
-rw-r--r--package.json1
-rw-r--r--pnpm-lock.yaml19
-rw-r--r--src/routes/+layout.svelte7
3 files changed, 27 insertions, 0 deletions
diff --git a/package.json b/package.json
index cf138b81..c9cce24b 100644
--- a/package.json
+++ b/package.json
@@ -62,6 +62,7 @@
"fast-levenshtein": "^3.0.0",
"jsdom": "^23.0.1",
"jszip": "^3.10.1",
+ "lenis": "^1.3.23",
"localforage": "^1.10.0",
"lz-string": "^1.5.0",
"modern-screenshot": "^4.4.33",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e8e3e20a..d64ad94b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -44,6 +44,9 @@ importers:
jszip:
specifier: ^3.10.1
version: 3.10.1
+ lenis:
+ specifier: ^1.3.23
+ version: 1.3.23
localforage:
specifier: ^1.10.0
version: 1.10.0
@@ -3300,6 +3303,20 @@ packages:
resolution: {integrity: sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==}
+ resolution: {integrity: sha512-YxYq3TJqj9sJNv0V9SkyQHejt14xwyIwgDaaMK89Uf9SxQfIszu+gTQSSphh6BWlLTNVKvvXAGkg+Zf+oFIevg==}
+ peerDependencies:
+ '@nuxt/kit': '>=3.0.0'
+ react: '>=17.0.0'
+ vue: '>=3.0.0'
+ peerDependenciesMeta:
+ '@nuxt/kit':
+ optional: true
+ react:
+ optional: true
+ vue:
+ optional: true
+
resolution: {integrity: sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==}
@@ -7845,6 +7862,8 @@ snapshots:
+
dependencies:
immediate: 3.0.6
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 78e08016..7f962884 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -39,6 +39,8 @@ import { toolsAsCommandPaletteActions } from "$lib/Tools/tools";
import localforage from "localforage";
import { dev } from "$app/environment";
import { injectAnalytics } from "@vercel/analytics/sveltekit";
+import Lenis from "lenis";
+import "lenis/dist/lenis.css";
import type { LayoutData } from "./$types";
injectSpeedInsights();
@@ -50,6 +52,7 @@ let isHeaderVisible = true;
let previousScrollPosition = 0;
let notificationInterval: ReturnType<typeof setInterval> | undefined =
undefined;
+let lenis: Lenis | undefined = undefined;
addMessages("en", english as unknown as LocaleDictionary);
addMessages("ja", japanese as unknown as LocaleDictionary);
@@ -94,6 +97,8 @@ const handleScroll = () => {
onMount(async () => {
if (browser) {
+ lenis = new Lenis({ autoRaf: true });
+
if (await localforage.getItem("redirect")) {
window.location.href = (await localforage.getItem("redirect")) ?? "/";
@@ -162,6 +167,8 @@ onDestroy(() => {
if (browser) window.removeEventListener("scroll", handleScroll);
if (notificationInterval) clearInterval(notificationInterval);
+
+ lenis?.destroy();
});
$: {