motion-dom 12.36.0 → 12.38.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 (35) hide show
  1. package/dist/cjs/index.js +179 -83
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/AsyncMotionValueAnimation.mjs +15 -6
  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/interfaces/visual-element-target.mjs +4 -1
  10. package/dist/es/animation/interfaces/visual-element-target.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/index.mjs +1 -1
  20. package/dist/es/projection/animation/mix-values.mjs +8 -3
  21. package/dist/es/projection/animation/mix-values.mjs.map +1 -1
  22. package/dist/es/projection/geometry/delta-apply.mjs +4 -6
  23. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  24. package/dist/es/projection/geometry/delta-calc.mjs +16 -10
  25. package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
  26. package/dist/es/projection/node/create-projection-node.mjs +49 -16
  27. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  28. package/dist/es/value/follow-value.mjs +3 -0
  29. package/dist/es/value/follow-value.mjs.map +1 -1
  30. package/dist/index.d.ts +30 -11
  31. package/dist/motion-dom.dev.js +179 -83
  32. package/dist/motion-dom.js +1 -1
  33. package/package.json +2 -2
  34. package/dist/es/animation/utils/get-final-keyframe.mjs +0 -13
  35. package/dist/es/animation/utils/get-final-keyframe.mjs.map +0 -1
@@ -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
  };
@@ -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 * 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 }\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 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"],"names":[],"mappings":";;;;;AAyBA;;;;;;;;;;;;;;;;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,IAAA,OAAO,KAAK;AAChB;AAEA;;;;;;;;;;AAUG;AACG,SAAU,YAAY,CACxB,KAAqB,EACrB,MAA0B,EAC1B,UAA8B,EAAE,EAAA;AAEhC,IAAA,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,EAAE;IAEhC,IAAI,eAAe,GAA+B,IAAI;IACtD,IAAI,WAAW,GAAG,Y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,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;AACvB,QAAA,IAAI,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,KAAK,IAAI;QAE7D,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAI;YACnD,IAAI,iBAAiB,EAAE;gBACnB,iBAAiB,GAAG,KAAK;AACzB,gBAAA,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAM,EAAE,KAAK,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;;;;"}
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 ===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AC,EAAE,IAAI,CAAM,EAAE,KAAK,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
@@ -945,6 +945,19 @@ interface MotionNodeLayoutOptions {
945
945
  * Currently used for `position: sticky` elements in Framer.
946
946
  */
947
947
  layoutRoot?: boolean;
948
+ /**
949
+ * The anchor point for relative layout projection. This defines which
950
+ * point on the parent is used as the reference for the child's position.
951
+ *
952
+ * `{ x: 0, y: 0 }` (default) anchors to the top-left corner.
953
+ * `{ x: 0.5, y: 0.5 }` anchors to the center, useful for centered layouts
954
+ * (e.g., flexbox) to prevent drift during parent layout animations.
955
+ * `false` disables relative projection entirely.
956
+ */
957
+ layoutAnchor?: {
958
+ x: number;
959
+ y: number;
960
+ } | false;
948
961
  /**
949
962
  * Attached to a portal root to ensure we attach the child to the document root and don't
950
963
  * perform scale correction on it.
@@ -2360,6 +2373,11 @@ declare class JSAnimation<T extends number | string> extends WithPromise impleme
2360
2373
  private playbackSpeed;
2361
2374
  private mixKeyframes;
2362
2375
  private mirroredGenerator;
2376
+ /**
2377
+ * Reusable state object for the delay phase to avoid
2378
+ * allocating a new object every frame.
2379
+ */
2380
+ private delayState;
2363
2381
  constructor(options: ValueAnimationOptions<T>);
2364
2382
  initAnimation(): void;
2365
2383
  updateTime(timestamp: number): void;
@@ -2481,7 +2499,7 @@ declare class NativeAnimationWrapper<T extends AnyResolvedKeyframe> extends Nati
2481
2499
  }
2482
2500
 
2483
2501
  declare const animationMapKey: (name: string, pseudoElement?: string) => string;
2484
- declare function getAnimationMap(element: Element): Map<any, any>;
2502
+ declare function getAnimationMap(element: Element): Map<string, NativeAnimation<AnyResolvedKeyframe>>;
2485
2503
 
