UNPKG

framer-motion

Version:

A simple and powerful JavaScript animation library

1 lines 1.65 kB
{"version":3,"file":"use-spring.mjs","sources":["../../../src/value/use-spring.ts"],"sourcesContent":["\"use client\"\n\nimport { MotionValue, SpringOptions } from \"motion-dom\"\nimport { useFollowValue } from \"./use-follow-value\"\n\n/**\n * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.\n *\n * It can either work as a stand-alone `MotionValue` by initialising it with a value, or as a subscriber\n * to another `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useSpring(0, { stiffness: 300 })\n * const y = useSpring(x, { damping: 10 })\n * ```\n *\n * @param inputValue - `MotionValue` or number. If provided a `MotionValue`, when the input `MotionValue` changes, the created `MotionValue` will spring towards that value.\n * @param springConfig - Configuration options for the spring.\n * @returns `MotionValue`\n *\n * @public\n */\nexport function useSpring(\n source: MotionValue<string>,\n options?: SpringOptions\n): MotionValue<string>\nexport function useSpring(\n source: string,\n options?: SpringOptions\n): MotionValue<string>\nexport function useSpring(\n source: MotionValue<number>,\n options?: SpringOptions\n): MotionValue<number>\nexport function useSpring(\n source: number,\n options?: SpringOptions\n): MotionValue<number>\nexport function useSpring(\n source: MotionValue<string> | MotionValue<number> | string | number,\n options: SpringOptions = {}\n): MotionValue<string> | MotionValue<number> {\n return useFollowValue(source as any, { type: \"spring\", ...options })\n}\n"],"names":[],"mappings":";;;;AA4CI;AACJ;;"}