Skip to content

Commit

Permalink
feat: update spring scroll preset
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Sep 17, 2024
1 parent 94aa73e commit d665858
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/scroller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use client'

import type { Spring } from 'framer-motion'
import { animateValue } from 'framer-motion'

import { microDampingPreset } from '~/constants/spring'

const spring: Spring = {
type: 'spring',
stiffness: 1000,
damping: 250,
}
// TODO scroller lock
export const springScrollTo = (y: number) => {
const scrollTop =
Expand All @@ -16,7 +20,7 @@ export const springScrollTo = (y: number) => {
const animation = animateValue({
keyframes: [scrollTop + 1, y],
autoplay: true,
...microDampingPreset,
...spring,
onPlay() {
window.addEventListener('wheel', stopSpringScrollHandler)
window.addEventListener('touchmove', stopSpringScrollHandler)
Expand Down

0 comments on commit d665858

Please sign in to comment.