chore: remove lenis package
This commit is contained in:
@@ -67,7 +67,6 @@
|
||||
"vitest-browser-svelte": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/svelte-query": "^6.0.14",
|
||||
"lenis": "^1.3.17"
|
||||
"@tanstack/svelte-query": "^6.0.14"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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?.()}
|
||||
19
yarn.lock
19
yarn.lock
@@ -2459,7 +2459,6 @@ __metadata:
|
||||
dprint: "npm:^0.50.2"
|
||||
jsdom: "npm:^27.4.0"
|
||||
lefthook: "npm:^2.0.13"
|
||||
lenis: "npm:^1.3.17"
|
||||
oxlint: "npm:^1.35.0"
|
||||
playwright: "npm:^1.57.0"
|
||||
storybook: "npm:^10.1.11"
|
||||
@@ -2850,24 +2849,6 @@ __metadata:
|
||||
languageName: node
|
||||
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":
|
||||
version: 1.30.2
|
||||
resolution: "lightningcss-android-arm64@npm:1.30.2"
|
||||
|
||||
Reference in New Issue
Block a user