framer-motion 12.4.13 → 12.6.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 (100) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/client.js +1 -1
  3. package/dist/cjs/{create-DkTZDHiS.js → create-CgwP8YNL.js} +4234 -4792
  4. package/dist/cjs/debug.js +5 -281
  5. package/dist/cjs/dom-mini.js +9 -7
  6. package/dist/cjs/dom.js +81 -639
  7. package/dist/cjs/index.js +1555 -1553
  8. package/dist/cjs/m.js +11 -179
  9. package/dist/cjs/mini.js +8 -0
  10. package/dist/debug.d.ts +2 -35
  11. package/dist/dom-mini.d.ts +1 -181
  12. package/dist/dom-mini.js +1 -1
  13. package/dist/dom.d.ts +3 -242
  14. package/dist/dom.js +1 -1
  15. package/dist/es/animation/animate/single-value.mjs +1 -1
  16. package/dist/es/animation/animators/BaseAnimation.mjs +1 -1
  17. package/dist/es/animation/animators/MainThreadAnimation.mjs +1 -2
  18. package/dist/es/animation/animators/drivers/driver-frameloop.mjs +1 -2
  19. package/dist/es/animation/animators/waapi/index.mjs +1 -3
  20. package/dist/es/animation/generators/utils/velocity.mjs +1 -1
  21. package/dist/es/animation/interfaces/motion-value.mjs +2 -4
  22. package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
  23. package/dist/es/animation/optimized-appear/start.mjs +3 -3
  24. package/dist/es/animation/sequence/utils/edit.mjs +1 -1
  25. package/dist/es/components/AnimatePresence/index.mjs +1 -1
  26. package/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
  27. package/dist/es/debug.mjs +1 -1
  28. package/dist/es/dom.mjs +1 -5
  29. package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -2
  30. package/dist/es/gestures/hover.mjs +1 -2
  31. package/dist/es/gestures/pan/PanSession.mjs +1 -2
  32. package/dist/es/gestures/pan/index.mjs +1 -1
  33. package/dist/es/gestures/press.mjs +1 -2
  34. package/dist/es/index.mjs +14 -19
  35. package/dist/es/motion/features/layout/MeasureLayout.mjs +1 -2
  36. package/dist/es/motion/utils/use-visual-element.mjs +6 -6
  37. package/dist/es/projection/node/create-projection-node.mjs +2 -8
  38. package/dist/es/projection/shared/stack.mjs +1 -1
  39. package/dist/es/projection.mjs +1 -3
  40. package/dist/es/render/VisualElement.mjs +2 -5
  41. package/dist/es/render/components/create-proxy.mjs +1 -1
  42. package/dist/es/render/dom/DOMVisualElement.mjs +1 -1
  43. package/dist/es/render/dom/scroll/info.mjs +1 -2
  44. package/dist/es/render/dom/scroll/observe.mjs +1 -1
  45. package/dist/es/render/dom/scroll/on-scroll-handler.mjs +1 -1
  46. package/dist/es/render/dom/scroll/track.mjs +1 -1
  47. package/dist/es/render/svg/SVGVisualElement.mjs +1 -1
  48. package/dist/es/render/svg/config-motion.mjs +1 -1
  49. package/dist/es/render/utils/KeyframesResolver.mjs +1 -1
  50. package/dist/es/render/utils/flat-tree.mjs +1 -1
  51. package/dist/es/render/utils/motion-values.mjs +3 -3
  52. package/dist/es/render/utils/setters.mjs +1 -1
  53. package/dist/es/utils/delay.mjs +1 -2
  54. package/dist/es/utils/reduced-motion/use-reduced-motion.mjs +1 -1
  55. package/dist/es/utils/use-animation-frame.mjs +1 -1
  56. package/dist/es/utils/use-force-update.mjs +1 -1
  57. package/dist/es/utils/use-instant-transition.mjs +1 -1
  58. package/dist/es/value/scroll/use-element-scroll.mjs +1 -1
  59. package/dist/es/value/scroll/use-viewport-scroll.mjs +1 -1
  60. package/dist/es/value/use-combine-values.mjs +2 -2
  61. package/dist/es/value/use-computed.mjs +1 -1
  62. package/dist/es/value/use-inverted-scale.mjs +3 -3
  63. package/dist/es/value/use-motion-value.mjs +1 -1
  64. package/dist/es/value/use-scroll.mjs +4 -4
  65. package/dist/es/value/use-spring.mjs +1 -1
  66. package/dist/es/value/use-transform.mjs +1 -1
  67. package/dist/es/value/use-velocity.mjs +1 -1
  68. package/dist/es/value/use-will-change/WillChangeMotionValue.mjs +2 -2
  69. package/dist/framer-motion.dev.js +8227 -8251
  70. package/dist/framer-motion.js +1 -1
  71. package/dist/m.d.ts +49 -241
  72. package/dist/size-rollup-animate.js +1 -1
  73. package/dist/size-rollup-dom-animation-assets.js +1 -1
  74. package/dist/size-rollup-dom-animation.js +1 -1
  75. package/dist/size-rollup-dom-max-assets.js +1 -1
  76. package/dist/size-rollup-dom-max.js +1 -1
  77. package/dist/size-rollup-m.js +1 -1
  78. package/dist/size-rollup-motion.js +1 -1
  79. package/dist/size-rollup-scroll.js +1 -1
  80. package/dist/types/client.d.ts +2 -2
  81. package/dist/types/index.d.ts +43 -79
  82. package/dist/{types.d-6pKw1mTI.d.ts → types.d-B50aGbjN.d.ts} +81 -289
  83. package/package.json +4 -6
  84. package/dist/es/frameloop/batcher.mjs +0 -69
  85. package/dist/es/frameloop/frame.mjs +0 -6
  86. package/dist/es/frameloop/index-legacy.mjs +0 -20
  87. package/dist/es/frameloop/microtask.mjs +0 -5
  88. package/dist/es/frameloop/order.mjs +0 -10
  89. package/dist/es/frameloop/render-step.mjs +0 -92
  90. package/dist/es/frameloop/sync-time.mjs +0 -31
  91. package/dist/es/stats/animation-count.mjs +0 -7
  92. package/dist/es/stats/buffer.mjs +0 -6
  93. package/dist/es/stats/index.mjs +0 -113
  94. package/dist/es/utils/GlobalConfig.mjs +0 -6
  95. package/dist/es/utils/array.mjs +0 -21
  96. package/dist/es/utils/subscription-manager.mjs +0 -40
  97. package/dist/es/utils/velocity-per-second.mjs +0 -11
  98. package/dist/es/utils/warn-once.mjs +0 -11
  99. package/dist/es/value/index.mjs +0 -319
  100. package/dist/three.d.ts +0 -2833
