chore: remove lenis package

This commit is contained in:
Ilia Mashkov
2026-02-18 16:53:40 +03:00
parent 411dbfefcb
commit f356851d97
4 changed files with 1 additions and 131 deletions

View File

@@ -67,7 +67,6 @@
"vitest-browser-svelte": "^2.0.1" "vitest-browser-svelte": "^2.0.1"
}, },
"dependencies": { "dependencies": {
"@tanstack/svelte-query": "^6.0.14", "@tanstack/svelte-query": "^6.0.14"
"lenis": "^1.3.17"
} }
} }

View File

@@ -1,32 +0,0 @@
import Lenis from 'lenis';
import {
getContext,
setContext,
} from 'svelte';
const LENIS_KEY = Symbol('lenis');
export function createLenisContext() {
let lenis = $state<Lenis | null>(null);
return {
get lenis() {
return lenis;
},
setLenis(instance: Lenis) {
lenis = instance;
},
destroyLenis() {
lenis?.destroy();
lenis = null;
},
};
}
export function setLenisContext(context: ReturnType<typeof createLenisContext>) {
setContext(LENIS_KEY, context);
}
export function getLenisContext() {
return getContext<ReturnType<typeof createLenisContext>>(LENIS_KEY);
}

View File

@@ -1,78 +0,0 @@
<script lang="ts">
import {
createLenisContext,
setLenisContext,
} from '$shared/lib';
import Lenis from 'lenis';
import type { LenisOptions } from 'lenis';
import { onMount } from 'svelte';
interface Props {
children?: import('svelte').Snippet;
// Lenis options - all optional with sensible defaults
duration?: number;
easing?: (t: number) => number;
smoothWheel?: boolean;
wheelMultiplier?: number;
touchMultiplier?: number;
infinite?: boolean;
orientation?: 'vertical' | 'horizontal';
gestureOrientation?: 'vertical' | 'horizontal' | 'both';
}
let {
children,
duration = 1.2,
easing = t => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
smoothWheel = true,
wheelMultiplier = 1,
touchMultiplier = 2,
infinite = false,
orientation = 'vertical',
gestureOrientation = 'vertical',
}: Props = $props();
const lenisContext = createLenisContext();
setLenisContext(lenisContext);
onMount(() => {
const lenisOptions: LenisOptions = {
duration,
easing,
smoothWheel,
wheelMultiplier,
touchMultiplier,
infinite,
orientation,
gestureOrientation,
// Prevent jitter with virtual scroll
prevent: (node: HTMLElement) => {
// Don't smooth scroll inside elements with data-lenis-prevent
return node.hasAttribute('data-lenis-prevent');
},
};
const lenis = new Lenis(lenisOptions);
lenisContext.setLenis(lenis);
// RAF loop
function raf(time: number) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// Expose to window for debugging (only in dev)
if (import.meta.env?.DEV) {
(window as any).lenis = lenis;
}
return () => {
lenisContext.destroyLenis();
};
});
</script>
{@render children?.()}

View File

@@ -2459,7 +2459,6 @@ __metadata:
dprint: "npm:^0.50.2" dprint: "npm:^0.50.2"
jsdom: "npm:^27.4.0" jsdom: "npm:^27.4.0"
lefthook: "npm:^2.0.13" lefthook: "npm:^2.0.13"
lenis: "npm:^1.3.17"
oxlint: "npm:^1.35.0" oxlint: "npm:^1.35.0"
playwright: "npm:^1.57.0" playwright: "npm:^1.57.0"
storybook: "npm:^10.1.11" storybook: "npm:^10.1.11"
@@ -2850,24 +2849,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"lenis@npm:^1.3.17":
version: 1.3.17
resolution: "lenis@npm:1.3.17"
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
checksum: 10c0/c268da36d5711677b239c7d173bc52775276df08f86f7f89f305c4e02ba4055d8c50ea69125d16c94bb1e1999ccd95f654237d11c6647dc5fdf63aa90515fbfb
languageName: node
linkType: hard
"lightningcss-android-arm64@npm:1.30.2": "lightningcss-android-arm64@npm:1.30.2":
version: 1.30.2 version: 1.30.2
resolution: "lightningcss-android-arm64@npm:1.30.2" resolution: "lightningcss-android-arm64@npm:1.30.2"