feat: adjust spring scroll preset

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-09-16 23:48:52 +08:00
parent ea3c96f8f3
commit be3aa09b8e
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
1 changed files with 8 additions and 2 deletions

View File

@ -1,7 +1,13 @@
// @see https://github.com/Innei/sprightly/blob/2444dcdb789ca585337a4d241095640a524231db/src/lib/scroller.ts
import { microDampingPreset } from "@renderer/components/ui/constants/spring"
import type { Spring } from "framer-motion"
import { animateValue } from "framer-motion"
const spring: Spring = {
type: "spring",
stiffness: 1000,
damping: 250,
}
// TODO scroller lock
export const springScrollTo = (
y: number,
@ -16,7 +22,7 @@ export const springScrollTo = (
const animation = animateValue({
keyframes: [scrollTop + 1, y],
autoplay: true,
...microDampingPreset,
...spring,
onPlay() {
el.addEventListener("wheel", stopSpringScrollHandler)
el.addEventListener("touchmove", stopSpringScrollHandler)