From d6658580877cd6d1c89d555d4f6196b9ea8ca0ab Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 16 Sep 2024 23:49:28 +0800 Subject: [PATCH] feat: update spring scroll preset Signed-off-by: Innei --- src/lib/scroller.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/scroller.ts b/src/lib/scroller.ts index 52875fc5b5..386c1ad7bd 100644 --- a/src/lib/scroller.ts +++ b/src/lib/scroller.ts @@ -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 = @@ -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)