motion-dom 12.35.2 → 12.37.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.
Files changed (44) hide show
  1. package/dist/cjs/index.js +181 -75
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/AsyncMotionValueAnimation.mjs +23 -7
  4. package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
  5. package/dist/es/animation/JSAnimation.mjs +16 -3
  6. package/dist/es/animation/JSAnimation.mjs.map +1 -1
  7. package/dist/es/animation/interfaces/motion-value.mjs +1 -1
  8. package/dist/es/animation/interfaces/motion-value.mjs.map +1 -1
  9. package/dist/es/animation/keyframes/utils/unit-conversion.mjs +12 -2
  10. package/dist/es/animation/keyframes/utils/unit-conversion.mjs.map +1 -1
  11. package/dist/es/animation/utils/active-animations.mjs +5 -2
  12. package/dist/es/animation/utils/active-animations.mjs.map +1 -1
  13. package/dist/es/animation/utils/is-transition-defined.mjs +18 -2
  14. package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
  15. package/dist/es/animation/waapi/supports/waapi.mjs +21 -12
  16. package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
  17. package/dist/es/animation/waapi/utils/is-browser-color.mjs +13 -0
  18. package/dist/es/animation/waapi/utils/is-browser-color.mjs.map +1 -0
  19. package/dist/es/frameloop/batcher.mjs +3 -2
  20. package/dist/es/frameloop/batcher.mjs.map +1 -1
  21. package/dist/es/frameloop/render-step.mjs +5 -3
  22. package/dist/es/frameloop/render-step.mjs.map +1 -1
  23. package/dist/es/index.mjs +1 -1
  24. package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
  25. package/dist/es/projection/animation/mix-values.mjs +8 -3
  26. package/dist/es/projection/animation/mix-values.mjs.map +1 -1
  27. package/dist/es/projection/geometry/delta-apply.mjs +4 -6
  28. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  29. package/dist/es/projection/node/create-projection-node.mjs +31 -10
  30. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  31. package/dist/es/utils/is-html-element.mjs +3 -1
  32. package/dist/es/utils/is-html-element.mjs.map +1 -1
  33. package/dist/es/value/follow-value.mjs +13 -1
  34. package/dist/es/value/follow-value.mjs.map +1 -1
  35. package/dist/index.d.ts +28 -12
  36. package/dist/motion-dom.dev.js +181 -75
  37. package/dist/motion-dom.js +1 -1
  38. package/dist/size-rollup-motion-value.js +1 -1
  39. package/dist/size-rollup-motion-value.js.map +1 -1
  40. package/dist/size-rollup-style-effect.js +1 -1
  41. package/dist/size-rollup-style-effect.js.map +1 -1
  42. package/package.json +3 -3
  43. package/dist/es/animation/utils/get-final-keyframe.mjs +0 -13
  44. package/dist/es/animation/utils/get-final-keyframe.mjs.map +0 -1
@@ -5,7 +5,9 @@ import { isObject } from 'motion-utils';
5
5
  * that works across iframes
6
6
  */
7
7
  function isHTMLElement(element) {
8
- return isObject(element) && "offsetHeight" in element;
8
+ return (isObject(element) &&
9
+ "offsetHeight" in element &&
10
+ !("ownerSVGElement" in element));
9
11
  }
10
12
 
11
13
  export { isHTMLElement };
