motion-dom 14.1.1 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1205 -181
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +19 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +54 -24
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimationExtended.mjs +47 -20
- package/dist/es/animation/NativeAnimationExtended.mjs.map +1 -1
- package/dist/es/animation/interfaces/motion-value.mjs +1 -0
- package/dist/es/animation/interfaces/motion-value.mjs.map +1 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +25 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +854 -0
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -0
- package/dist/es/animation/waapi/transforms/groups.mjs +4 -0
- package/dist/es/animation/waapi/transforms/groups.mjs.map +1 -0
- package/dist/es/effects/style/index.mjs +6 -3
- package/dist/es/effects/style/index.mjs.map +1 -1
- package/dist/es/effects/style/transform.mjs +2 -7
- package/dist/es/effects/style/transform.mjs.map +1 -1
- package/dist/es/index.mjs +3 -3
- package/dist/es/projection/node/create-projection-node.mjs +10 -0
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +16 -3
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/render/dom/parse-transform.mjs +4 -2
- package/dist/es/render/dom/parse-transform.mjs.map +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +1 -1
- package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
- package/dist/es/render/svg/utils/scrape-motion-values.mjs +7 -2
- package/dist/es/render/svg/utils/scrape-motion-values.mjs.map +1 -1
- package/dist/es/render/utils/keys-transform.mjs +1 -0
- package/dist/es/render/utils/keys-transform.mjs.map +1 -1
- package/dist/es/utils/stagger.mjs +39 -6
- package/dist/es/utils/stagger.mjs.map +1 -1
- package/dist/es/value/index.mjs +12 -0
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/es/value/types/complex/index.mjs +3 -2
- package/dist/es/value/types/complex/index.mjs.map +1 -1
- package/dist/es/value/utils/follow.mjs +19 -2
- package/dist/es/value/utils/follow.mjs.map +1 -1
- package/dist/index.d.ts +84 -14
- package/dist/motion-dom.dev.js +1205 -181
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/value/index.ts"],"sourcesContent":["import {\n EasingFunction,\n SubscriptionManager,\n velocityPerSecond,\n warnOnce,\n} from \"motion-utils\"\nimport {\n AnimationPlaybackControlsWithThen,\n AnyResolvedKeyframe,\n MotionValueAnimation,\n TransformProperties,\n} from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { time } from \"../frameloop/sync-time\"\n\n/**\n * @public\n */\nexport type Subscriber<T> = (v: T) => void\n\n/**\n * @public\n */\nexport type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void\n\nexport type StartAnimation = (\n complete: () => void\n) => AnimationPlaybackControlsWithThen | undefined\n\nexport interface MotionValueEventCallbacks<V> {\n animationStart: () => void\n animationComplete: () => void\n animationCancel: () => void\n change: (latestValue: V) => void\n destroy: () => void\n}\n\n/**\n * Maximum time between the value of two frames, beyond which we\n * assume the velocity has since been 0.\n */\nconst MAX_VELOCITY_DELTA = 30\n\nconst isFloat = (value: any): value is string => {\n return !isNaN(parseFloat(value))\n}\n\ninterface ResolvedValues {\n [key: string]: AnyResolvedKeyframe\n}\n\nexport interface Owner {\n current: HTMLElement | unknown\n getProps: () => {\n onUpdate?: (latest: ResolvedValues) => void\n transformTemplate?: (\n transform: TransformProperties,\n generatedTransform: string\n ) => string\n }\n}\n\nexport interface AccelerateConfig {\n factory: (animation: AnimationPlaybackControlsWithThen) => VoidFunction\n times: number[]\n keyframes: any[]\n ease?: EasingFunction | EasingFunction[]\n duration: number\n isTransformed?: boolean\n}\n\nexport interface MotionValueOptions {\n owner?: Owner\n}\n\nexport const collectMotionValues: { current: MotionValue[] | undefined } = {\n current: undefined,\n}\n\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue<V = any> {\n /**\n * If a MotionValue has an owner, it was created internally within Motion\n * and therefore has no external listeners. It is therefore safe to animate via WAAPI.\n */\n owner?: Owner\n\n /**\n * The current state of the `MotionValue`.\n */\n private current: V | undefined\n\n /**\n * The previous state of the `MotionValue`.\n */\n private prev: V | undefined\n\n /**\n * The previous state of the `MotionValue` at the end of the previous frame.\n */\n private prevFrameValue: V | undefined\n\n /**\n * The last time the `MotionValue` was updated.\n */\n updatedAt: number\n\n /**\n * The time `prevFrameValue` was updated.\n */\n prevUpdatedAt: number | undefined\n\n /**\n * Add a passive effect to this `MotionValue`.\n *\n * A passive effect intercepts calls to `set`. For instance, `useSpring` adds\n * a passive effect that attaches a `spring` to the latest\n * set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.\n *\n * @internal\n */\n private passiveEffect?: PassiveEffect<V>\n private stopPassiveEffect?: VoidFunction\n\n /**\n * Whether the passive effect is active.\n */\n isEffectActive?: boolean\n\n /**\n * A reference to the currently-controlling animation.\n */\n animation?: MotionValueAnimation\n\n /**\n * The sole `change` subscriber. Most values have exactly one (an\n * effect or a follower), so it's stored and notified directly. A\n * SubscriptionManager is only created for a second subscriber.\n */\n private changeSubscriber?: Subscriber<V>\n\n /**\n * Tracks whether this value can output a velocity. Currently this is only true\n * if the value is numerical, but we might be able to widen the scope here and support\n * other value types.\n *\n * @internal\n */\n private canTrackVelocity: boolean | null = null\n\n /**\n * A list of MotionValues whose values are computed from this one.\n * This is a rough start to a proper signal-like dirtying system.\n */\n private dependents: Set<MotionValue> | undefined\n\n /**\n * Tracks whether this value should be removed\n */\n liveStyle?: boolean\n\n /**\n * Scroll timeline acceleration metadata. When set, VisualElement\n * can create a native WAAPI animation attached to a scroll timeline\n * instead of driving updates through JS.\n */\n accelerate?: AccelerateConfig\n\n /**\n * @param init - The initiating value\n * @param config - Optional configuration options\n *\n * - `transformer`: A function to transform incoming values with.\n */\n constructor(init: V, options: MotionValueOptions = {}) {\n this.setCurrent(init)\n this.owner = options.owner\n }\n\n setCurrent(current: V) {\n this.current = current\n this.updatedAt = time.now()\n\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current)\n }\n }\n\n setPrevFrameValue(prevFrameValue: V | undefined = this.current) {\n this.prevFrameValue = prevFrameValue\n this.prevUpdatedAt = this.updatedAt\n }\n\n /**\n * Adds a function that will be notified when the `MotionValue` is updated.\n *\n * It returns a function that, when called, will cancel the subscription.\n *\n * When calling `onChange` inside a React component, it should be wrapped with the\n * `useEffect` hook. As it returns an unsubscribe function, this should be returned\n * from the `useEffect` function to ensure you don't add duplicate subscribers..\n *\n * ```jsx\n * export const MyComponent = () => {\n * const x = useMotionValue(0)\n * const y = useMotionValue(0)\n * const opacity = useMotionValue(1)\n *\n * useEffect(() => {\n * function updateOpacity() {\n * const maxXY = Math.max(x.get(), y.get())\n * const newOpacity = transform(maxXY, [0, 100], [1, 0])\n * opacity.set(newOpacity)\n * }\n *\n * const unsubscribeX = x.on(\"change\", updateOpacity)\n * const unsubscribeY = y.on(\"change\", updateOpacity)\n *\n * return () => {\n * unsubscribeX()\n * unsubscribeY()\n * }\n * }, [])\n *\n * return <motion.div style={{ x }} />\n * }\n * ```\n *\n * @param subscriber - A function that receives the latest value.\n * @returns A function that, when called, will cancel this subscription.\n *\n * @deprecated\n */\n onChange(subscription: Subscriber<V>): () => void {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(\n false,\n `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`\n )\n }\n return this.on(\"change\", subscription)\n }\n\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n private events: {\n [key: string]: SubscriptionManager<any>\n } = {}\n\n on<EventName extends keyof MotionValueEventCallbacks<V>>(\n eventName: EventName,\n callback: MotionValueEventCallbacks<V>[EventName]\n ): VoidFunction {\n if (eventName === \"change\") return this.onChangeSubscribe(callback)\n\n return (this.events[eventName] ||= new SubscriptionManager()).add(\n callback\n )\n }\n\n private onChangeSubscribe(callback: Subscriber<V>): VoidFunction {\n const { events } = this\n\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback\n } else {\n if (!events.change) {\n events.change = new SubscriptionManager()\n events.change.add(this.changeSubscriber!)\n this.changeSubscriber = undefined\n }\n events.change.add(callback)\n }\n\n return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined\n } else {\n events.change?.remove(callback)\n }\n this.stopIfUnobserved()\n }\n }\n\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n private stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop()\n }\n })\n }\n\n clearListeners() {\n this.changeSubscriber = undefined\n for (const eventManagers in this.events) {\n this.events[eventManagers].clear()\n }\n }\n\n /**\n * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect: PassiveEffect<V>, stopPassiveEffect: VoidFunction) {\n this.passiveEffect = passiveEffect\n this.stopPassiveEffect = stopPassiveEffect\n }\n\n /**\n * Sets the state of the `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useMotionValue(0)\n * x.set(10)\n * ```\n *\n * @param latest - Latest value to set.\n * @param render - Whether to notify render subscribers. Defaults to `true`\n *\n * @public\n */\n set(v: V) {\n if (!this.passiveEffect) {\n this.updateAndNotify(v)\n } else {\n this.passiveEffect(v, this.updateAndNotify)\n }\n }\n\n setWithVelocity(prev: V, current: V, delta: number) {\n this.set(current)\n this.prev = undefined\n this.prevFrameValue = prev\n this.prevUpdatedAt = this.updatedAt - delta\n }\n\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v: V, endAnimation = true) {\n this.updateAndNotify(v)\n this.prev = v\n this.prevUpdatedAt = this.prevFrameValue = undefined\n endAnimation && this.stop()\n if (this.stopPassiveEffect) this.stopPassiveEffect()\n }\n\n dirty() {\n this.notifyChange()\n }\n\n private notifyChange() {\n const { current, changeSubscriber } = this\n /**\n * One or the other exists. Subscribing during the direct\n * subscriber's call moves it into a new manager, which must not\n * then be notified for the same change.\n */\n if (changeSubscriber) {\n changeSubscriber(current!)\n } else {\n this.events.change?.notify(current)\n }\n }\n\n addDependent(dependent: MotionValue) {\n if (!this.dependents) {\n this.dependents = new Set()\n }\n this.dependents.add(dependent)\n }\n\n removeDependent(dependent: MotionValue) {\n if (this.dependents) {\n this.dependents.delete(dependent)\n }\n }\n\n updateAndNotify = (v: V) => {\n const currentTime = time.now()\n\n /**\n * If we're updating the value during another frame or eventloop\n * than the previous frame, then the we set the previous frame value\n * to current.\n */\n if (this.updatedAt !== currentTime) {\n this.setPrevFrameValue()\n }\n\n this.prev = this.current\n\n this.setCurrent(v)\n\n // Update update subscribers\n if (this.current !== this.prev) {\n this.notifyChange()\n\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty()\n }\n }\n }\n }\n\n /**\n * Returns the latest state of `MotionValue`\n *\n * @returns - The latest state of `MotionValue`\n *\n * @public\n */\n get() {\n if (collectMotionValues.current) {\n collectMotionValues.current.push(this)\n }\n\n return this.current!\n }\n\n /**\n * @public\n */\n getPrevious() {\n return this.prev\n }\n\n /**\n * Returns the latest velocity of `MotionValue`\n *\n * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.\n *\n * @public\n */\n getVelocity() {\n const currentTime = time.now()\n\n if (\n !this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA\n ) {\n return 0\n }\n\n const delta = Math.min(\n this.updatedAt - this.prevUpdatedAt!,\n MAX_VELOCITY_DELTA\n )\n\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(\n parseFloat(this.current as any) -\n parseFloat(this.prevFrameValue as any),\n delta\n )\n }\n\n hasAnimated = false\n\n /**\n * Registers a new animation to control this `MotionValue`. Only one\n * animation can drive a `MotionValue` at one time.\n *\n * ```jsx\n * value.start()\n * ```\n *\n * @param animation - A function that starts the provided animation\n */\n start(startAnimation: StartAnimation) {\n this.stop()\n\n return new Promise<void>((resolve) => {\n this.hasAnimated = true\n\n /**\n * Complete synchronously via the callback rather than chaining a\n * second promise per animation. Guard against animations that\n * complete before startAnimation has returned.\n */\n let isComplete = false\n let animation: MotionValueAnimation | undefined\n // eslint-disable-next-line prefer-const -- read by the callback before assignment when completing synchronously\n animation = startAnimation(() => {\n isComplete = true\n this.events.animationComplete?.notify()\n if (this.animation === animation) this.clearAnimation()\n resolve()\n })\n\n if (!isComplete) this.animation = animation\n\n this.events.animationStart?.notify()\n })\n }\n\n /**\n * Stop the currently active animation.\n *\n * @public\n */\n stop() {\n if (this.animation) {\n this.animation.stop()\n if (this.events.animationCancel) {\n this.events.animationCancel.notify()\n }\n }\n this.clearAnimation()\n }\n\n /**\n * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation\n }\n\n private clearAnimation() {\n // Assign rather than delete to keep the object's shape stable\n this.animation = undefined\n }\n\n /**\n * Destroy and clean up subscribers to this `MotionValue`.\n *\n * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically\n * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually\n * created a `MotionValue` via the `motionValue` function.\n *\n * @public\n */\n destroy() {\n this.dependents?.clear()\n this.events.destroy?.notify()\n this.clearListeners()\n this.stop()\n\n if (this.stopPassiveEffect) {\n this.stopPassiveEffect()\n }\n }\n}\n\nexport function motionValue<V>(init: V, options?: MotionValueOptions) {\n return new MotionValue<V>(init, options)\n}\n"],"names":[],"mappings":";;;;AAqCA;;;AAGG;AACH,MAAM,kBAAkB,GAAG,EAAE;AAE7B,MAAM,OAAO,GAAG,CAAC,KAAU,KAAqB;IAC5C,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AA8BM,MAAM,mBAAmB,GAA2C;AACvE,IAAA,OAAO,EAAE,SAAS;;AAGtB;;;;AAIG;MACU,WAAW,CAAA;AAwFpB;;;;;AAKG;IACH,WAAA,CAAY,IAAO,EAAE,OAAA,GAA8B,EAAE,EAAA;AAjCrD;;;;;;AAMG;QACK,IAAA,CAAA,gBAAgB,GAAmB,IAAI;AA+F/C;;AAEG;QACK,IAAA,CAAA,MAAM,GAEV,EAAE;AAyIN,QAAA,IAAA,CAAA,eAAe,GAAG,CAAC,CAAI,KAAI;AACvB,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE;AAE9B;;;;AAIG;AACH,YAAA,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW,EAAE;gBAChC,IAAI,CAAC,iBAAiB,EAAE;YAC5B;AAEA,YAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO;AAExB,YAAA,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;;YAGlB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,EAAE;gBAC5B,IAAI,CAAC,YAAY,EAAE;AAEnB,gBAAA,IAAI,IAAI,CAAC,UAAU,EAAE;AACjB,oBAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;wBACrC,SAAS,CAAC,KAAK,EAAE;oBACrB;gBACJ;YACJ;AACJ,QAAA,CAAC;QAuDD,IAAA,CA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QAAA,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,iBAAiB,EAAE;QAC5B;IACJ;AACH;AAEK,SAAU,WAAW,CAAI,IAAO,EAAE,OAA4B,EAAA;AAChE,IAAA,OAAO,IAAI,WAAW,CAAI,IAAI,EAAE,OAAO,CAAC;AAC5C;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/value/index.ts"],"sourcesContent":["import {\n EasingFunction,\n SubscriptionManager,\n velocityPerSecond,\n warnOnce,\n} from \"motion-utils\"\nimport {\n AnimationPlaybackControlsWithThen,\n AnyResolvedKeyframe,\n MotionValueAnimation,\n TransformProperties,\n} from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { time } from \"../frameloop/sync-time\"\n\n/**\n * @public\n */\nexport type Subscriber<T> = (v: T) => void\n\n/**\n * @public\n */\nexport type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void\n\nexport type StartAnimation = (\n complete: () => void\n) => AnimationPlaybackControlsWithThen | undefined\n\nexport interface MotionValueEventCallbacks<V> {\n animationStart: () => void\n animationComplete: () => void\n animationCancel: () => void\n change: (latestValue: V) => void\n destroy: () => void\n}\n\n/**\n * Maximum time between the value of two frames, beyond which we\n * assume the velocity has since been 0.\n */\nconst MAX_VELOCITY_DELTA = 30\n\nconst isFloat = (value: any): value is string => {\n return !isNaN(parseFloat(value))\n}\n\ninterface ResolvedValues {\n [key: string]: AnyResolvedKeyframe\n}\n\nexport interface Owner {\n current: HTMLElement | unknown\n getProps: () => {\n onUpdate?: (latest: ResolvedValues) => void\n transformTemplate?: (\n transform: TransformProperties,\n generatedTransform: string\n ) => string\n }\n}\n\nexport interface AccelerateConfig {\n factory: (animation: AnimationPlaybackControlsWithThen) => VoidFunction\n times: number[]\n keyframes: any[]\n ease?: EasingFunction | EasingFunction[]\n duration: number\n isTransformed?: boolean\n}\n\nexport interface MotionValueOptions {\n owner?: Owner\n}\n\nexport const collectMotionValues: { current: MotionValue[] | undefined } = {\n current: undefined,\n}\n\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue<V = any> {\n /**\n * If a MotionValue has an owner, it was created internally within Motion\n * and therefore has no external listeners. It is therefore safe to animate via WAAPI.\n */\n owner?: Owner\n\n /**\n * The current state of the `MotionValue`.\n */\n private current: V | undefined\n\n /**\n * The previous state of the `MotionValue`.\n */\n private prev: V | undefined\n\n /**\n * The previous state of the `MotionValue` at the end of the previous frame.\n */\n private prevFrameValue: V | undefined\n\n /**\n * The last time the `MotionValue` was updated.\n */\n updatedAt: number\n\n /**\n * The time `prevFrameValue` was updated.\n */\n prevUpdatedAt: number | undefined\n\n /**\n * Add a passive effect to this `MotionValue`.\n *\n * A passive effect intercepts calls to `set`. For instance, `useSpring` adds\n * a passive effect that attaches a `spring` to the latest\n * set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.\n *\n * @internal\n */\n private passiveEffect?: PassiveEffect<V>\n private stopPassiveEffect?: VoidFunction\n\n /**\n * Whether the passive effect is active.\n */\n isEffectActive?: boolean\n\n /**\n * A reference to the currently-controlling animation.\n */\n animation?: MotionValueAnimation\n\n /**\n * The sole `change` subscriber. Most values have exactly one (an\n * effect or a follower), so it's stored and notified directly. A\n * SubscriptionManager is only created for a second subscriber.\n */\n private changeSubscriber?: Subscriber<V>\n\n /**\n * Tracks whether this value can output a velocity. Currently this is only true\n * if the value is numerical, but we might be able to widen the scope here and support\n * other value types.\n *\n * @internal\n */\n private canTrackVelocity: boolean | null = null\n\n /**\n * A list of MotionValues whose values are computed from this one.\n * This is a rough start to a proper signal-like dirtying system.\n */\n private dependents: Set<MotionValue> | undefined\n\n /**\n * Tracks whether this value should be removed\n */\n liveStyle?: boolean\n\n /**\n * Scroll timeline acceleration metadata. When set, VisualElement\n * can create a native WAAPI animation attached to a scroll timeline\n * instead of driving updates through JS.\n */\n accelerate?: AccelerateConfig\n\n /**\n * @param init - The initiating value\n * @param config - Optional configuration options\n *\n * - `transformer`: A function to transform incoming values with.\n */\n constructor(init: V, options: MotionValueOptions = {}) {\n this.setCurrent(init)\n this.owner = options.owner\n }\n\n setCurrent(current: V) {\n this.current = current\n this.updatedAt = time.now()\n\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current)\n }\n }\n\n setPrevFrameValue(prevFrameValue: V | undefined = this.current) {\n this.prevFrameValue = prevFrameValue\n this.prevUpdatedAt = this.updatedAt\n }\n\n /**\n * Adds a function that will be notified when the `MotionValue` is updated.\n *\n * It returns a function that, when called, will cancel the subscription.\n *\n * When calling `onChange` inside a React component, it should be wrapped with the\n * `useEffect` hook. As it returns an unsubscribe function, this should be returned\n * from the `useEffect` function to ensure you don't add duplicate subscribers..\n *\n * ```jsx\n * export const MyComponent = () => {\n * const x = useMotionValue(0)\n * const y = useMotionValue(0)\n * const opacity = useMotionValue(1)\n *\n * useEffect(() => {\n * function updateOpacity() {\n * const maxXY = Math.max(x.get(), y.get())\n * const newOpacity = transform(maxXY, [0, 100], [1, 0])\n * opacity.set(newOpacity)\n * }\n *\n * const unsubscribeX = x.on(\"change\", updateOpacity)\n * const unsubscribeY = y.on(\"change\", updateOpacity)\n *\n * return () => {\n * unsubscribeX()\n * unsubscribeY()\n * }\n * }, [])\n *\n * return <motion.div style={{ x }} />\n * }\n * ```\n *\n * @param subscriber - A function that receives the latest value.\n * @returns A function that, when called, will cancel this subscription.\n *\n * @deprecated\n */\n onChange(subscription: Subscriber<V>): () => void {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(\n false,\n `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`\n )\n }\n return this.on(\"change\", subscription)\n }\n\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n private events: {\n [key: string]: SubscriptionManager<any>\n } = {}\n\n on<EventName extends keyof MotionValueEventCallbacks<V>>(\n eventName: EventName,\n callback: MotionValueEventCallbacks<V>[EventName]\n ): VoidFunction {\n if (eventName === \"change\") return this.onChangeSubscribe(callback)\n\n return (this.events[eventName] ||= new SubscriptionManager()).add(\n callback\n )\n }\n\n private onChangeSubscribe(callback: Subscriber<V>): VoidFunction {\n const { events } = this\n\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback\n } else {\n if (!events.change) {\n events.change = new SubscriptionManager()\n events.change.add(this.changeSubscriber!)\n this.changeSubscriber = undefined\n }\n events.change.add(callback)\n }\n\n return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined\n } else {\n events.change?.remove(callback)\n }\n this.stopIfUnobserved()\n }\n }\n\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n private stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop()\n }\n })\n }\n\n clearListeners() {\n this.changeSubscriber = undefined\n for (const eventManagers in this.events) {\n this.events[eventManagers].clear()\n }\n }\n\n /**\n * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect: PassiveEffect<V>, stopPassiveEffect: VoidFunction) {\n this.passiveEffect = passiveEffect\n this.stopPassiveEffect = stopPassiveEffect\n }\n\n /**\n * Sets the state of the `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useMotionValue(0)\n * x.set(10)\n * ```\n *\n * @param latest - Latest value to set.\n * @param render - Whether to notify render subscribers. Defaults to `true`\n *\n * @public\n */\n set(v: V) {\n if (!this.passiveEffect) {\n this.updateAndNotify(v)\n } else {\n this.passiveEffect(v, this.updateAndNotify)\n }\n }\n\n setWithVelocity(prev: V, current: V, delta: number) {\n this.set(current)\n this.prev = undefined\n this.prevFrameValue = prev\n this.prevUpdatedAt = this.updatedAt - delta\n }\n\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v: V, endAnimation = true) {\n this.updateAndNotify(v)\n this.prev = v\n this.prevUpdatedAt = this.prevFrameValue = undefined\n endAnimation && this.stop()\n if (this.stopPassiveEffect) this.stopPassiveEffect()\n }\n\n dirty() {\n this.notifyChange()\n }\n\n private notifyChange() {\n const { current, changeSubscriber } = this\n /**\n * One or the other exists. Subscribing during the direct\n * subscriber's call moves it into a new manager, which must not\n * then be notified for the same change.\n */\n if (changeSubscriber) {\n changeSubscriber(current!)\n } else {\n this.events.change?.notify(current)\n }\n }\n\n addDependent(dependent: MotionValue) {\n if (!this.dependents) {\n this.dependents = new Set()\n }\n this.dependents.add(dependent)\n }\n\n removeDependent(dependent: MotionValue) {\n if (this.dependents) {\n this.dependents.delete(dependent)\n }\n }\n\n updateAndNotify = (v: V) => {\n const currentTime = time.now()\n\n /**\n * If we're updating the value during another frame or eventloop\n * than the previous frame, then the we set the previous frame value\n * to current.\n */\n if (this.updatedAt !== currentTime) {\n this.setPrevFrameValue()\n }\n\n this.prev = this.current\n\n this.setCurrent(v)\n\n // Update update subscribers\n if (this.current !== this.prev) {\n this.notifyChange()\n\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty()\n }\n }\n }\n }\n\n /**\n * Returns the latest state of `MotionValue`\n *\n * @returns - The latest state of `MotionValue`\n *\n * @public\n */\n get() {\n if (collectMotionValues.current) {\n collectMotionValues.current.push(this)\n }\n\n /**\n * A value animating on the compositor isn't updated every frame,\n * so read it from its animation.\n */\n const sampled = this.animation?.liveValue?.()\n\n return sampled === undefined ? this.current! : (sampled as V)\n }\n\n /**\n * The value as last set. Unlike get(), this doesn't read an animation\n * running on the compositor, which renders the value itself.\n */\n getCurrent() {\n return this.current!\n }\n\n /**\n * @public\n */\n getPrevious() {\n return this.prev\n }\n\n /**\n * Returns the latest velocity of `MotionValue`\n *\n * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.\n *\n * @public\n */\n getVelocity() {\n const currentTime = time.now()\n\n if (\n !this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA\n ) {\n return 0\n }\n\n const delta = Math.min(\n this.updatedAt - this.prevUpdatedAt!,\n MAX_VELOCITY_DELTA\n )\n\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(\n parseFloat(this.current as any) -\n parseFloat(this.prevFrameValue as any),\n delta\n )\n }\n\n hasAnimated = false\n\n /**\n * Registers a new animation to control this `MotionValue`. Only one\n * animation can drive a `MotionValue` at one time.\n *\n * ```jsx\n * value.start()\n * ```\n *\n * @param animation - A function that starts the provided animation\n */\n start(startAnimation: StartAnimation) {\n this.stop()\n\n return new Promise<void>((resolve) => {\n this.hasAnimated = true\n\n /**\n * Complete synchronously via the callback rather than chaining a\n * second promise per animation. Guard against animations that\n * complete before startAnimation has returned.\n */\n let isComplete = false\n let animation: MotionValueAnimation | undefined\n // eslint-disable-next-line prefer-const -- read by the callback before assignment when completing synchronously\n animation = startAnimation(() => {\n isComplete = true\n this.events.animationComplete?.notify()\n if (this.animation === animation) this.clearAnimation()\n resolve()\n })\n\n if (!isComplete) this.animation = animation\n\n this.events.animationStart?.notify()\n })\n }\n\n /**\n * Stop the currently active animation.\n *\n * @public\n */\n stop() {\n if (this.animation) {\n this.animation.stop()\n if (this.events.animationCancel) {\n this.events.animationCancel.notify()\n }\n }\n this.clearAnimation()\n }\n\n /**\n * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation\n }\n\n private clearAnimation() {\n // Assign rather than delete to keep the object's shape stable\n this.animation = undefined\n }\n\n /**\n * Destroy and clean up subscribers to this `MotionValue`.\n *\n * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically\n * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually\n * created a `MotionValue` via the `motionValue` function.\n *\n * @public\n */\n destroy() {\n this.dependents?.clear()\n this.events.destroy?.notify()\n this.clearListeners()\n this.stop()\n\n if (this.stopPassiveEffect) {\n this.stopPassiveEffect()\n }\n }\n}\n\nexport function motionValue<V>(init: V, options?: MotionValueOptions) {\n return new MotionValue<V>(init, options)\n}\n"],"names":[],"mappings":";;;;AAqCA;;;AAGG;AACH,MAAM,kBAA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B,EAAE;YACxB,IAAI,CAAC,iBAAiB,EAAE;QAC5B;IACJ;AACH;AAEK,SAAU,WAAW,CAAI,IAAO,EAAE,OAA4B,EAAA;AAChE,IAAA,OAAO,IAAI,WAAW,CAAI,IAAI,EAAE,OAAO,CAAC;AAC5C;;;;"}
|
|
@@ -19,8 +19,9 @@ const COLOR_TOKEN = "color";
|
|
|
19
19
|
const VAR_TOKEN = "var";
|
|
20
20
|
const VAR_FUNCTION_TOKEN = "var(";
|
|
21
21
|
const SPLIT_TOKEN = "${}";
|
|
22
|
-
// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex
|
|
23
|
-
|
|
22
|
+
// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex`.
|
|
23
|
+
// The lookahead skips digits in function names, like the 3 in matrix3d(.
|
|
24
|
+
const complexRegex = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?![a-z]*\()/giu;
|
|
24
25
|
/**
|
|
25
26
|
* Whether analyseComplexValue(value) would find any values, without
|
|
26
27
|
* tokenising the string. CSS variables are resolved before this is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../src/value/types/complex/index.ts"],"sourcesContent":["import { AnyResolvedKeyframe } from \"../../../animation/types\"\nimport { CSSVariableToken } from \"../../../animation/utils/is-css-variable\"\nimport { color } from \"../color\"\nimport { Color } from \"../types\"\nimport { colorRegex } from \"../utils/color-regex\"\nimport { floatRegex } from \"../utils/float-regex\"\nimport { sanitize } from \"../utils/sanitize\"\n\n/**\n * Non-global copies of the token regexes so test() can use .test()\n * (no match array, stops at the first token) without lastIndex state.\n */\nconst hasFloat = /*@__PURE__*/ new RegExp(floatRegex.source)\nconst hasColor = /*@__PURE__*/ new RegExp(colorRegex.source, \"i\")\n\nfunction test(v: any) {\n return (\n isNaN(v) &&\n typeof v === \"string\" &&\n (hasFloat.test(v) || hasColor.test(v))\n )\n}\n\nconst NUMBER_TOKEN = \"number\"\nconst COLOR_TOKEN = \"color\"\nconst VAR_TOKEN = \"var\"\nconst VAR_FUNCTION_TOKEN = \"var(\"\nconst SPLIT_TOKEN = \"${}\"\n\nexport type ComplexValues = Array<\n CSSVariableToken | AnyResolvedKeyframe | Color\n>\n\nexport interface ValueIndexes {\n color: number[]\n number: number[]\n var: number[]\n}\n\nexport interface ComplexValueInfo {\n values: ComplexValues\n split: string[]\n indexes: ValueIndexes\n types: Array<keyof ValueIndexes>\n}\n\n// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../src/value/types/complex/index.ts"],"sourcesContent":["import { AnyResolvedKeyframe } from \"../../../animation/types\"\nimport { CSSVariableToken } from \"../../../animation/utils/is-css-variable\"\nimport { color } from \"../color\"\nimport { Color } from \"../types\"\nimport { colorRegex } from \"../utils/color-regex\"\nimport { floatRegex } from \"../utils/float-regex\"\nimport { sanitize } from \"../utils/sanitize\"\n\n/**\n * Non-global copies of the token regexes so test() can use .test()\n * (no match array, stops at the first token) without lastIndex state.\n */\nconst hasFloat = /*@__PURE__*/ new RegExp(floatRegex.source)\nconst hasColor = /*@__PURE__*/ new RegExp(colorRegex.source, \"i\")\n\nfunction test(v: any) {\n return (\n isNaN(v) &&\n typeof v === \"string\" &&\n (hasFloat.test(v) || hasColor.test(v))\n )\n}\n\nconst NUMBER_TOKEN = \"number\"\nconst COLOR_TOKEN = \"color\"\nconst VAR_TOKEN = \"var\"\nconst VAR_FUNCTION_TOKEN = \"var(\"\nconst SPLIT_TOKEN = \"${}\"\n\nexport type ComplexValues = Array<\n CSSVariableToken | AnyResolvedKeyframe | Color\n>\n\nexport interface ValueIndexes {\n color: number[]\n number: number[]\n var: number[]\n}\n\nexport interface ComplexValueInfo {\n values: ComplexValues\n split: string[]\n indexes: ValueIndexes\n types: Array<keyof ValueIndexes>\n}\n\n// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex`.\n// The lookahead skips digits in function names, like the 3 in matrix3d(.\nconst complexRegex =\n /var\\s*\\(\\s*--(?:[\\w-]+\\s*|[\\w-]+\\s*,(?:\\s*[^)(\\s]|\\s*\\((?:[^)(]|\\([^)(]*\\))*\\))+\\s*)\\)|#[\\da-f]{3,8}|(?:rgb|hsl)a?\\((?:-?[\\d.]+%?[,\\s]+){2}-?[\\d.]+%?\\s*(?:[,/]\\s*)?(?:\\b\\d+(?:\\.\\d+)?|\\.\\d+)?%?\\)|-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?![a-z]*\\()/giu\n\n/**\n * Whether analyseComplexValue(value) would find any values, without\n * tokenising the string. CSS variables are resolved before this is\n * used, so it's enough to look for a number or a color.\n */\nexport function hasComplexValues(value: AnyResolvedKeyframe) {\n const asString = value.toString()\n return hasFloat.test(asString) || hasColor.test(asString)\n}\n\nexport function analyseComplexValue(\n value: AnyResolvedKeyframe\n): ComplexValueInfo {\n const originalValue = value.toString()\n\n const values: ComplexValues = []\n const indexes: ValueIndexes = {\n color: [],\n number: [],\n var: [],\n }\n const types: Array<keyof ValueIndexes> = []\n\n let i = 0\n const tokenised = originalValue.replace(complexRegex, (parsedValue) => {\n if (color.test(parsedValue)) {\n indexes.color.push(i)\n types.push(COLOR_TOKEN)\n values.push(color.parse(parsedValue))\n } else if (parsedValue.startsWith(VAR_FUNCTION_TOKEN)) {\n indexes.var.push(i)\n types.push(VAR_TOKEN)\n values.push(parsedValue)\n } else {\n indexes.number.push(i)\n types.push(NUMBER_TOKEN)\n values.push(parseFloat(parsedValue))\n }\n ++i\n return SPLIT_TOKEN\n })\n const split = tokenised.split(SPLIT_TOKEN)\n\n return { values, split, indexes, types }\n}\n\nfunction parseComplexValue(v: AnyResolvedKeyframe) {\n return analyseComplexValue(v).values\n}\n\nfunction buildTransformer({ split, types }: ComplexValueInfo) {\n const numSections = split.length\n return (v: Array<CSSVariableToken | Color | number | string>) => {\n let output = \"\"\n for (let i = 0; i < numSections; i++) {\n output += split[i]\n if (v[i] !== undefined) {\n const type = types[i]\n if (type === NUMBER_TOKEN) {\n output += sanitize(v[i] as number)\n } else if (type === COLOR_TOKEN) {\n output += color.transform(v[i] as Color)\n } else {\n output += v[i]\n }\n }\n }\n\n return output\n }\n}\n\nfunction createTransformer(source: AnyResolvedKeyframe) {\n return buildTransformer(analyseComplexValue(source))\n}\n\nconst convertNumbersToZero = (v: number | string) =>\n typeof v === \"number\" ? 0 : color.test(v) ? color.getAnimatableNone(v) : v\n\n/**\n * Convert a parsed value to its zero equivalent, but preserve numbers\n * that act as divisors in CSS calc() expressions.\n *\n * analyseComplexValue extracts numbers from CSS strings and puts the\n * surrounding text into a `split` template array. For example:\n * \"calc(var(--gap) / 5)\" → values: [var(--gap), 5]\n * split: [\"calc(\", \" / \", \")\"]\n *\n * When building a zero-equivalent for animation, naively zeroing all\n * numbers turns the divisor into 0 → \"calc(var(--gap) / 0)\" → NaN.\n * We detect this by checking whether the text preceding a number\n * (split[i]) ends with \"/\" — the CSS calc division operator.\n */\nconst convertToZero = (\n value: ComplexValues[number],\n splitBefore: string\n): ComplexValues[number] => {\n if (typeof value === \"number\") {\n return splitBefore?.trim().endsWith(\"/\") ? value : 0\n }\n return convertNumbersToZero(value as string)\n}\n\nfunction getAnimatableNone(v: AnyResolvedKeyframe) {\n const info = analyseComplexValue(v)\n const transformer = buildTransformer(info)\n return transformer(\n info.values.map((value, i) => convertToZero(value, info.split[i]))\n )\n}\n\nexport const complex = {\n test,\n parse: parseComplexValue,\n createTransformer,\n getAnimatableNone,\n}\n"],"names":[],"mappings":";;;;;AAQA;;;AAGG;AACH,MAAM,QAAQ,iBAAiB,IAAI,M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,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CACrE;AACL;AAEO,MAAM,OAAO,GAAG;IACnB,IAAI;AACJ,IAAA,KAAK,EAAE,iBAAiB;IACxB,iBAAiB;IACjB,iBAAiB;;;;;"}
|
|
@@ -69,7 +69,7 @@ function follow(value, source, options) {
|
|
|
69
69
|
}, stopAnimation);
|
|
70
70
|
if (isMotionValue(source)) {
|
|
71
71
|
let skipNextAnimation = options.skipInitialAnimation === true;
|
|
72
|
-
const
|
|
72
|
+
const onSourceChange = (v) => {
|
|
73
73
|
if (skipNextAnimation) {
|
|
74
74
|
skipNextAnimation = false;
|
|
75
75
|
value.jump(parseValue(v, unit), false);
|
|
@@ -77,11 +77,28 @@ function follow(value, source, options) {
|
|
|
77
77
|
else {
|
|
78
78
|
value.set(parseValue(v, unit));
|
|
79
79
|
}
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
|
+
const removeSourceOnChange = source.on("change", onSourceChange);
|
|
82
|
+
/**
|
|
83
|
+
* Catch up on a change made before we subscribed, for instance
|
|
84
|
+
* between a React render reading the source and the effect
|
|
85
|
+
* attaching to it. Subtracting is falsy for equal or non-numeric
|
|
86
|
+
* (NaN) values.
|
|
87
|
+
*/
|
|
88
|
+
const latest = source.get();
|
|
89
|
+
if (asNumber(latest) - asNumber(value.get()))
|
|
90
|
+
onSourceChange(latest);
|
|
81
91
|
const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
|
|
92
|
+
/**
|
|
93
|
+
* Stop our animation on detach, otherwise a re-attach (new
|
|
94
|
+
* options, Strict Mode) starts a second animation that fights
|
|
95
|
+
* this orphaned one. The catch-up above resumes from the
|
|
96
|
+
* current value and velocity.
|
|
97
|
+
*/
|
|
82
98
|
return () => {
|
|
83
99
|
removeSourceOnChange();
|
|
84
100
|
removeValueOnDestroy();
|
|
101
|
+
stopAnimation();
|
|
85
102
|
};
|
|
86
103
|
}
|
|
87
104
|
return stopAnimation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follow.mjs","sources":["../../../../src/value/utils/follow.ts"],"sourcesContent":["import type { MotionValue } from \"..\"\nimport { FollowAnimation } from \"../../animation/FollowAnimation\"\nimport type {\n AnyResolvedKeyframe,\n GeneratorFactory,\n ValueAnimationOptions,\n} from \"../../animation/types\"\nimport type { FollowValueOptions } from \"../follow-value\"\nimport { asNumber } from \"./as-number\"\nimport { isMotionValue } from \"./is-motion-value\"\n\nexport type FollowOptions = FollowValueOptions & { type: GeneratorFactory }\n\n/**\n * Animate `value` to its latest value with the generator in\n * `options.type`, tracking `source` if it's a `MotionValue`. Takes a\n * generator rather than a type name, so spring-only callers don't\n * bundle every generator.\n */\nexport function follow<T extends AnyResolvedKeyframe>(\n value: MotionValue<T>,\n source: T | MotionValue<T>,\n options: FollowOptions\n): VoidFunction {\n const initialValue = value.get()\n\n let activeAnimation: FollowAnimation | null = null\n let set: (v: T) => void\n\n const unit =\n typeof initialValue === \"string\"\n ? initialValue.replace(/[\\d.-]/g, \"\")\n : undefined\n\n const onUpdate = (v: number) => set((unit ? v + unit : v) as T)\n\n const onPlay = () => value[\"events\"].animationStart?.notify()\n\n const stopAnimation = () => {\n if (activeAnimation) {\n activeAnimation.stop()\n activeAnimation = null\n }\n value.animation = undefined\n }\n\n value.attach((v, safeSet) => {\n set = safeSet\n const target = asNumber(v)\n\n if (activeAnimation?.state === \"running\") {\n /**\n * Steer the running animation rather than replacing it. This\n * keeps its completion promise and uses its analytical velocity\n * for accuracy, preventing systematic velocity loss at high\n * frame rates (240hz+).\n */\n activeAnimation.setTarget(target, options.velocity)\n return\n }\n\n const current = asNumber(value.get())\n const velocity = activeAnimation\n ? activeAnimation.getGeneratorVelocity()\n : value.getVelocity()\n\n stopAnimation()\n\n // Don't animate if we're already at the target\n if (current === target) return\n\n const animationOptions: ValueAnimationOptions<number> = {\n keyframes: [current, target],\n velocity,\n restDelta: 0.001,\n restSpeed: 0.01,\n ...options,\n onUpdate,\n }\n\n const animation = (activeAnimation = new FollowAnimation({\n ...animationOptions,\n onPlay,\n }))\n\n value.animation = animation\n\n animation.then(() => {\n // Ignore if this animation has since been replaced\n if (activeAnimation !== animation) return\n activeAnimation = null\n value.animation = undefined\n value[\"events\"].animationComplete?.notify()\n })\n }, stopAnimation)\n\n if (isMotionValue(source)) {\n let skipNextAnimation = options.skipInitialAnimation === true\n\n const
|
|
1
|
+
{"version":3,"file":"follow.mjs","sources":["../../../../src/value/utils/follow.ts"],"sourcesContent":["import type { MotionValue } from \"..\"\nimport { FollowAnimation } from \"../../animation/FollowAnimation\"\nimport type {\n AnyResolvedKeyframe,\n GeneratorFactory,\n ValueAnimationOptions,\n} from \"../../animation/types\"\nimport type { FollowValueOptions } from \"../follow-value\"\nimport { asNumber } from \"./as-number\"\nimport { isMotionValue } from \"./is-motion-value\"\n\nexport type FollowOptions = FollowValueOptions & { type: GeneratorFactory }\n\n/**\n * Animate `value` to its latest value with the generator in\n * `options.type`, tracking `source` if it's a `MotionValue`. Takes a\n * generator rather than a type name, so spring-only callers don't\n * bundle every generator.\n */\nexport function follow<T extends AnyResolvedKeyframe>(\n value: MotionValue<T>,\n source: T | MotionValue<T>,\n options: FollowOptions\n): VoidFunction {\n const initialValue = value.get()\n\n let activeAnimation: FollowAnimation | null = null\n let set: (v: T) => void\n\n const unit =\n typeof initialValue === \"string\"\n ? initialValue.replace(/[\\d.-]/g, \"\")\n : undefined\n\n const onUpdate = (v: number) => set((unit ? v + unit : v) as T)\n\n const onPlay = () => value[\"events\"].animationStart?.notify()\n\n const stopAnimation = () => {\n if (activeAnimation) {\n activeAnimation.stop()\n activeAnimation = null\n }\n value.animation = undefined\n }\n\n value.attach((v, safeSet) => {\n set = safeSet\n const target = asNumber(v)\n\n if (activeAnimation?.state === \"running\") {\n /**\n * Steer the running animation rather than replacing it. This\n * keeps its completion promise and uses its analytical velocity\n * for accuracy, preventing systematic velocity loss at high\n * frame rates (240hz+).\n */\n activeAnimation.setTarget(target, options.velocity)\n return\n }\n\n const current = asNumber(value.get())\n const velocity = activeAnimation\n ? activeAnimation.getGeneratorVelocity()\n : value.getVelocity()\n\n stopAnimation()\n\n // Don't animate if we're already at the target\n if (current === target) return\n\n const animationOptions: ValueAnimationOptions<number> = {\n keyframes: [current, target],\n velocity,\n restDelta: 0.001,\n restSpeed: 0.01,\n ...options,\n onUpdate,\n }\n\n const animation = (activeAnimation = new FollowAnimation({\n ...animationOptions,\n onPlay,\n }))\n\n value.animation = animation\n\n animation.then(() => {\n // Ignore if this animation has since been replaced\n if (activeAnimation !== animation) return\n activeAnimation = null\n value.animation = undefined\n value[\"events\"].animationComplete?.notify()\n })\n }, stopAnimation)\n\n if (isMotionValue(source)) {\n let skipNextAnimation = options.skipInitialAnimation === true\n\n const onSourceChange = (v: T) => {\n if (skipNextAnimation) {\n skipNextAnimation = false\n value.jump(parseValue(v, unit) as T, false)\n } else {\n value.set(parseValue(v, unit) as T)\n }\n }\n\n const removeSourceOnChange = source.on(\"change\", onSourceChange)\n\n /**\n * Catch up on a change made before we subscribed, for instance\n * between a React render reading the source and the effect\n * attaching to it. Subtracting is falsy for equal or non-numeric\n * (NaN) values.\n */\n const latest = source.get()\n if (asNumber(latest) - asNumber(value.get())) onSourceChange(latest)\n\n const removeValueOnDestroy = value.on(\"destroy\", removeSourceOnChange)\n\n /**\n * Stop our animation on detach, otherwise a re-attach (new\n * options, Strict Mode) starts a second animation that fights\n * this orphaned one. The catch-up above resumes from the\n * current value and velocity.\n */\n return () => {\n removeSourceOnChange()\n removeValueOnDestroy()\n stopAnimation()\n }\n }\n\n return stopAnimation\n}\n\nfunction parseValue(v: AnyResolvedKeyframe, unit?: string) {\n return unit ? v + unit : v\n}\n"],"names":[],"mappings":";;;;AAaA;;;;;AAKG;SACa,MAAM,CAClB,KAAqB,EACrB,MAA0B,EAC1B,OAAsB,EAAA;AAEtB,IAAA,MAAM,YAAY,GAAG,KAAK,C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EtE;;;;;AAKG;AACH,QAAA,OAAO,MAAK;AACR,YAAA,oBAAoB,EAAE;AACtB,YAAA,oBAAoB,EAAE;AACtB,YAAA,aAAa,EAAE;AACnB,QAAA,CAAC;IACL;AAEA,IAAA,OAAO,aAAa;AACxB;AAEA,SAAS,UAAU,CAAC,CAAsB,EAAE,IAAa,EAAA;IACrD,OAAO,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC;AAC9B;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1935,7 +1935,13 @@ type AnimationPlaybackControlsWithThen = AnimationPlaybackControls & {
|
|
|
1935
1935
|
* full `AnimationPlaybackControls`; followers (`springValue`,
|
|
1936
1936
|
* `followValue`) only implement these.
|
|
1937
1937
|
*/
|
|
1938
|
-
type MotionValueAnimation = Pick<AnimationPlaybackControlsWithThen, "state" | "stop" | "finished" | "then"
|
|
1938
|
+
type MotionValueAnimation = Pick<AnimationPlaybackControlsWithThen, "state" | "stop" | "finished" | "then"> & {
|
|
1939
|
+
/**
|
|
1940
|
+
* The value now, if the animation is running somewhere other than
|
|
1941
|
+
* the main thread and so isn't setting it every frame.
|
|
1942
|
+
*/
|
|
1943
|
+
liveValue?: () => AnyResolvedKeyframe | undefined;
|
|
1944
|
+
};
|
|
1939
1945
|
interface AnimationState<V> {
|
|
1940
1946
|
value: V;
|
|
1941
1947
|
done: boolean;
|
|
@@ -1963,6 +1969,11 @@ interface ValueAnimationOptions<V extends AnyResolvedKeyframe = number> extends
|
|
|
1963
1969
|
isHandoff?: boolean;
|
|
1964
1970
|
allowFlatten?: boolean;
|
|
1965
1971
|
finalKeyframe?: V;
|
|
1972
|
+
/**
|
|
1973
|
+
* Whether the transition has its own onUpdate, which needs the value
|
|
1974
|
+
* every frame.
|
|
1975
|
+
*/
|
|
1976
|
+
hasOnUpdate?: boolean;
|
|
1966
1977
|
}
|
|
1967
1978
|
type GeneratorFactoryFunction = (options: ValueAnimationOptions<any>) => KeyframeGenerator<any>;
|
|
1968
1979
|
interface GeneratorFactory extends GeneratorFactoryFunction {
|
|
@@ -2620,7 +2631,12 @@ declare class MotionValue<V = any> {
|
|
|
2620
2631
|
*
|
|
2621
2632
|
* @public
|
|
2622
2633
|
*/
|
|
2623
|
-
get():
|
|
2634
|
+
get(): V;
|
|
2635
|
+
/**
|
|
2636
|
+
* The value as last set. Unlike get(), this doesn't read an animation
|
|
2637
|
+
* running on the compositor, which renders the value itself.
|
|
2638
|
+
*/
|
|
2639
|
+
getCurrent(): NonNullable<V>;
|
|
2624
2640
|
/**
|
|
2625
2641
|
* @public
|
|
2626
2642
|
*/
|
|
@@ -2742,6 +2758,10 @@ declare class AsyncMotionValueAnimation<T extends AnyResolvedKeyframe> extends W
|
|
|
2742
2758
|
onKeyframesResolved(keyframes: ResolvedKeyframes<T>, finalKeyframe: T, options: ResolvedOptions<T>, sync: boolean): void;
|
|
2743
2759
|
get finished(): Promise<any>;
|
|
2744
2760
|
then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
|
|
2761
|
+
/**
|
|
2762
|
+
* The value now, if the animation runs on the compositor.
|
|
2763
|
+
*/
|
|
2764
|
+
liveValue(): T | undefined;
|
|
2745
2765
|
get animation(): AnimationPlaybackControls;
|
|
2746
2766
|
get duration(): number;
|
|
2747
2767
|
get iterationDuration(): number;
|
|
@@ -2794,6 +2814,7 @@ declare class GroupAnimationWithThen extends GroupAnimation implements Animation
|
|
|
2794
2814
|
then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
|
|
2795
2815
|
}
|
|
2796
2816
|
|
|
2817
|
+
declare const round: (value: number) => number;
|
|
2797
2818
|
declare class JSAnimation<T extends number | string> extends WithPromise implements AnimationPlaybackControlsWithThen {
|
|
2798
2819
|
state: AnimationPlayState;
|
|
2799
2820
|
startTime: number | null;
|
|
@@ -2801,17 +2822,17 @@ declare class JSAnimation<T extends number | string> extends WithPromise impleme
|
|
|
2801
2822
|
* The driver that's controlling the animation loop. Normally this is a requestAnimationFrame loop
|
|
2802
2823
|
* but in tests we can pass in a synchronous loop.
|
|
2803
2824
|
*/
|
|
2804
|
-
|
|
2805
|
-
|
|
2825
|
+
protected driver?: DriverControls;
|
|
2826
|
+
protected isStopped: boolean;
|
|
2806
2827
|
/**
|
|
2807
2828
|
* The start time this animation picked for itself, until its first tick.
|
|
2808
2829
|
*/
|
|
2809
2830
|
private pendingStartTime?;
|
|
2810
2831
|
private generator;
|
|
2811
2832
|
private calculatedDuration;
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2833
|
+
protected resolvedDuration: number;
|
|
2834
|
+
protected totalDuration: number;
|
|
2835
|
+
protected options: ValueAnimationOptions<T>;
|
|
2815
2836
|
/**
|
|
2816
2837
|
* The current time of the animation.
|
|
2817
2838
|
*/
|
|
@@ -2819,7 +2840,7 @@ declare class JSAnimation<T extends number | string> extends WithPromise impleme
|
|
|
2819
2840
|
/**
|
|
2820
2841
|
* The time at which the animation was paused.
|
|
2821
2842
|
*/
|
|
2822
|
-
|
|
2843
|
+
protected holdTime: number | null;
|
|
2823
2844
|
/**
|
|
2824
2845
|
* Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
|
|
2825
2846
|
*/
|
|
@@ -2835,6 +2856,21 @@ declare class JSAnimation<T extends number | string> extends WithPromise impleme
|
|
|
2835
2856
|
initAnimation(): void;
|
|
2836
2857
|
updateTime(timestamp: number): void;
|
|
2837
2858
|
tick(timestamp: number, sample?: boolean): AnimationState<T>;
|
|
2859
|
+
/**
|
|
2860
|
+
* This animation's time, including delay, at a timestamp.
|
|
2861
|
+
*/
|
|
2862
|
+
at(timestamp: number): number;
|
|
2863
|
+
/**
|
|
2864
|
+
* The value at a timestamp, without changing this animation's state.
|
|
2865
|
+
* If resolved, it ends at the last resolved keyframe, which is in the
|
|
2866
|
+
* same unit as the others, rather than at finalKeyframe.
|
|
2867
|
+
*/
|
|
2868
|
+
sampleAt(timestamp: number, resolved?: boolean): T;
|
|
2869
|
+
/**
|
|
2870
|
+
* The generator's state `currentTime` ms after the delay, without
|
|
2871
|
+
* changing the animation's own state.
|
|
2872
|
+
*/
|
|
2873
|
+
protected generate(currentTime: number, isInDelayPhase: boolean): AnimationState<T>;
|
|
2838
2874
|
/**
|
|
2839
2875
|
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
2840
2876
|
* resolves when the animation finishes at all but in a future update could/should
|
|
@@ -2933,16 +2969,38 @@ declare class NativeAnimation<T extends AnyResolvedKeyframe> extends WithPromise
|
|
|
2933
2969
|
}
|
|
2934
2970
|
|
|
2935
2971
|
type NativeAnimationOptionsExtended<T extends AnyResolvedKeyframe> = NativeAnimationOptions & ValueAnimationOptions<T> & NativeAnimationOptions;
|
|
2972
|
+
/**
|
|
2973
|
+
* 10ms is chosen here as it strikes a balance between smooth
|
|
2974
|
+
* results (more than one keyframe per frame at 60fps) and
|
|
2975
|
+
* keyframe quantity.
|
|
2976
|
+
*/
|
|
2977
|
+
declare const sampleDelta = 10;
|
|
2936
2978
|
declare class NativeAnimationExtended<T extends AnyResolvedKeyframe> extends NativeAnimation<T> {
|
|
2937
2979
|
options: NativeAnimationOptionsExtended<T>;
|
|
2938
2980
|
constructor(options: NativeAnimationOptionsExtended<T>);
|
|
2981
|
+
private sampler?;
|
|
2982
|
+
/**
|
|
2983
|
+
* The animation's time now, in ms. Wall-clock rather than WAAPI's
|
|
2984
|
+
* currentTime while running, as under CPU load currentTime may not
|
|
2985
|
+
* reflect the actual elapsed time, causing incorrect sampling and
|
|
2986
|
+
* visual jumps.
|
|
2987
|
+
*/
|
|
2988
|
+
private elapsed;
|
|
2989
|
+
/**
|
|
2990
|
+
* The value at a time, from a renderless JS animation.
|
|
2991
|
+
*/
|
|
2992
|
+
private sample;
|
|
2993
|
+
/**
|
|
2994
|
+
* The value now, as WAAPI doesn't set the motion value while it runs.
|
|
2995
|
+
*/
|
|
2996
|
+
liveValue(): T | undefined;
|
|
2939
2997
|
/**
|
|
2940
2998
|
* WAAPI doesn't natively have any interruption capabilities.
|
|
2941
2999
|
*
|
|
2942
3000
|
* Rather than read committed styles back out of the DOM, we can
|
|
2943
|
-
*
|
|
2944
|
-
*
|
|
2945
|
-
*
|
|
3001
|
+
* sample a renderless JS animation twice to calculate its current
|
|
3002
|
+
* value, "previous" value, and therefore allow Motion to calculate
|
|
3003
|
+
* velocity for any subsequent animation.
|
|
2946
3004
|
*/
|
|
2947
3005
|
updateMotionValue(value?: T): void;
|
|
2948
3006
|
}
|
|
@@ -3134,6 +3192,12 @@ declare class DOMKeyframesResolver<T extends AnyResolvedKeyframe> extends Keyfra
|
|
|
3134
3192
|
private removedTransforms?;
|
|
3135
3193
|
private measuredOrigin?;
|
|
3136
3194
|
constructor(unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: WithRender);
|
|
3195
|
+
/**
|
|
3196
|
+
* Keyframes that don't need reading from the DOM, or measuring,
|
|
3197
|
+
* resolve straight away rather than in the frame loop's batched read.
|
|
3198
|
+
*/
|
|
3199
|
+
scheduleResolve(): void;
|
|
3200
|
+
private canReadNow;
|
|
3137
3201
|
readKeyframes(): void;
|
|
3138
3202
|
resolveNoneKeyframes(): void;
|
|
3139
3203
|
private measure;
|
|
@@ -3173,6 +3237,7 @@ declare function startWaapiAnimation(element: Element, valueName: string, keyfra
|
|
|
3173
3237
|
|
|
3174
3238
|
declare const supportsPartialKeyframes: () => boolean;
|
|
3175
3239
|
|
|
3240
|
+
declare const supportsWaapi: () => any;
|
|
3176
3241
|
declare function supportsBrowserAnimation<T extends AnyResolvedKeyframe>(options: ValueAnimationOptionsWithRenderContext<T>): any;
|
|
3177
3242
|
|
|
3178
3243
|
/**
|
|
@@ -3736,14 +3801,19 @@ declare const invisibleValues: Set<string>;
|
|
|
3736
3801
|
*/
|
|
3737
3802
|
declare function mixVisibility(origin: string, target: string): (p: number) => string;
|
|
3738
3803
|
|
|
3739
|
-
type StaggerOrigin = "first" | "last" | "center" | number;
|
|
3804
|
+
type StaggerOrigin = "first" | "last" | "center" | "edges" | "random" | number;
|
|
3740
3805
|
type StaggerOptions = {
|
|
3741
3806
|
startDelay?: number;
|
|
3742
3807
|
from?: StaggerOrigin;
|
|
3743
3808
|
ease?: Easing;
|
|
3809
|
+
/**
|
|
3810
|
+
* Treat elements as a grid of `[columns, rows]`, in reading order.
|
|
3811
|
+
* Delays are then based on the 2D distance from `from`.
|
|
3812
|
+
*/
|
|
3813
|
+
grid?: [number, number];
|
|
3744
3814
|
};
|
|
3745
3815
|
declare function getOriginIndex(from: StaggerOrigin, total: number): number;
|
|
3746
|
-
declare function stagger(duration?: number, { startDelay, from, ease }?: StaggerOptions): DynamicOption<number>;
|
|
3816
|
+
declare function stagger(duration?: number, { startDelay, from, ease, grid }?: StaggerOptions): DynamicOption<number>;
|
|
3747
3817
|
|
|
3748
3818
|
/**
|
|
3749
3819
|
* Add the ability for test suites to manually set support flags
|
|
@@ -5579,4 +5649,4 @@ declare const sync: Batcher;
|
|
|
5579
5649
|
*/
|
|
5580
5650
|
declare const cancelSync: Record<string, (process: Process) => void>;
|
|
5581
5651
|
|
|
5582
|
-
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, addAttrValue, addDomEvent, addEffect, addSVGValue, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, scale, scaleCorrectors, scalePoint, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, svgEffect, svgSubjectEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
|
5652
|
+
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, addAttrValue, addDomEvent, addEffect, addSVGValue, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, round, sampleDelta, scale, scaleCorrectors, scalePoint, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, supportsWaapi, svgEffect, svgSubjectEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|