Upgrade Lenis smooth scroll

This commit is contained in:
2022-09-09 12:26:08 +02:00
parent 77824594e7
commit 3374871f2f
3 changed files with 9 additions and 8 deletions

View File

@@ -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)
}