diff --git a/package.json b/package.json index ea47464..9a0637f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint": "eslint --ignore-path .gitignore ." }, "dependencies": { - "@studio-freight/lenis": "^0.1.18", + "@studio-freight/lenis": "^0.2.1", "dayjs": "^1.11.5", "embla-carousel": "^7.0.2", "focus-visible": "^5.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c7491e..cd94593 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ lockfileVersion: 5.4 specifiers: - '@studio-freight/lenis': ^0.1.18 + '@studio-freight/lenis': ^0.2.1 '@sveltejs/adapter-auto': ^1.0.0-next.72 '@sveltejs/adapter-node': ^1.0.0-next.89 '@sveltejs/adapter-vercel': ^1.0.0-next.73 @@ -34,7 +34,7 @@ specifiers: vite: ^3.1.0 dependencies: - '@studio-freight/lenis': 0.1.18 + '@studio-freight/lenis': 0.2.1 dayjs: 1.11.5 embla-carousel: 7.0.2 focus-visible: 5.2.0 @@ -424,8 +424,8 @@ packages: picomatch: 2.3.1 dev: true - /@studio-freight/lenis/0.1.18: - resolution: {integrity: sha512-NLlkTD+hqbg1nYSvP7NY3dZcdKrMJCvDvsoGM1xbnfsTxGr/FnB6y/0Gu6CqoIWyPnRiUrMgafSgoQVWwfwQPg==} + /@studio-freight/lenis/0.2.1: + resolution: {integrity: sha512-U0H460uh3CXqVpEHBdmKWIp1s46U8FKOoNUumvETXx2OIZAjDTCmQOFsnMOca1lc3wEg5ghUYosCjbx99SHKAg==} dependencies: tiny-emitter: 2.1.0 virtual-scroll: 2.2.1 diff --git a/src/components/SmoothScroll.svelte b/src/components/SmoothScroll.svelte index b0dfed4..85600db 100644 --- a/src/components/SmoothScroll.svelte +++ b/src/components/SmoothScroll.svelte @@ -10,15 +10,16 @@ // Setup smooth scroll if (browser) { $smoothScroll = new Lenis({ - lerp: 0.1, + duration: 1.2, + easing: (t) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t)), // https://easings.net/ smooth: true, direction: 'vertical', }) } // Lenis RAF - const update = () => { - $smoothScroll.raf() + const update = (time: number) => { + $smoothScroll.raf(time) smoothScrollRAF = requestAnimationFrame(update) }