2486
2504
  interface VisualElementAnimationOptions {
2487
2505
  delay?: number;
@@ -2847,7 +2865,7 @@ declare function getVariableValue(current: CSSVariableToken, element: Element, d
2847
2865
 
2848
2866
  declare const getDefaultTransition: (valueKey: string, { keyframes }: ValueAnimationOptions) => Partial<ValueAnimationOptions>;
2849
2867
 
2850
- declare function getFinalKeyframe<T>(keyframes: T[], { repeat, repeatType }: AnimationPlaybackOptions, finalKeyframe?: T): T;
2868
+ declare function getFinalKeyframe<T>(keyframes: T[], { repeat, repeatType }: AnimationPlaybackOptions, finalKeyframe?: T, speed?: number): T;
2851
2869
 
2852
2870
  declare function getValueTransition(transition: any, key: string): any;
2853
2871
 
@@ -2863,7 +2881,7 @@ declare function resolveTransition(transition: any, parentTransition?: any): any
2863
2881
  * This filters out orchestration options and returns true
2864
2882
  * if any options are left.
2865
2883
  */
2866
- declare function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }: Transition & {
2884
+ declare function isTransitionDefined(transition: Transition & {
2867
2885
  elapsed?: number;
2868
2886
  from?: AnyResolvedKeyframe;
2869
2887
  }): boolean;
@@ -4123,10 +4141,10 @@ declare function calcLength(axis: Axis): number;
4123
4141
  declare function isNear(value: number, target: number, maxDistance: number): boolean;
4124
4142
  declare function calcAxisDelta(delta: AxisDelta, source: Axis, target: Axis, origin?: number): void;
4125
4143
  declare function calcBoxDelta(delta: Delta, source: Box, target: Box, origin?: ResolvedValues$1): void;
4126
- declare function calcRelativeAxis(target: Axis, relative: Axis, parent: Axis): void;
4127
- declare function calcRelativeBox(target: Box, relative: Box, parent: Box): void;
4128
- declare function calcRelativeAxisPosition(target: Axis, layout: Axis, parent: Axis): void;
4129
- declare function calcRelativePosition(target: Box, layout: Box, parent: Box): void;
4144
+ declare function calcRelativeAxis(target: Axis, relative: Axis, parent: Axis, anchor?: number): void;
4145
+ declare function calcRelativeBox(target: Box, relative: Box, parent: Box, anchor?: Point): void;
4146
+ declare function calcRelativeAxisPosition(target: Axis, layout: Axis, parent: Axis, anchor?: number): void;
4147
+ declare function calcRelativePosition(target: Box, layout: Box, parent: Box, anchor?: Point): void;
4130
4148
 
4131
4149
  /**
4132
4150
  * Remove a delta from a point. This is essentially the steps of applyPointDelta in reverse
@@ -4298,7 +4316,7 @@ interface IProjectionNode<I = unknown> {
4298
4316
  setTargetDelta(delta: Delta): void;
4299
4317
  resetTransform(): void;
4300
4318
  resetSkewAndRotation(): void;
4301
- applyTransform(box: Box, transformOnly?: boolean): Box;
4319
+ applyTransform(box: Box, transformOnly?: boolean, output?: Box): Box;
4302
4320
  resolveTargetDelta(force?: boolean): void;
4303
4321
  calcProjection(): void;
4304
4322
  applyProjectionStyles(targetStyle: CSSStyleDeclaration, styleProp?: MotionStyle): void;
@@ -4376,6 +4394,7 @@ interface ProjectionNodeOptions {
4376
4394
  transition?: Transition;
4377
4395
  initialPromotionConfig?: InitialPromotionConfig;
4378
4396
  layoutDependency?: unknown;
4397
+ layoutAnchor?: Point | false;
4379
4398
  }
4380
4399
  type ProjectionEventName = "layoutUpdate" | "projectionUpdate";
4381
4400
 
@@ -4647,7 +4666,7 @@ declare function createProjectionNode<I>({ attachResizeListener, defaultParent,
4647
4666
  };
4648
4667
  measurePageBox(): Box;
4649
4668
  removeElementScroll(box: Box): Box;
4650
- applyTransform(box: Box, transformOnly?: boolean): Box;
4669
+ applyTransform(box: Box, transformOnly?: boolean, output?: Box): Box;
4651
4670
  removeTransform(box: Box): Box;
4652
4671
  setTargetDelta(delta: Delta): void;
4653
4672
  setOptions(options: ProjectionNodeOptions): void;
@@ -4793,7 +4812,7 @@ declare const DocumentProjectionNode: {
4793
4812
  };
4794
4813
  measurePageBox(): motion_utils.Box;
4795
4814
  removeElementScroll(box: motion_utils.Box): motion_utils.Box;
4796
- applyTransform(box: motion_utils.Box, transformOnly?: boolean): motion_utils.Box;
4815
+ applyTransform(box: motion_utils.Box, transformOnly?: boolean, output?: motion_utils.Box | undefined): motion_utils.Box;
4797
4816
  removeTransform(box: motion_utils.Box): motion_utils.Box;
4798
4817
  setTargetDelta(delta: motion_utils.Delta): void;
4799
4818
  setOptions(options: ProjectionNodeOptions): void;
@@ -4938,7 +4957,7 @@ declare const HTMLProjectionNode: {
4938
4957
  };
4939
4958
  measurePageBox(): motion_utils.Box;
4940
4959
  removeElementScroll(box: motion_utils.Box): motion_utils.Box;
4941
- applyTransform(box: motion_utils.Box, transformOnly?: boolean): motion_utils.Box;
4960
+ applyTransform(box: motion_utils.Box, transformOnly?: boolean, output?: motion_utils.Box | undefined): motion_utils.Box;
4942
4961
  removeTransform(box: motion_utils.Box): motion_utils.Box;
4943
4962
  setTargetDelta(delta: motion_utils.Delta): void;
4944
4963
  setOptions(options: ProjectionNodeOptions): void;