Upgrade Lenis smooth scroll
This commit is contained in:
@@ -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",
|
||||
|
||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user