Files
ai-course/node_modules/.cache/babel-loader/a133687ca7a518b5d0cb39b31597193d96a4c19c6aead731333c14c60c0da141.json

1 line
7.4 KiB
JSON
Raw Normal View History

{"ast":null,"code":"import _objectSpread from \"/Users/apple/Documents/cursor/Web\\u8BFE\\u4EF6/AI\\u8BFE/education_web_\\u591AAgent\\u534F\\u4F5C\\u7CFB\\u7EDF/node_modules/@babel/runtime/helpers/esm/objectSpread2.js\";\nimport { motionValue } from './index.mjs';\nimport { JSAnimation } from '../animation/JSAnimation.mjs';\nimport { isMotionValue } from './utils/is-motion-value.mjs';\nimport { frame } from '../frameloop/frame.mjs';\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 = transformValue(() => x.get() * 2) // double x\n * ```\n *\n * @param transformer - A transform function. This function must be pure with no side-effects or conditional statements.\n * @returns `MotionValue`\n *\n * @public\n */\nfunction springValue(source, options) {\n const initialValue = isMotionValue(source) ? source.get() : source;\n const value = motionValue(initialValue);\n attachSpring(value, source, options);\n return value;\n}\nfunction attachSpring(value, source, options) {\n const initialValue = value.get();\n let activeAnimation = null;\n let latestValue = initialValue;\n let latestSetter;\n const unit = typeof initialValue === \"string\" ? initialValue.replace(/[\\d.-]/g, \"\") : undefined;\n const stopAnimation = () => {\n if (activeAnimation) {\n activeAnimation.stop();\n activeAnimation = null;\n }\n };\n const startAnimation = () => {\n stopAnimation();\n activeAnimation = new JSAnimation(_objectSpread(_objectSpread({\n keyframes: [asNumber(value.get()), asNumber(latestValue)],\n velocity: value.getVelocity(),\n type: \"spring\",\n restDelta: 0.001,\n restSpeed: 0.01\n }, options), {}, {\n onUpdate: latestSetter\n }));\n };\n value.attach((v, set) => {\n latestValue = v;\n latestSetter = latest => set(parseValue(latest, unit));\n frame.postRender(startAnimation);\n return value.get();\n }, stopAnimation);\n let unsubscribe = undefined;\n if (isMotionValue(source)) {\n unsubscribe = source.on(\"change\", v => value.set(parseValue(v, unit)));\n value.on(\"destroy\", unsubscribe);\n }\n return unsubscribe;\n}\nfunction parseValue(v, unit) {\n return unit ? v + unit : v;\n}\nfunction asNumber(v) {\n return typeof v === \"number\" ? v : parseFloat(v);\n}\nexport { attachSpring, springValue };","map":{"version":3,"names":["motionValue","JSAnimation","isMotionValue","frame","springValue","source","options","initialValue","get","value","attachSpring","activeAnimation","latestValue","latestSetter","unit","replace","undefined","stopAnimation","stop","startAnimation","_objectSpread","keyframes","asNumber","velocity","getVelocity","type","restDelta","restSpeed","onUpdate","attach","v","set","latest","parseValue","postRender","unsubscribe","on","parseFloat"],"sources":["/Users/apple/Documents/cursor/Web课件/AI课/education_web_多Agent协作系统/node_modules/motion-dom/dist/es/value/spring-value.mjs"],"sourcesContent":["import { motionValue } from './index.mjs';\nimport { JSAnimation } from '../animation/JSAnimation.mjs';\nimport { isMotionValue } from './utils/is-motion-value.mjs';\nimport { frame } from '../frameloop/frame.mjs';\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 = transformValue(() => x.get() * 2) // double x\n * ```\n *\n * @param transformer - A transform function. This function must be pure with no side-effects or conditional statements.\n * @returns `MotionValue`\n *\n * @public\n */\nfunction springValue(source, options) {\n const initialValue = isMotionValue(source) ? source.get() : source;\n const value = motionValue(initialValue);\n attachSpring(value, source, options);\n return value;\n}\nfunction attachSpring(value, source, options) {\n const initialValue = value.get();\n let activeAnimation = null;\n