1 line
13 KiB
JSON
1 line
13 KiB
JSON
{"ast":null,"code":"import { resolveElements, getValueTransition, getAnimationMap, animationMapKey, getComputedStyle, fillWildcards, applyPxDefaults, NativeAnimation } from 'motion-dom';\nimport { invariant, secondsToMilliseconds } from 'motion-utils';\nfunction animateElements(elementOrSelector, keyframes, options, scope) {\n const elements = resolveElements(elementOrSelector, scope);\n const numElements = elements.length;\n invariant(Boolean(numElements), \"No valid elements provided.\", \"no-valid-elements\");\n /**\n * WAAPI doesn't support interrupting animations.\n *\n * Therefore, starting animations requires a three-step process:\n * 1. Stop existing animations (write styles to DOM)\n * 2. Resolve keyframes (read styles from DOM)\n * 3. Create new animations (write styles to DOM)\n *\n * The hybrid `animate()` function uses AsyncAnimation to resolve\n * keyframes before creating new animations, which removes style\n * thrashing. Here, we have much stricter filesize constraints.\n * Therefore we do this in a synchronous way that ensures that\n * at least within `animate()` calls there is no style thrashing.\n *\n * In the motion-native-animate-mini-interrupt benchmark this\n * was 80% faster than a single loop.\n */\n const animationDefinitions = [];\n /**\n * Step 1: Build options and stop existing animations (write)\n */\n for (let i = 0; i < numElements; i++) {\n const element = elements[i];\n const elementTransition = {\n ...options\n };\n /**\n * Resolve stagger function if provided.\n */\n if (typeof elementTransition.delay === \"function\") {\n elementTransition.delay = elementTransition.delay(i, numElements);\n }\n for (const valueName in keyframes) {\n let valueKeyframes = keyframes[valueName];\n if (!Array.isArray(valueKeyframes)) {\n valueKeyframes = [valueKeyframes];\n }\n const valueOptions = {\n ...getValueTransition(elementTransition, valueName)\n };\n valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));\n valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));\n /**\n * If there's an existing animation playing on this element then stop it\n * before creating a new one.\n */\n const map = getAnimationMap(element);\n const key = animationMapKey(valueName, valueOptions.pseudoElement || \"\");\n const currentAnimation = map.get(key);\n currentAnimation && currentAnimation.stop();\n animationDefinitions.push({\n map,\n key,\n unresolvedKeyframes: valueKeyframes,\n options: {\n ...valueOptions,\n element,\n name: valueName,\n allowFlatten: !elementTransition.type && !elementTransition.ease\n }\n });\n }\n }\n /**\n * Step 2: Resolve keyframes (read)\n */\n for (let i = 0; i < animationDefinitions.length; i++) {\n const {\n unresolvedKeyframes,\n options: animationOptions\n } = animationDefinitions[i];\n const {\n element,\n name,\n pseudoElement\n } = animationOptions;\n if (!pseudoElement && unresolvedKeyframes[0] === null) {\n unresolvedKeyframes[0] = getComputedStyle(element, name);\n }\n fillWildcards(unresolvedKeyframes);\n applyPxDefaults(unresolvedKeyframes, name);\n /**\n * If we only have one keyframe, explicitly read the initial keyframe\n * from the computed style. This is to ensure consistency with WAAPI behaviour\n * for restarting animations, for instance .play() after finish, when it\n * has one vs two keyframes.\n */\n if (!pseudoElement && unresolvedKeyframes.length < 2) {\n unresolvedKeyframes.unshift(getComputedStyle(element, name));\n }\n animationOptions.keyframes = unresolvedKeyframes;\n }\n /**\n * Step 3: Create new animations (write)\n */\n const animations = [];\n for (let i = 0; i < animationDefinitions.length; i++) {\n const {\n map,\n key,\n options: animationOptions\n } = animationDefinitions[i];\n const animation = new NativeAnimation(animationOptions);\n map.set(key, animation);\n animation.finished.finally(() => map.delete(key));\n animations.push(animation);\n }\n return animations;\n}\nexport { animateElements };","map":{"version":3,"names":["resolveElements","getValueTransition","getAnimationMap","animationMapKey","getComputedStyle","fillWildcards","applyPxDefaults","NativeAnimation","invariant","secondsToMilliseconds","animateElements","elementOrSelector","keyframes","options","scope","elements","numElements","length","Boolean","animationDefinitions","i","element","elementTransition","delay","valueName","valueKeyframes","Array","isArray","valueOptions","duration","map","key","pseudoElement","currentAnimation","get","stop","push","unresolvedKeyframes","name","allowFlatten","type","ease","animationOptions","unshift","animations","animation","set","finished","finally","delete"],"sources":["/home/gnx/Desktop/ETB/ETB-FrontEnd/node_modules/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs"],"sourcesContent":["import { resolveElements, getValueTransition, getAnimationMap, animationMapKey, getComputedStyle, fillWildcards, applyPxDefaults, NativeAnimation } from 'motion-dom';\nimport { invariant, secondsToMilliseconds } from 'motion-utils';\n\nfunction animateElements(elementOrSelector, keyframes, options, scope) {\n const elements = resolveElements(elementOrSelector, scope);\n const numElements = elements.length;\n invariant(Boolean(numElements), \"No valid elements provided.\", \"no-valid-elements\");\n /**\n * WAAPI doesn't support interrupting animations.\n *\n * Therefore, starting animations requires a three-step process:\n * 1. Stop existing animations (write styles to DOM)\n * 2. Resolve keyframes (read styles from DOM)\n * 3. Create new animations (write styles to DOM)\n *\n * The hybrid `animate()` function uses AsyncAnimation to resolve\n * keyframes before creating new animations, which removes style\n * thrashing. Here, we have much stricter filesize constraints.\n * Therefore we do this in a synchronous way that ensures that\n * at least within `animate()` calls there is no style thrashing.\n *\n * In the motion-native-animate-mini-interrupt benchmark this\n * was 80% faster than a single loop.\n */\n const animationDefinitions = [];\n /**\n * Step 1: Build options and stop existing animations (write)\n */\n for (let i = 0; i < numElements; i++) {\n const element = elements[i];\n const elementTransition = { ...options };\n /**\n * Resolve stagger function if provided.\n */\n if (typeof elementTransition.delay === \"function\") {\n elementTransition.delay = elementTransition.delay(i, numElements);\n }\n for (const valueName in keyframes) {\n let valueKeyframes = keyframes[valueName];\n if (!Array.isArray(valueKeyframes)) {\n valueKeyframes = [valueKeyframes];\n }\n const valueOptions = {\n ...getValueTransition(elementTransition, valueName),\n };\n valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));\n valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));\n /**\n * If there's an existing animation playing on this element then stop it\n * before creating a new one.\n */\n const map = getAnimationMap(element);\n const key = animationMapKey(valueName, valueOptions.pseudoElement || \"\");\n const currentAnimation = map.get(key);\n currentAnimation && currentAnimation.stop();\n animationDefinitions.push({\n map,\n key,\n unresolvedKeyframes: valueKeyframes,\n options: {\n ...valueOptions,\n element,\n name: valueName,\n allowFlatten: !elementTransition.type && !elementTransition.ease,\n },\n });\n }\n }\n /**\n * Step 2: Resolve keyframes (read)\n */\n for (let i = 0; i < animationDefinitions.length; i++) {\n const { unresolvedKeyframes, options: animationOptions } = animationDefinitions[i];\n const { element, name, pseudoElement } = animationOptions;\n if (!pseudoElement && unresolvedKeyframes[0] === null) {\n unresolvedKeyframes[0] = getComputedStyle(element, name);\n }\n fillWildcards(unresolvedKeyframes);\n applyPxDefaults(unresolvedKeyframes, name);\n /**\n * If we only have one keyframe, explicitly read the initial keyframe\n * from the computed style. This is to ensure consistency with WAAPI behaviour\n * for restarting animations, for instance .play() after finish, when it\n * has one vs two keyframes.\n */\n if (!pseudoElement && unresolvedKeyframes.length < 2) {\n unresolvedKeyframes.unshift(getComputedStyle(element, name));\n }\n animationOptions.keyframes = unresolvedKeyframes;\n }\n /**\n * Step 3: Create new animations (write)\n */\n const animations = [];\n for (let i = 0; i < animationDefinitions.length; i++) {\n const { map, key, options: animationOptions } = animationDefinitions[i];\n const animation = new NativeAnimation(animationOptions);\n map.set(key, animation);\n animation.finished.finally(() => map.delete(key));\n animations.push(animation);\n }\n return animations;\n}\n\nexport { animateElements };\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,kBAAkB,EAAEC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,EAAEC,aAAa,EAAEC,eAAe,EAAEC,eAAe,QAAQ,YAAY;AACrK,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,cAAc;AAE/D,SAASC,eAAeA,CAACC,iBAAiB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACnE,MAAMC,QAAQ,GAAGf,eAAe,CAACW,iBAAiB,EAAEG,KAAK,CAAC;EAC1D,MAAME,WAAW,GAAGD,QAAQ,CAACE,MAAM;EACnCT,SAAS,CAACU,OAAO,CAACF,WAAW,CAAC,EAAE,6BAA6B,EAAE,mBAAmB,CAAC;EACnF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACI,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