{"version":3,"file":"spring-value.mjs","sources":["../../../src/value/spring-value.ts"],"sourcesContent":["import { MotionValue, motionValue } from \".\"\nimport { spring } from \"../animation/generators/spring\"\nimport { AnyResolvedKeyframe, SpringOptions } from \"../animation/types\"\nimport { follow } from \"./utils/follow\"\nimport { isMotionValue } from \"./utils/is-motion-value\"\n\n/**\n * Create a `MotionValue` that animates to its latest value using a spring.\n * Can either be a value or track another `MotionValue`.\n *\n * ```jsx\n * const x = motionValue(0)\n * const y = springValue(x, { stiffness: 300 })\n * ```\n *\n * @param source - Initial value or MotionValue to track\n * @param options - Spring configuration options\n * @returns `MotionValue`\n *\n * @public\n */\nexport function springValue(\n source: T | MotionValue,\n options?: SpringOptions\n) {\n const value = motionValue(isMotionValue(source) ? source.get() : source)\n\n attachSpring(value, source, options)\n\n return value\n}\n\n/**\n * Attach a spring animation to a MotionValue that will animate whenever the value changes.\n *\n * @param value - The MotionValue to animate\n * @param source - Initial value or MotionValue to track\n * @param options - Spring configuration options\n * @returns Cleanup function\n *\n * @public\n */\nexport function attachSpring(\n value: MotionValue,\n source: T | MotionValue,\n options?: SpringOptions\n): VoidFunction {\n return follow(value, source, { ...options, type: spring })\n}\n"],"names":[],"mappings":";;;;;AAMA;;;;;;;;;;;;;;AAcG;AACG,SAAU,WAAW,CACvB,MAA0B,EAC1B,OAAuB,EAAA;IAEvB,MAAM,KAAK,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;AAExE,IAAA,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;AAEpC,IAAA,OAAO,KAAK;AAChB;AAEA;;;;;;;;;AASG;SACa,YAAY,CACxB,KAAqB,EACrB,MAA0B,EAC1B,OAAuB,EAAA;AAEvB,IAAA,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9D;;;;"}