package/dist/m.d.ts CHANGED
@@ -1,11 +1,7 @@
1
1
  /// <reference types="react" />
2
+ import { Easing, TransformProperties, SVGPathProperties, VariableKeyframesDefinition, MotionValue, Transition as Transition$1, ProgressTimeline, Batcher } from 'motion-dom';
2
3
  import * as React$1 from 'react';
3
4
  import { SVGAttributes, CSSProperties, PropsWithoutRef, RefAttributes, JSX } from 'react';
4
- import { Easing, TransformProperties, SVGPathProperties, VariableKeyframesDefinition, AnimationPlaybackControls, Transition as Transition$1, ProgressTimeline } from 'motion-dom';
5
-
6
- type RefObject<T> = {
7
- current: T | null;
8
- };
9
5
 
10
6
  interface Point {
11
7
  x: number;
@@ -26,81 +22,6 @@ interface BoundingBox {
26
22
  left: number;
27
23
  }
28
24
 
29
- /**
30
- * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
31
- * information about the current state of the tap gesture such as its
32
- * `point`, `delta`, `offset` and `velocity`.
33
- *
34
- * ```jsx
35
- * <motion.div onPan={(event, info) => {
36
- * console.log(info.point.x, info.point.y)
37
- * }} />
38
- * ```
39
- *
40
- * @public
41
- */
42
- interface PanInfo {
43
- /**
44
- * Contains `x` and `y` values for the current pan position relative
45
- * to the device or page.
46
- *
47
- * ```jsx
48
- * function onPan(event, info) {
49
- * console.log(info.point.x, info.point.y)
50
- * }
51
- *
52
- * <motion.div onPan={onPan} />
53
- * ```
54
- *
55
- * @public
56
- */
57
- point: Point;
58
- /**
59
- * Contains `x` and `y` values for the distance moved since
60
- * the last event.
61
- *
62
- * ```jsx
63
- * function onPan(event, info) {
64
- * console.log(info.delta.x, info.delta.y)
65
- * }
66
- *
67
- * <motion.div onPan={onPan} />
68
- * ```
69
- *
70
- * @public
71
- */
72
- delta: Point;
73
- /**
74
- * Contains `x` and `y` values for the distance moved from
75
- * the first pan event.
76
- *
77
- * ```jsx
78
- * function onPan(event, info) {
79
- * console.log(info.offset.x, info.offset.y)
80
- * }
81
- *
82
- * <motion.div onPan={onPan} />
83
- * ```
84
- *
85
- * @public
86
- */
87
- offset: Point;
88
- /**
89
- * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
90
- *
91
- * ```jsx
92
- * function onPan(event, info) {
93
- * console.log(info.velocity.x, info.velocity.y)
94
- * }
95
- *
96
- * <motion.div onPan={onPan} />
97
- * ```
98
- *
99
- * @public
100
- */
101
- velocity: Point;
102
- }
103
-
104
25
  /**
105
26
  * Options for orchestrating the timing of animations.
106
27
  *
@@ -952,184 +873,83 @@ interface CustomValueType {
952
873
  toValue: () => number | string;
953
874
  }
954
875
 
876
+ type RefObject<T> = {
877
+ current: T | null;
878
+ };
879
+
955
880
  /**
956
- * @public
957
- */
958
- type Subscriber<T> = (v: T) => void;
959
- interface MotionValueEventCallbacks<V> {
960
- animationStart: () => void;
961
- animationComplete: () => void;
962
- animationCancel: () => void;
963
- change: (latestValue: V) => void;
964
- renderRequest: () => void;
965
- }
966
- interface ResolvedValues$1 {
967
- [key: string]: string | number;
968
- }
969
- interface Owner {
970
- current: HTMLElement | unknown;
971
- getProps: () => {
972
- onUpdate?: (latest: ResolvedValues$1) => void;
973
- transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
974
- };
975
- }
976
- /**
977
- * `MotionValue` is used to track the state and velocity of motion values.
881
+ * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
882
+ * information about the current state of the tap gesture such as its
883
+ * `point`, `delta`, `offset` and `velocity`.
884
+ *
885
+ * ```jsx
886
+ * <motion.div onPan={(event, info) => {
887
+ * console.log(info.point.x, info.point.y)
888
+ * }} />
889
+ * ```
978
890
  *
979
891
  * @public
980
892
  */
981
- declare class MotionValue<V = any> {
982
- /**
983
- * This will be replaced by the build step with the latest version number.
984
- * When MotionValues are provided to motion components, warn if versions are mixed.
985
- */
986
- version: string;
987
- /**
988
- * If a MotionValue has an owner, it was created internally within Motion
989
- * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
990
- */
991
- owner?: Owner;
992
- /**
993
- * The current state of the `MotionValue`.
994
- */
995
- private current;
996
- /**
997
- * The previous state of the `MotionValue`.
998
- */
999
- private prev;
1000
- /**
1001
- * The previous state of the `MotionValue` at the end of the previous frame.
1002
- */
1003
- private prevFrameValue;
1004
- /**
1005
- * The last time the `MotionValue` was updated.
1006
- */
1007
- updatedAt: number;
1008
- /**
1009
- * The time `prevFrameValue` was updated.
1010
- */
1011
- prevUpdatedAt: number | undefined;
1012
- private stopPassiveEffect?;
1013
- /**
1014
- * A reference to the currently-controlling animation.
1015
- */
1016
- animation?: AnimationPlaybackControls;
1017
- setCurrent(current: V): void;
1018
- setPrevFrameValue(prevFrameValue?: V | undefined): void;
893
+ interface PanInfo {
1019
894
  /**
1020
- * Adds a function that will be notified when the `MotionValue` is updated.
1021
- *
1022
- * It returns a function that, when called, will cancel the subscription.
1023
- *
1024
- * When calling `onChange` inside a React component, it should be wrapped with the
1025
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1026
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
895
+ * Contains `x` and `y` values for the current pan position relative
896
+ * to the device or page.
1027
897
  *
1028
898
  * ```jsx
1029
- * export const MyComponent = () => {
1030
- * const x = useMotionValue(0)
1031
- * const y = useMotionValue(0)
1032
- * const opacity = useMotionValue(1)
1033
- *
1034
- * useEffect(() => {
1035
- * function updateOpacity() {
1036
- * const maxXY = Math.max(x.get(), y.get())
1037
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1038
- * opacity.set(newOpacity)
1039
- * }
1040
- *
1041
- * const unsubscribeX = x.on("change", updateOpacity)
1042
- * const unsubscribeY = y.on("change", updateOpacity)
1043
- *
1044
- * return () => {
1045
- * unsubscribeX()
1046
- * unsubscribeY()
1047
- * }
1048
- * }, [])
1049
- *
1050
- * return <motion.div style={{ x }} />
899
+ * function onPan(event, info) {
900
+ * console.log(info.point.x, info.point.y)
1051
901
  * }
1052
- * ```
1053
- *
1054
- * @param subscriber - A function that receives the latest value.
1055
- * @returns A function that, when called, will cancel this subscription.
1056
- *
1057
- * @deprecated
1058
- */
1059
- onChange(subscription: Subscriber<V>): () => void;
1060
- /**
1061
- * An object containing a SubscriptionManager for each active event.
1062
- */
1063
- private events;
1064
- on<EventName extends keyof MotionValueEventCallbacks<V>>(eventName: EventName, callback: MotionValueEventCallbacks<V>[EventName]): VoidFunction;
1065
- clearListeners(): void;
1066
- /**
1067
- * Sets the state of the `MotionValue`.
1068
- *
1069
- * @remarks
1070
902
  *
1071
- * ```jsx
1072
- * const x = useMotionValue(0)
1073
- * x.set(10)
903
+ * <motion.div onPan={onPan} />
1074
904
  * ```
1075
905
  *
1076
- * @param latest - Latest value to set.
1077
- * @param render - Whether to notify render subscribers. Defaults to `true`
1078
- *
1079
906
  * @public
1080
907
  */
1081
- set(v: V, render?: boolean): void;
1082
- setWithVelocity(prev: V, current: V, delta: number): void;
1083
- /**
1084
- * Set the state of the `MotionValue`, stopping any active animations,
1085
- * effects, and resets velocity to `0`.
1086
- */
1087
- jump(v: V, endAnimation?: boolean): void;
1088
- updateAndNotify: (v: V, render?: boolean) => void;
908
+ point: Point;
1089
909
  /**
1090
- * Returns the latest state of `MotionValue`
910
+ * Contains `x` and `y` values for the distance moved since
911
+ * the last event.
1091
912
  *
1092
- * @returns - The latest state of `MotionValue`
913
+ * ```jsx
914
+ * function onPan(event, info) {
915
+ * console.log(info.delta.x, info.delta.y)
916
+ * }
917
+ *
918
+ * <motion.div onPan={onPan} />
919
+ * ```
1093
920
  *
1094
921
  * @public
1095
922
  */
1096
- get(): NonNullable<V>;
1097
- /**
1098
- * @public
1099
- */
1100
- getPrevious(): V | undefined;
923
+ delta: Point;
1101
924
  /**
1102
- * Returns the latest velocity of `MotionValue`
925
+ * Contains `x` and `y` values for the distance moved from
926
+ * the first pan event.
1103
927
  *
1104
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
928
+ * ```jsx
929
+ * function onPan(event, info) {
930
+ * console.log(info.offset.x, info.offset.y)
931
+ * }
1105
932
  *
1106
- * @public
1107
- */
1108
- getVelocity(): number;
1109
- hasAnimated: boolean;
1110
- /**
1111
- * Stop the currently active animation.
933
+ * <motion.div onPan={onPan} />
934
+ * ```
1112
935
  *
1113
936
  * @public
1114
937
  */
1115
- stop(): void;
938
+ offset: Point;
1116
939
  /**
1117
- * Returns `true` if this value is currently animating.
940
+ * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
1118
941
  *
1119
- * @public
1120
- */
1121
- isAnimating(): boolean;
1122
- private clearAnimation;
1123
- /**
1124
- * Destroy and clean up subscribers to this `MotionValue`.
942
+ * ```jsx
943
+ * function onPan(event, info) {
944
+ * console.log(info.velocity.x, info.velocity.y)
945
+ * }
1125
946
  *
1126
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1127
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1128
- * created a `MotionValue` via the `motionValue` function.
947
+ * <motion.div onPan={onPan} />
948
+ * ```
1129
949
  *
1130
950
  * @public
1131
951
  */
1132
- destroy(): void;
952
+ velocity: Point;
1133
953
  }
1134
954
 
1135
955
  interface DragControlOptions {
@@ -2305,18 +2125,6 @@ declare class ScrollTimeline implements ProgressTimeline {
2305
2125
  cancel?: VoidFunction;
2306
2126
  }
2307
2127
 
2308
- type Process = (data: FrameData) => void;
2309
- type Schedule = (process: Process, keepAlive?: boolean, immediate?: boolean) => Process;
2310
- type StepId = "read" | "resolveKeyframes" | "update" | "preRender" | "render" | "postRender";
2311
- type Batcher = {
2312
- [key in StepId]: Schedule;
2313
- };
2314
- interface FrameData {
2315
- delta: number;
2316
- timestamp: number;
2317
- isProcessing: boolean;
2318
- }
2319
-
2320
2128
  type UnionStringArray<T extends Readonly<string[]>> = T[number];
2321
2129
  declare const svgElements: readonly ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"];
2322
2130
  type SVGElements = UnionStringArray<typeof svgElements>;
@@ -2378,7 +2186,7 @@ type DOMMotionComponents = HTMLMotionComponents & SVGMotionComponents;
2378
2186
 
2379
2187
  declare const createMinimalMotionComponent: <Props, TagName extends string = "div">(Component: string | TagName | React$1.ComponentType<Props>, { forwardMotionProps }?: {
2380
2188
  forwardMotionProps: boolean;
2381
- }) => TagName extends "symbol" | "clipPath" | "filter" | "mask" | "marker" | "text" | "stop" | "animate" | "path" | "image" | "circle" | "switch" | "svg" | keyof HTMLElements | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "line" | "linearGradient" | "metadata" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "textPath" | "tspan" | "use" | "view" ? DOMMotionComponents[TagName] : React$1.ComponentType<Omit<MotionComponentProps<Props>, "children"> & {
2189
+ }) => TagName extends "symbol" | "clipPath" | "filter" | "mask" | "marker" | "text" | "animate" | "path" | "image" | "circle" | "switch" | "stop" | "svg" | keyof HTMLElements | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "line" | "linearGradient" | "metadata" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "textPath" | "tspan" | "use" | "view" ? DOMMotionComponents[TagName] : React$1.ComponentType<Omit<MotionComponentProps<Props>, "children"> & {
2382
2190
  children?: ("children" extends keyof Props ? Props[keyof Props & "children"] | MotionComponentProps<Props>[keyof Props & "children"] : MotionComponentProps<Props>["children"]) | undefined;
2383
2191
  }>;
2384
2192