@@ -1 +1 @@
1
- {"version":3,"file":"is-html-element.mjs","sources":["../../../src/utils/is-html-element.ts"],"sourcesContent":["import { isObject } from \"motion-utils\"\n\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nexport function isHTMLElement(element: unknown): element is HTMLElement {\n return isObject(element) && \"offsetHeight\" in element\n}\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAgB,EAAA;IAC1C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,cAAc,IAAI,OAAO;AACzD;;;;"}
1
+ {"version":3,"file":"is-html-element.mjs","sources":["../../../src/utils/is-html-element.ts"],"sourcesContent":["import { isObject } from \"motion-utils\"\n\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nexport function isHTMLElement(element: unknown): element is HTMLElement {\n return (\n isObject(element) &&\n \"offsetHeight\" in element &&\n !(\"ownerSVGElement\" in element)\n )\n}\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAgB,EAAA;AAC1C,IAAA,QACI,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,cAAc,IAAI,OAAO;AACzB,QAAA,EAAE,iBAAiB,IAAI,OAAO,CAAC;AAEvC;;;;"}
@@ -50,6 +50,7 @@ function attachFollow(value, source, options = {}) {
50
50
  activeAnimation.stop();
51
51
  activeAnimation = null;
52
52
  }
53
+ value.animation = undefined;
53
54
  };
54
55
  const startAnimation = () => {
55
56
  const currentValue = asNumber(value.get());
@@ -81,8 +82,10 @@ function attachFollow(value, source, options = {}) {
81
82
  // multiple calls within the same frame (e.g. rapid mouse events)
82
83
  const scheduleAnimation = () => {
83
84
  startAnimation();
85
+ value.animation = activeAnimation ?? undefined;
84
86
  value["events"].animationStart?.notify();
85
87
  activeAnimation?.then(() => {
88
+ value.animation = undefined;
86
89
  value["events"].animationComplete?.notify();
87
90
  });
88
91
  };
@@ -92,7 +95,16 @@ function attachFollow(value, source, options = {}) {
92
95
  frame.postRender(scheduleAnimation);
93
96
  }, stopAnimation);
94
97
  if (isMotionValue(source)) {
95
- const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
98
+ let skipNextAnimation = options.skipInitialAnimation === true;
99
+ const removeSourceOnChange = source.on("change", (v) => {
100
+ if (skipNextAnimation) {
101
+ skipNextAnimation = false;
102
+ value.jump(parseValue(v, unit), false);
103
+ }
104
+ else {
105
+ value.set(parseValue(v, unit));
106
+ }
107
+ });
96
108
  const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
97
109
  return () => {
98
110
  removeSourceOnChange();
@@ -1 +1 @@
1
- {"version":3,"file":"follow-value.mjs","sources":["../../../src/value/follow-value.ts"],"sourcesContent":["import { MotionValue, motionValue } from \".\"\nimport { JSAnimation } from \"../animation/JSAnimation\"\nimport { AnyResolvedKeyframe, ValueAnimationTransition } from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { isMotionValue } from \"./utils/is-motion-value\"\n\n/**\n * Options for useFollowValue hook, extending ValueAnimationTransition\n * but excluding lifecycle callbacks that don't make sense for the hook pattern.\n */\nexport type FollowValueOptions = Omit<\n ValueAnimationTransition,\n \"onUpdate\" | \"onComplete\" | \"onPlay\" | \"onRepeat\" | \"onStop\"\n>\n\n/**\n * Create a `MotionValue` that animates to its latest value using any transition type.\n * Can either be a value or track another `MotionValue`.\n *\n * ```jsx\n * const x = motionValue(0)\n * const y = followValue(x, { type: \"spring\", stiffness: 300 })\n * // or with tween\n * const z = followValue(x, { type: \"tween\", duration: 0.5, ease: \"easeOut\" })\n * ```\n *\n * @param source - Initial value or MotionValue to track\n * @param options - Animation transition options\n * @returns `MotionValue`\n *\n * @public\n */\nexport function followValue<T extends AnyResolvedKeyframe>(\n source: T | MotionValue<T>,\n options?: FollowValueOptions\n) {\n const initialValue = isMotionValue(source) ? source.get() : source\n const value = motionValue(initialValue)\n\n attachFollow(value, source, options)\n\n return value\n}\n\n/**\n * Attach an animation to a MotionValue that will animate whenever the value changes.\n * Similar to attachSpring but supports any transition type (spring, tween, inertia, etc.)\n *\n * @param value - The MotionValue to animate\n * @param source - Initial value or MotionValue to track\n * @param options - Animation transition options\n * @returns Cleanup function\n *\n * @public\n */\nexport function attachFollow<T extends AnyResolvedKeyframe>(\n value: MotionValue<T>,\n source: T | MotionValue<T>,\n options: FollowValueOptions = {}\n): VoidFunction {\n const initialValue = value.get()\n\n let activeAnimation: JSAnimation<number> | null = null\n let latestValue = initialValue\n let latestSetter: (v: T) => void\n\n const unit =\n typeof initialValue === \"string\"\n ? initialValue.replace(/[\\d.-]/g, \"\")\n : undefined\n\n const stopAnimation = () => {\n if (activeAnimation) {\n activeAnimation.stop()\n activeAnimation = null\n }\n }\n\n const startAnimation = () => {\n const currentValue = asNumber(value.get())\n const targetValue = asNumber(latestValue)\n\n // Don't animate if we're already at the target\n if (currentValue === targetValue) {\n stopAnimation()\n return\n }\n\n // Use the running animation's analytical velocity for accuracy,\n // falling back to the MotionValue's velocity for the initial animation.\n // This prevents systematic velocity loss at high frame rates (240hz+).\n const velocity = activeAnimation\n ? activeAnimation.getGeneratorVelocity()\n : value.getVelocity()\n\n stopAnimation()\n\n activeAnimation = new JSAnimation({\n keyframes: [currentValue, targetValue],\n velocity,\n // Default to spring if no type specified (matches useSpring behavior)\n type: \"spring\",\n restDelta: 0.001,\n restSpeed: 0.01,\n ...options,\n onUpdate: latestSetter,\n })\n }\n\n // Use a stable function reference so the frame loop Set deduplicates\n // multiple calls within the same frame (e.g. rapid mouse events)\n const scheduleAnimation = () => {\n startAnimation()\n value[\"events\"].animationStart?.notify()\n activeAnimation?.then(() => {\n value[\"events\"].animationComplete?.notify()\n })\n }\n\n value.attach((v, set) => {\n latestValue = v\n latestSetter = (latest) => set(parseValue(latest, unit) as T)\n frame.postRender(scheduleAnimation)\n }, stopAnimation)\n\n if (isMotionValue(source)) {\n const removeSourceOnChange = source.on(\"change\", (v) =>\n value.set(parseValue(v, unit) as T)\n )\n\n const removeValueOnDestroy = value.on(\"destroy\", removeSourceOnChange)\n\n return () => {\n removeSourceOnChange()\n removeValueOnDestroy()\n }\n }\n\n return stopAnimation\n}\n\nfunction parseValue(v: AnyResolvedKeyframe, unit?: string) {\n return unit ? v + unit : v\n}\n\nfunction asNumber(v: AnyResolvedKeyframe) {\n return typeof v === \"number\" ? v : parseFloat(v)\n}\n"],"names":[],"mappings":";;;;;AAeA;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,WAAW,CACvB,MAA0B,EAC1B,OAA4B,EAAA;AAE5B,IAAA,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,MAAM;AAClE,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,YAAY,CAAC;AAEvC,IAAA,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;AAEpC,IA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AC,cAAc,EAAE,MAAM,EAAE;AACxC,QAAA,eAAe,EAAE,IAAI,CAAC,MAAK;YACvB,KAAK,CAAC,QAAQ,CAAC,CAAC,iBAAiB,EAAE,MAAM,EAAE;AAC/C,QAAA,CAAC,CAAC;AACN,IAAA,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAI;QACpB,WAAW,GAAG,CAAC;AACf,QAAA,YAAY,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAM,CAAC;AAC7D,QAAA,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC;IACvC,CAAC,EAAE,aAAa,CAAC;AAEjB,IAAA,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,KAC/C,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAM,CAAC,CACtC;QAED,MAAM,oBAAoB,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC;AAEtE,QAAA,OAAO,MAAK;AACR,YAAA,oBAAoB,EAAE;AACtB,YAAA,oBAAoB,EAAE;AAC1B,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;AAEA,SAAS,QAAQ,CAAC,CAAsB,EAAA;AACpC,IAAA,OAAO,OAAO,CAAC,KAAK,QAAQ,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;AACpD;;;;"}
1
+ {"version":3,"file":"follow-value.mjs","sources":["../../../src/value/follow-value.ts"],"sourcesContent":["import { MotionValue, motionValue } from \".\"\nimport { JSAnimation } from \"../animation/JSAnimation\"\nimport { AnyResolvedKeyframe, ValueAnimationTransition } from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { isMotionValue } from \"./utils/is-motion-value\"\n\n/**\n * Options for useFollowValue hook, extending ValueAnimationTransition\n * but excluding lifecycle callbacks that don't make sense for the hook pattern.\n */\nexport type FollowValueOptions = Omit<\n ValueAnimationTransition,\n \"onUpdate\" | \"onComplete\" | \"onPlay\" | \"onRepeat\" | \"onStop\"\n> & {\n /**\n * When true, the first change from a tracked `MotionValue` source\n * will jump to the new value instead of animating. Subsequent\n * changes animate normally. This prevents unwanted animations\n * on page refresh or back navigation (e.g. `useScroll` + `useSpring`).\n *\n * @default false\n */\n skipInitialAnimation?: boolean\n}\n\n/**\n * Create a `MotionValue` that animates to its latest value using any transition type.\n * Can either be a value or track another `MotionValue`.\n *\n * ```jsx\n * const x = motionValue(0)\n * const y = followValue(x, { type: \"spring\", stiffness: 300 })\n * // or with tween\n * const z = followValue(x, { type: \"tween\", duration: 0.5, ease: \"easeOut\" })\n * ```\n *\n * @param source - Initial value or MotionValue to track\n * @param options - Animation transition options\n * @returns `MotionValue`\n *\n * @public\n */\nexport function followValue<T extends AnyResolvedKeyframe>(\n source: T | MotionValue<T>,\n options?: FollowValueOptions\n) {\n const initialValue = isMotionValue(source) ? source.get() : source\n const value = motionValue(initialValue)\n\n attachFollow(value, source, options)\n\n return value\n}\n\n/**\n * Attach an animation to a MotionValue that will animate whenever the value changes.\n * Similar to attachSpring but supports any transition type (spring, tween, inertia, etc.)\n *\n * @param value - The MotionValue to animate\n * @param source - Initial value or MotionValue to track\n * @param options - Animation transition options\n * @returns Cleanup function\n *\n * @public\n */\nexport function attachFollow<T extends AnyResolvedKeyframe>(\n value: MotionValue<T>,\n source: T | MotionValue<T>,\n options: FollowValueOptions = {}\n): VoidFunction {\n const initialValue = value.get()\n\n let activeAnimation: JSAnimation<number> | null = null\n let latestValue = initialValue\n let latestSetter: (v: T) => void\n\n const unit =\n typeof initialValue === \"string\"\n ? initialValue.replace(/[\\d.-]/g, \"\")\n : undefined\n\n const stopAnimation = () => {\n if (activeAnimation) {\n activeAnimation.stop()\n activeAnimation = null\n }\n value.animation = undefined\n }\n\n const startAnimation = () => {\n const currentValue = asNumber(value.get())\n const targetValue = asNumber(latestValue)\n\n // Don't animate if we're already at the target\n if (currentValue === targetValue) {\n stopAnimation()\n return\n }\n\n // Use the running animation's analytical velocity for accuracy,\n // falling back to the MotionValue's velocity for the initial animation.\n // This prevents systematic velocity loss at high frame rates (240hz+).\n const velocity = activeAnimation\n ? activeAnimation.getGeneratorVelocity()\n : value.getVelocity()\n\n stopAnimation()\n\n activeAnimation = new JSAnimation({\n keyframes: [currentValue, targetValue],\n velocity,\n // Default to spring if no type specified (matches useSpring behavior)\n type: \"spring\",\n restDelta: 0.001,\n restSpeed: 0.01,\n ...options,\n onUpdate: latestSetter,\n })\n }\n\n // Use a stable function reference so the frame loop Set deduplicates\n // multiple calls within the same frame (e.g. rapid mouse events)\n const scheduleAnimation = () => {\n startAnimation()\n value.animation = activeAnimation ?? undefined\n value[\"events\"].animationStart?.notify()\n activeAnimation?.then(() => {\n value.animation = undefined\n value[\"events\"].animationComplete?.notify()\n })\n }\n\n value.attach((v, set) => {\n latestValue = v\n latestSetter = (latest) => set(parseValue(latest, unit) as T)\n frame.postRender(scheduleAnimation)\n }, stopAnimation)\n\n if (isMotionValue(source)) {\n let skipNextAnimation = options.skipInitialAnimation === true\n\n const removeSourceOnChange = source.on(\"change\", (v) => {\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 removeValueOnDestroy = value.on(\"destroy\", removeSourceOnChange)\n\n return () => {\n removeSourceOnChange()\n removeValueOnDestroy()\n }\n }\n\n return stopAnimation\n}\n\nfunction parseValue(v: AnyResolvedKeyframe, unit?: string) {\n return unit ? v + unit : v\n}\n\nfunction asNumber(v: AnyResolvedKeyframe) {\n return typeof v === \"number\" ? v : parseFloat(v)\n}\n"],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AAK,CAAC;YAC/C;iBAAO;gBACH,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAM,CAAC;YACvC;AACJ,QAAA,CAAC,CAAC;QAEF,MAAM,oBAAoB,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC;AAEtE,QAAA,OAAO,MAAK;AACR,YAAA,oBAAoB,EAAE;AACtB,YAAA,oBAAoB,EAAE;AAC1B,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;AAEA,SAAS,QAAQ,CAAC,CAAsB,EAAA;AACpC,IAAA,OAAO,OAAO,CAAC,KAAK,QAAQ,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;AACpD;;;;"}
package/dist/index.d.ts CHANGED
@@ -734,14 +734,15 @@ interface MotionNodeDraggableOptions {
734
734
  */
735
735
  dragControls?: any;
736
736
  /**
737
- * If true, element will snap back to its origin when dragging ends.
737
+ * If `true`, element will snap back to its origin when dragging ends.
738
+ * Set to `"x"` or `"y"` to only snap back on a specific axis.
738
739
  *
739
740
  * Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
740
741
  * with `dragElastic={1}`, but when used together `dragConstraints` can define
741
742
  * a wider draggable area and `dragSnapToOrigin` will ensure the element
742
743
  * animates back to its origin on release.
743
744
  */
744
- dragSnapToOrigin?: boolean;
745
+ dragSnapToOrigin?: boolean | "x" | "y";
745
746
  /**
746
747
  * By default, if `drag` is defined on a component then an event listener will be attached
747
748
  * to automatically initiate dragging when a user presses down on it.
@@ -894,7 +895,7 @@ interface MotionNodeLayoutOptions {
894
895
  *
895
896
  * @public
896
897
  */
897
- layout?: boolean | "position" | "size" | "preserve-aspect";
898
+ layout?: boolean | "position" | "size" | "preserve-aspect" | "x" | "y";
898
899
  /**
899
900
  * Enable shared layout transitions between different components with the same `layoutId`.
900
901
  *
@@ -2359,6 +2360,11 @@ declare class JSAnimation<T extends number | string> extends WithPromise impleme
2359
2360
  private playbackSpeed;
2360
2361
  private mixKeyframes;
2361
2362
  private mirroredGenerator;
2363
+ /**
2364
+ * Reusable state object for the delay phase to avoid
2365
+ * allocating a new object every frame.
2366
+ */
2367
+ private delayState;
2362
2368
  constructor(options: ValueAnimationOptions<T>);
2363
2369
  initAnimation(): void;
2364
2370
  updateTime(timestamp: number): void;
@@ -2480,7 +2486,7 @@ declare class NativeAnimationWrapper<T extends AnyResolvedKeyframe> extends Nati
2480
2486
  }
2481
2487
 
2482
2488
  declare const animationMapKey: (name: string, pseudoElement?: string) => string;
2483
- declare function getAnimationMap(element: Element): Map<any, any>;
2489
+ declare function getAnimationMap(element: Element): Map<string, NativeAnimation<AnyResolvedKeyframe>>;
2484
2490
 
2485
2491
  interface VisualElementAnimationOptions {
2486
2492
  delay?: number;
@@ -2846,7 +2852,7 @@ declare function getVariableValue(current: CSSVariableToken, element: Element, d
2846
2852
 
2847
2853
  declare const getDefaultTransition: (valueKey: string, { keyframes }: ValueAnimationOptions) => Partial<ValueAnimationOptions>;
2848
2854
 
2849
- declare function getFinalKeyframe<T>(keyframes: T[], { repeat, repeatType }: AnimationPlaybackOptions, finalKeyframe?: T): T;
2855
+ declare function getFinalKeyframe<T>(keyframes: T[], { repeat, repeatType }: AnimationPlaybackOptions, finalKeyframe?: T, speed?: number): T;
2850
2856
 
2851
2857
  declare function getValueTransition(transition: any, key: string): any;
2852
2858
 
@@ -2862,7 +2868,7 @@ declare function resolveTransition(transition: any, parentTransition?: any): any
2862
2868
  * This filters out orchestration options and returns true
2863
2869
  * if any options are left.
2864
2870
  */
2865
- declare function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }: Transition & {
2871
+ declare function isTransitionDefined(transition: Transition & {
2866
2872
  elapsed?: number;
2867
2873
  from?: AnyResolvedKeyframe;
2868
2874
  }): boolean;
@@ -3517,7 +3523,17 @@ declare function transform<T>(inputRange: number[], outputRange: T[], options?:
3517
3523
  * Options for useFollowValue hook, extending ValueAnimationTransition
3518
3524
  * but excluding lifecycle callbacks that don't make sense for the hook pattern.
3519
3525
  */
3520
- type FollowValueOptions = Omit<ValueAnimationTransition, "onUpdate" | "onComplete" | "onPlay" | "onRepeat" | "onStop">;
3526
+ type FollowValueOptions = Omit<ValueAnimationTransition, "onUpdate" | "onComplete" | "onPlay" | "onRepeat" | "onStop"> & {
3527
+ /**
3528
+ * When true, the first change from a tracked `MotionValue` source
3529
+ * will jump to the new value instead of animating. Subsequent
3530
+ * changes animate normally. This prevents unwanted animations
3531
+ * on page refresh or back navigation (e.g. `useScroll` + `useSpring`).
3532
+ *
3533
+ * @default false
3534
+ */
3535
+ skipInitialAnimation?: boolean;
3536
+ };
3521
3537
  /**
3522
3538
  * Create a `MotionValue` that animates to its latest value using any transition type.
3523
3539
  * Can either be a value or track another `MotionValue`.
@@ -4287,7 +4303,7 @@ interface IProjectionNode<I = unknown> {
4287
4303
  setTargetDelta(delta: Delta): void;
4288
4304
  resetTransform(): void;
4289
4305
  resetSkewAndRotation(): void;
4290
- applyTransform(box: Box, transformOnly?: boolean): Box;
4306
+ applyTransform(box: Box, transformOnly?: boolean, output?: Box): Box;
4291
4307
  resolveTargetDelta(force?: boolean): void;
4292
4308
  calcProjection(): void;
4293
4309
  applyProjectionStyles(targetStyle: CSSStyleDeclaration, styleProp?: MotionStyle): void;
@@ -4357,7 +4373,7 @@ interface ProjectionNodeOptions {
4357
4373
  layoutRoot?: boolean;
4358
4374
  alwaysMeasureLayout?: boolean;
4359
4375
  onExitComplete?: VoidFunction;
4360
- animationType?: "size" | "position" | "both" | "preserve-aspect";
4376
+ animationType?: "size" | "position" | "both" | "preserve-aspect" | "x" | "y";
4361
4377
  layoutId?: string;
4362
4378
  layout?: boolean | string;
4363
4379
  visualElement?: VisualElement;
@@ -4636,7 +4652,7 @@ declare function createProjectionNode<I>({ attachResizeListener, defaultParent,
4636
4652
  };
4637
4653
  measurePageBox(): Box;
4638
4654
  removeElementScroll(box: Box): Box;
4639
- applyTransform(box: Box, transformOnly?: boolean): Box;
4655
+ applyTransform(box: Box, transformOnly?: boolean, output?: Box): Box;
4640
4656
  removeTransform(box: Box): Box;
4641
4657
  setTargetDelta(delta: Delta): void;
4642
4658
  setOptions(options: ProjectionNodeOptions): void;
@@ -4782,7 +4798,7 @@ declare const DocumentProjectionNode: {
4782
4798
  };
4783
4799
  measurePageBox(): motion_utils.Box;
4784
4800
  removeElementScroll(box: motion_utils.Box): motion_utils.Box;
4785
- applyTransform(box: motion_utils.Box, transformOnly?: boolean): motion_utils.Box;
4801
+ applyTransform(box: motion_utils.Box, transformOnly?: boolean, output?: motion_utils.Box | undefined): motion_utils.Box;
4786
4802
  removeTransform(box: motion_utils.Box): motion_utils.Box;
4787
4803
  setTargetDelta(delta: motion_utils.Delta): void;
4788
4804
  setOptions(options: ProjectionNodeOptions): void;
@@ -4927,7 +4943,7 @@ declare const HTMLProjectionNode: {
4927
4943
  };
4928
4944
  measurePageBox(): motion_utils.Box;
4929
4945
  removeElementScroll(box: motion_utils.Box): motion_utils.Box;
4930
- applyTransform(box: motion_utils.Box, transformOnly?: boolean): motion_utils.Box;
4946
+ applyTransform(box: motion_utils.Box, transformOnly?: boolean, output?: motion_utils.Box | undefined): motion_utils.Box;
4931
4947
  removeTransform(box: motion_utils.Box): motion_utils.Box;
4932
4948
  setTargetDelta(delta: motion_utils.Delta): void;
4933
4949
  setOptions(options: ProjectionNodeOptions): void;