1 line
10 KiB
JSON
1 line
10 KiB
JSON
|
|
{"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 { resolveVariant } from '../../render/utils/resolve-dynamic-variants.mjs';\nimport { animateTarget } from './visual-element-target.mjs';\nfunction animateVariant(visualElement, variant) {\n var _visualElement$presen;\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n const resolved = resolveVariant(visualElement, variant, options.type === \"exit\" ? (_visualElement$presen = visualElement.presenceContext) === null || _visualElement$presen === void 0 ? void 0 : _visualElement$presen.custom : undefined);\n let {\n transition = visualElement.getDefaultTransition() || {}\n } = resolved || {};\n if (options.transitionOverride) {\n transition = options.transitionOverride;\n }\n /**\n * If we have a variant, create a callback that runs it as an animation.\n * Otherwise, we resolve a Promise immediately for a composable no-op.\n */\n const getAnimation = resolved ? () => Promise.all(animateTarget(visualElement, resolved, options)) : () => Promise.resolve();\n /**\n * If we have children, create a callback that runs all their animations.\n * Otherwise, we resolve a Promise immediately for a composable no-op.\n */\n const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size ? function () {\n let forwardDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n const {\n delayChildren = 0,\n staggerChildren,\n staggerDirection\n } = transition;\n return animateChildren(visualElement, variant, delayChildren + forwardDelay, staggerChildren, staggerDirection, options);\n } : () => Promise.resolve();\n /**\n * If the transition explicitly defines a \"when\" option, we need to resolve either\n * this animation or all children animations before playing the other.\n */\n const {\n when\n } = transition;\n if (when) {\n const [first, last] = when === \"beforeChildren\" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];\n return first().then(() => last());\n } else {\n return Promise.all([getAnimation(), getChildAnimations(options.delay)]);\n }\n}\nfunction animateChildren(visualElement, variant) {\n let delayChildren = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n let staggerChildren = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n let staggerDirection = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;\n let options = arguments.length > 5 ? arguments[5] : undefined;\n const animations = [];\n const maxStaggerDuration = (visualElement.variantChildren.size - 1) * staggerChildren;\n const generateStaggerDuration = staggerDirection === 1 ? function () {\n let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n return i * staggerChildren;\n } : function () {\n let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n return maxStaggerDuration - i * staggerChildren;\n };\n Array.from(visualElement.variantChildren).sort(sortByTreeOrder).forEach((child, i) => {\n child.notify(\"AnimationStart\", variant);\n animations.push(animateVariant(child, variant, _objectSpread(_objectSpread({}, options), {}, {\n delay: delayChildren + generateStaggerDuration(i)\n })).then(() => child.notify(\"AnimationComplete\", variant)));\n });\n return Promise.all(animations);\n}\nfunction sortByTreeOrder(a, b) {\n return a.sortNodePosition(b);\n}\nexport { animateVariant, sortByTreeOrder };","map":{"version":3,"names":["resolveVariant","animateTarget","animateVariant","visualElement","variant","_visualElement$presen","options","arguments","length","undefined","resolved","type","presenceContext","custom","transition","getDefaultTransition","transitionOverride","getAnimation","Promise","al
|