motion-dom 12.24.10 → 12.27.0-alpha.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 (31) hide show
  1. package/dist/cjs/index.js +1462 -5
  2. package/dist/es/animation/NativeAnimation.mjs +10 -2
  3. package/dist/es/animation/NativeAnimationExtended.mjs +11 -4
  4. package/dist/es/index.mjs +23 -0
  5. package/dist/es/layout/animate-layout.mjs +287 -0
  6. package/dist/es/layout/factory.mjs +119 -0
  7. package/dist/es/layout/mutation-observer.mjs +139 -0
  8. package/dist/es/layout/shared-registry.mjs +111 -0
  9. package/dist/es/projection/animation/mix-values.mjs +66 -0
  10. package/dist/es/projection/geometry/conversion.mjs +33 -0
  11. package/dist/es/projection/geometry/copy.mjs +31 -0
  12. package/dist/es/projection/geometry/delta-apply.mjs +119 -0
  13. package/dist/es/projection/geometry/delta-calc.mjs +52 -0
  14. package/dist/es/projection/geometry/delta-remove.mjs +54 -0
  15. package/dist/es/projection/geometry/models.mjs +17 -0
  16. package/dist/es/projection/geometry/utils.mjs +31 -0
  17. package/dist/es/projection/node/state.mjs +19 -0
  18. package/dist/es/projection/shared/stack.mjs +112 -0
  19. package/dist/es/projection/styles/scale-border-radius.mjs +41 -0
  20. package/dist/es/projection/styles/scale-box-shadow.mjs +35 -0
  21. package/dist/es/projection/styles/scale-correction.mjs +30 -0
  22. package/dist/es/projection/styles/transform.mjs +49 -0
  23. package/dist/es/projection/utils/each-axis.mjs +5 -0
  24. package/dist/es/projection/utils/has-transform.mjs +26 -0
  25. package/dist/es/projection/utils/measure.mjs +17 -0
  26. package/dist/es/render/utils/flat-tree.mjs +24 -0
  27. package/dist/es/utils/delay.mjs +24 -0
  28. package/dist/index.d.ts +934 -242
  29. package/dist/motion-dom.dev.js +1462 -5
  30. package/dist/motion-dom.js +1 -1
  31. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -2045,6 +2045,12 @@ class NativeAnimation extends WithPromise {
2045
2045
  super();
2046
2046
  this.finishedTime = null;
2047
2047
  this.isStopped = false;
2048
+ /**
2049
+ * Tracks a manually-set start time that takes precedence over WAAPI's
2050
+ * dynamic startTime. This is cleared when play() or time setter is called,
2051
+ * allowing WAAPI to take over timing.
2052
+ */
2053
+ this.manualStartTime = null;
2048
2054
  if (!options)
2049
2055
  return;
2050
2056
  const { element, name, keyframes, pseudoElement, allowFlatten = false, finalKeyframe, onComplete, } = options;
@@ -2080,6 +2086,7 @@ class NativeAnimation extends WithPromise {
2080
2086
  play() {
2081
2087
  if (this.isStopped)
2082
2088
  return;
2089
+ this.manualStartTime = null;
2083
2090
  this.animation.play();
2084
2091
  if (this.state === "finished") {
2085
2092
  this.updateFinished();
@@ -2143,6 +2150,7 @@ class NativeAnimation extends WithPromise {
2143
2150
  return motionUtils.millisecondsToSeconds(Number(this.animation.currentTime) || 0);
2144
2151
  }
2145
2152
  set time(newTime) {
2153
+ this.manualStartTime = null;
2146
2154
  this.finishedTime = null;
2147
2155
  this.animation.currentTime = motionUtils.secondsToMilliseconds(newTime);
2148
2156
  }
@@ -2165,10 +2173,10 @@ class NativeAnimation extends WithPromise {
2165
2173
  : this.animation.playState;
2166
2174
  }
2167
2175
  get startTime() {
2168
- return Number(this.animation.startTime);
2176
+ return this.manualStartTime ?? Number(this.animation.startTime);
2169
2177
  }
2170
2178
  set startTime(newStartTime) {
2171
- this.animation.startTime = newStartTime;
2179
+ this.manualStartTime = this.animation.startTime = newStartTime;
2172
2180
  }
2173
2181
  /**
2174
2182
  * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
@@ -2230,7 +2238,7 @@ class NativeAnimationExtended extends NativeAnimation {
2230
2238
  */
2231
2239
  replaceTransitionType(options);
2232
2240
  super(options);
2233
- if (options.startTime) {
2241
+ if (options.startTime !== undefined) {
2234
2242
  this.startTime = options.startTime;
2235
2243
  }
2236
2244
  this.options = options;
@@ -2255,8 +2263,14 @@ class NativeAnimationExtended extends NativeAnimation {
2255
2263
  ...options,
2256
2264
  autoplay: false,
2257
2265
  });
2258
- const sampleTime = motionUtils.secondsToMilliseconds(this.finishedTime ?? this.time);
2259
- motionValue.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
2266
+ /**
2267
+ * Use wall-clock elapsed time for sampling.
2268
+ * Under CPU load, WAAPI's currentTime may not reflect actual
2269
+ * elapsed time, causing incorrect sampling and visual jumps.
2270
+ */
2271
+ const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
2272
+ const delta = motionUtils.clamp(0, sampleDelta, sampleTime - sampleDelta);
2273
+ motionValue.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
2260
2274
  sampleAnimation.stop();
2261
2275
  }
2262
2276
  }
@@ -3720,6 +3734,755 @@ function convertAttrKey(key) {
3720
3734
  return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());
3721
3735
  }
3722
3736
 
3737
+ /**
3738
+ * Utilities for observing DOM mutations during layout animations.
3739
+ * Used to detect elements added/removed during mutation callbacks
3740
+ * for enter/exit animations.
3741
+ */
3742
+ /**
3743
+ * Selectors for elements that should participate in layout animations
3744
+ */
3745
+ const LAYOUT_SELECTORS = [
3746
+ "[data-layout]",
3747
+ "[data-layout-id]",
3748
+ "[data-animate-layout]",
3749
+ ];
3750
+ /**
3751
+ * Execute a mutation callback while observing DOM changes.
3752
+ * Returns information about elements that were added or removed.
3753
+ *
3754
+ * Uses a snapshot approach since MutationObserver callbacks are async.
3755
+ *
3756
+ * @param container - The container to observe for mutations
3757
+ * @param mutation - The mutation callback to execute
3758
+ * @returns Information about elements added/removed during the mutation
3759
+ *
3760
+ * @example
3761
+ * ```typescript
3762
+ * const { addedElements, removedElements } = observeMutation(
3763
+ * document.body,
3764
+ * () => {
3765
+ * list.innerHTML = newContent
3766
+ * }
3767
+ * )
3768
+ *
3769
+ * // Handle newly added elements with enter animations
3770
+ * addedElements.forEach(el => animateEnter(el))
3771
+ *
3772
+ * // Handle removed elements with exit animations
3773
+ * removedElements.forEach(el => animateExit(el))
3774
+ * ```
3775
+ */
3776
+ function observeMutation(container, mutation) {
3777
+ // Snapshot approach: capture layout elements before and after mutation
3778
+ // MutationObserver callbacks are async microtasks, so we use direct comparison instead
3779
+ const selector = LAYOUT_SELECTORS.join(", ");
3780
+ // Capture elements and their bounds before mutation
3781
+ const elementsBefore = new Map();
3782
+ container.querySelectorAll(selector).forEach((el) => {
3783
+ elementsBefore.set(el, el.getBoundingClientRect());
3784
+ });
3785
+ // Execute the mutation
3786
+ mutation();
3787
+ // Capture elements after mutation
3788
+ const elementsAfter = new Set(container.querySelectorAll(selector));
3789
+ // Find added elements (in after but not in before)
3790
+ const addedElements = [];
3791
+ elementsAfter.forEach((el) => {
3792
+ if (!elementsBefore.has(el) && el instanceof HTMLElement) {
3793
+ addedElements.push(el);
3794
+ }
3795
+ });
3796
+ // Find removed elements (in before but not in after) with their pre-removal bounds
3797
+ const removedElements = [];
3798
+ elementsBefore.forEach((bounds, el) => {
3799
+ if (!elementsAfter.has(el) && el instanceof HTMLElement) {
3800
+ removedElements.push({ element: el, bounds });
3801
+ }
3802
+ });
3803
+ return { addedElements, removedElements };
3804
+ }
3805
+ /**
3806
+ * Find the common ancestor of a list of elements.
3807
+ * Used to determine the container for mutation observation.
3808
+ *
3809
+ * @param elements - Elements to find common ancestor of
3810
+ * @returns The common ancestor element, or document.body if none found
3811
+ */
3812
+ function findCommonAncestor(elements) {
3813
+ if (elements.length === 0)
3814
+ return document.body;
3815
+ if (elements.length === 1)
3816
+ return elements[0].parentElement ?? document.body;
3817
+ // Start with the first element's ancestors
3818
+ const ancestors = new Set();
3819
+ let el = elements[0];
3820
+ while (el) {
3821
+ ancestors.add(el);
3822
+ el = el.parentElement;
3823
+ }
3824
+ // Find the first ancestor that contains all elements
3825
+ for (let i = 1; i < elements.length; i++) {
3826
+ el = elements[i];
3827
+ while (el) {
3828
+ if (ancestors.has(el)) {
3829
+ // Check if this element contains all other elements
3830
+ const containsAll = elements.every((e) => el === e || el?.contains(e));
3831
+ if (containsAll) {
3832
+ return el;
3833
+ }
3834
+ }
3835
+ el = el.parentElement;
3836
+ }
3837
+ }
3838
+ return document.body;
3839
+ }
3840
+ /**
3841
+ * Keep an element in the DOM for exit animation.
3842
+ * Returns a cleanup function to remove the clone after animation.
3843
+ *
3844
+ * @param element - The element that was removed
3845
+ * @param bounds - The element's bounds before removal
3846
+ * @param container - Container to add the clone to
3847
+ * @returns Object with clone element and cleanup function
3848
+ */
3849
+ function preserveElementForExit(element, bounds, container) {
3850
+ // Clone the element to keep it in the DOM for animation
3851
+ const clone = element.cloneNode(true);
3852
+ // Position it absolutely at its last known position (from pre-captured bounds)
3853
+ clone.style.position = "fixed";
3854
+ clone.style.top = `${bounds.top}px`;
3855
+ clone.style.left = `${bounds.left}px`;
3856
+ clone.style.width = `${bounds.width}px`;
3857
+ clone.style.height = `${bounds.height}px`;
3858
+ clone.style.margin = "0";
3859
+ clone.style.pointerEvents = "none";
3860
+ clone.style.zIndex = "9999";
3861
+ // Mark as exiting to prevent re-observation
3862
+ clone.setAttribute("data-layout-exiting", "true");
3863
+ // Add to container
3864
+ container.appendChild(clone);
3865
+ return {
3866
+ clone,
3867
+ cleanup: () => {
3868
+ if (clone.parentNode) {
3869
+ clone.parentNode.removeChild(clone);
3870
+ }
3871
+ },
3872
+ };
3873
+ }
3874
+
3875
+ /**
3876
+ * Default transition for layout animations
3877
+ */
3878
+ const defaultTransition = {
3879
+ duration: 0.3,
3880
+ ease: [0.4, 0, 0.2, 1], // ease-out cubic
3881
+ };
3882
+ /**
3883
+ * Global factory for creating projection nodes and visual elements.
3884
+ * This must be set by the consuming package (e.g., framer-motion).
3885
+ */
3886
+ let globalFactory = null;
3887
+ /**
3888
+ * Set the global factory for creating layout nodes.
3889
+ * This should be called by framer-motion to provide concrete implementations.
3890
+ */
3891
+ function setLayoutNodeFactory(factory) {
3892
+ globalFactory = factory;
3893
+ }
3894
+ /**
3895
+ * Get the current layout node factory
3896
+ */
3897
+ function getLayoutNodeFactory() {
3898
+ return globalFactory;
3899
+ }
3900
+ /**
3901
+ * Internal node cache for tracking elements across animations
3902
+ */
3903
+ const nodeCache = new WeakMap();
3904
+ /**
3905
+ * Create or retrieve a projection node for an element
3906
+ */
3907
+ function getOrCreateNode(element, parent, options, factory) {
3908
+ let node = nodeCache.get(element);
3909
+ if (!node) {
3910
+ node = factory.createProjectionNode(element, parent, options);
3911
+ nodeCache.set(element, node);
3912
+ }
3913
+ return node;
3914
+ }
3915
+ /**
3916
+ * Build a projection tree from a list of elements.
3917
+ * Parents are determined by DOM ancestry.
3918
+ */
3919
+ function buildProjectionTree(elements, options, factory) {
3920
+ // Sort by DOM depth (parents first)
3921
+ const sorted = [...elements].sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
3922
+ const nodes = [];
3923
+ const elementToNode = new Map();
3924
+ for (const element of sorted) {
3925
+ if (!(element instanceof HTMLElement))
3926
+ continue;
3927
+ // Find parent node from previously processed elements
3928
+ let parent;
3929
+ let ancestor = element.parentElement;
3930
+ while (ancestor) {
3931
+ const ancestorNode = elementToNode.get(ancestor);
3932
+ if (ancestorNode) {
3933
+ parent = ancestorNode;
3934
+ break;
3935
+ }
3936
+ ancestor = ancestor.parentElement;
3937
+ }
3938
+ const node = getOrCreateNode(element, parent, options, factory);
3939
+ nodes.push(node);
3940
+ elementToNode.set(element, node);
3941
+ }
3942
+ return nodes;
3943
+ }
3944
+ /**
3945
+ * Apply enter animation to an element and return the animation controller
3946
+ */
3947
+ function applyEnterAnimation(element, config, defaultDuration) {
3948
+ const { keyframes, transition } = config;
3949
+ const duration = transition?.duration ?? defaultDuration;
3950
+ // Get the animation values from keyframes
3951
+ // Enter animations typically start from the keyframes values and animate to natural state
3952
+ const entries = Object.entries(keyframes);
3953
+ const fromValues = {};
3954
+ const toValues = {};
3955
+ for (const [key, value] of entries) {
3956
+ if (Array.isArray(value)) {
3957
+ // Multi-value keyframe - use first as start, last as end
3958
+ fromValues[key] = value[0];
3959
+ toValues[key] = value[value.length - 1];
3960
+ }
3961
+ else {
3962
+ // Single value - use as target, current as start
3963
+ toValues[key] = value;
3964
+ }
3965
+ }
3966
+ // Set initial state
3967
+ for (const [key, value] of Object.entries(fromValues)) {
3968
+ if (key in element.style) {
3969
+ element.style[key] = value;
3970
+ }
3971
+ }
3972
+ // Animate to final state using WAAPI
3973
+ const animation = element.animate([fromValues, toValues], {
3974
+ duration: duration * 1000,
3975
+ easing: typeof transition?.ease === "string"
3976
+ ? transition.ease
3977
+ : "ease-out",
3978
+ fill: "forwards",
3979
+ });
3980
+ // Commit styles when animation finishes
3981
+ if (animation.finished) {
3982
+ animation.finished.then(() => {
3983
+ animation.commitStyles();
3984
+ animation.cancel();
3985
+ });
3986
+ }
3987
+ return new NativeAnimationWrapper(animation);
3988
+ }
3989
+ /**
3990
+ * Apply exit animation to an element and return the animation controller
3991
+ */
3992
+ function applyExitAnimation(element, bounds, config, defaultDuration, container) {
3993
+ const { keyframes, transition } = config;
3994
+ const duration = transition?.duration ?? defaultDuration;
3995
+ // Preserve element in DOM for animation using pre-captured bounds
3996
+ const { clone, cleanup } = preserveElementForExit(element, bounds, container);
3997
+ // Animate to exit state
3998
+ const animation = clone.animate([{}, keyframes], {
3999
+ duration: duration * 1000,
4000
+ easing: typeof transition?.ease === "string" ? transition.ease : "ease-out",
4001
+ fill: "forwards",
4002
+ });
4003
+ // Cleanup when animation finishes
4004
+ animation.finished.then(cleanup);
4005
+ return new NativeAnimationWrapper(animation);
4006
+ }
4007
+ /**
4008
+ * Wait for the next animation frame
4009
+ */
4010
+ function nextFrame() {
4011
+ return new Promise((resolve) => {
4012
+ frame.postRender(() => resolve());
4013
+ });
4014
+ }
4015
+ /**
4016
+ * Execute layout animation on the given nodes and return a GroupAnimation
4017
+ */
4018
+ async function executeLayoutAnimation(nodes, mutation, options, enterConfig, exitConfig) {
4019
+ const animations = [];
4020
+ if (nodes.length === 0 && !mutation) {
4021
+ return new GroupAnimation(animations);
4022
+ }
4023
+ // 1. Snapshot phase - capture current positions
4024
+ nodes.forEach((node) => node.willUpdate());
4025
+ // Get container for mutation observation
4026
+ const elements = nodes
4027
+ .map((n) => n.instance)
4028
+ .filter((e) => e !== undefined);
4029
+ const container = findCommonAncestor(elements);
4030
+ // 2. Execute DOM mutation while observing for changes
4031
+ let addedElements = [];
4032
+ let removedElements = [];
4033
+ if (mutation) {
4034
+ const result = observeMutation(container, mutation);
4035
+ addedElements = result.addedElements;
4036
+ removedElements = result.removedElements;
4037
+ }
4038
+ // 3. Trigger layout update and animation
4039
+ const root = nodes[0]?.root;
4040
+ if (root) {
4041
+ root.didUpdate();
4042
+ }
4043
+ // 4. Wait for next frame - animations are created in frame.update()
4044
+ await nextFrame();
4045
+ // 5. Collect all animations from projection nodes
4046
+ for (const node of nodes) {
4047
+ if (node.currentAnimation) {
4048
+ animations.push(node.currentAnimation);
4049
+ }
4050
+ }
4051
+ // 6. Handle enter animations for newly added elements
4052
+ if (enterConfig && addedElements.length > 0) {
4053
+ for (const el of addedElements) {
4054
+ const anim = applyEnterAnimation(el, enterConfig, options.duration ?? 0.3);
4055
+ animations.push(anim);
4056
+ }
4057
+ }
4058
+ // 7. Handle exit animations for removed elements
4059
+ if (exitConfig && removedElements.length > 0) {
4060
+ for (const { element, bounds } of removedElements) {
4061
+ const anim = applyExitAnimation(element, bounds, exitConfig, options.duration ?? 0.3, container);
4062
+ animations.push(anim);
4063
+ }
4064
+ }
4065
+ return new GroupAnimation(animations);
4066
+ }
4067
+ /**
4068
+ * Animate layout changes for the specified elements.
4069
+ * Returns a builder that resolves to a GroupAnimation implementing AnimationPlaybackControls.
4070
+ *
4071
+ * @example
4072
+ * // Basic usage with mutation callback
4073
+ * const animation = await animateLayout("#box", () => {
4074
+ * box.classList.toggle("expanded")
4075
+ * }, { duration: 0.3 })
4076
+ * animation.pause()
4077
+ *
4078
+ * @example
4079
+ * // Builder pattern with enter/exit animations
4080
+ * const animation = await animateLayout(".cards", { duration: 0.3 })
4081
+ * .enter({ opacity: [0, 1], scale: [0.8, 1] }, { duration: 0.2 })
4082
+ * .exit({ opacity: 0, scale: 0.8 }, { duration: 0.15 })
4083
+ * animation.time = 0 // Seek to start
4084
+ *
4085
+ * @example
4086
+ * // Multiple elements with auto-hierarchy
4087
+ * const animation = await animateLayout([parent, child1, child2], () => {
4088
+ * parent.style.width = "500px"
4089
+ * })
4090
+ */
4091
+ function animateLayout(elementOrSelector, mutationOrOptions, options) {
4092
+ // Check if factory is configured
4093
+ if (!globalFactory) {
4094
+ throw new Error("animateLayout: No layout node factory configured. " +
4095
+ "Make sure to import from 'framer-motion' or call setLayoutNodeFactory() first.");
4096
+ }
4097
+ const factory = globalFactory;
4098
+ const elements = resolveElements(elementOrSelector);
4099
+ // Parse overloaded arguments
4100
+ const mutation = typeof mutationOrOptions === "function" ? mutationOrOptions : undefined;
4101
+ const opts = typeof mutationOrOptions === "object"
4102
+ ? mutationOrOptions
4103
+ : options ?? {};
4104
+ // Merge with default transition
4105
+ const mergedOptions = {
4106
+ ...opts,
4107
+ transition: {
4108
+ ...defaultTransition,
4109
+ ...opts.transition,
4110
+ duration: opts.duration ?? opts.transition?.duration ?? 0.3,
4111
+ ease: opts.ease ?? opts.transition?.ease,
4112
+ },
4113
+ };
4114
+ // Build projection tree
4115
+ const nodes = buildProjectionTree(elements, mergedOptions, factory);
4116
+ // State for builder pattern
4117
+ let enterConfig;
4118
+ let exitConfig;
4119
+ let animationPromise;
4120
+ const builder = {
4121
+ enter(keyframes, transition) {
4122
+ enterConfig = { keyframes, transition };
4123
+ return builder;
4124
+ },
4125
+ exit(keyframes, transition) {
4126
+ exitConfig = { keyframes, transition };
4127
+ return builder;
4128
+ },
4129
+ then(onResolve, onReject) {
4130
+ // Execute animation if not already started
4131
+ if (!animationPromise) {
4132
+ animationPromise = executeLayoutAnimation(nodes, mutation, mergedOptions, enterConfig, exitConfig);
4133
+ }
4134
+ return animationPromise
4135
+ .then((groupAnimation) => onResolve(groupAnimation))
4136
+ .catch((err) => {
4137
+ if (onReject)
4138
+ onReject(err);
4139
+ throw err;
4140
+ });
4141
+ },
4142
+ };
4143
+ // If mutation is provided, schedule execution on microtask
4144
+ // to allow builder methods to be called first
4145
+ if (mutation) {
4146
+ queueMicrotask(() => {
4147
+ if (!animationPromise) {
4148
+ animationPromise = executeLayoutAnimation(nodes, mutation, mergedOptions, enterConfig, exitConfig);
4149
+ }
4150
+ });
4151
+ }
4152
+ return builder;
4153
+ }
4154
+
4155
+ class NodeStack {
4156
+ constructor() {
4157
+ this.members = [];
4158
+ }
4159
+ add(node) {
4160
+ motionUtils.addUniqueItem(this.members, node);
4161
+ node.scheduleRender();
4162
+ }
4163
+ remove(node) {
4164
+ motionUtils.removeItem(this.members, node);
4165
+ if (node === this.prevLead) {
4166
+ this.prevLead = undefined;
4167
+ }
4168
+ if (node === this.lead) {
4169
+ const prevLead = this.members[this.members.length - 1];
4170
+ if (prevLead) {
4171
+ this.promote(prevLead);
4172
+ }
4173
+ }
4174
+ }
4175
+ relegate(node) {
4176
+ const indexOfNode = this.members.findIndex((member) => node === member);
4177
+ if (indexOfNode === 0)
4178
+ return false;
4179
+ /**
4180
+ * Find the next projection node that is present
4181
+ */
4182
+ let prevLead;
4183
+ for (let i = indexOfNode; i >= 0; i--) {
4184
+ const member = this.members[i];
4185
+ if (member.isPresent !== false) {
4186
+ prevLead = member;
4187
+ break;
4188
+ }
4189
+ }
4190
+ if (prevLead) {
4191
+ this.promote(prevLead);
4192
+ return true;
4193
+ }
4194
+ else {
4195
+ return false;
4196
+ }
4197
+ }
4198
+ promote(node, preserveFollowOpacity) {
4199
+ const prevLead = this.lead;
4200
+ if (node === prevLead)
4201
+ return;
4202
+ this.prevLead = prevLead;
4203
+ this.lead = node;
4204
+ node.show();
4205
+ if (prevLead) {
4206
+ prevLead.instance && prevLead.scheduleRender();
4207
+ node.scheduleRender();
4208
+ node.resumeFrom = prevLead;
4209
+ if (preserveFollowOpacity) {
4210
+ node.resumeFrom.preserveOpacity = true;
4211
+ }
4212
+ if (prevLead.snapshot) {
4213
+ node.snapshot = prevLead.snapshot;
4214
+ node.snapshot.latestValues =
4215
+ prevLead.animationValues || prevLead.latestValues;
4216
+ }
4217
+ if (node.root && node.root.isUpdating) {
4218
+ node.isLayoutDirty = true;
4219
+ }
4220
+ const { crossfade } = node.options;
4221
+ if (crossfade === false) {
4222
+ prevLead.hide();
4223
+ }
4224
+ /**
4225
+ * TODO:
4226
+ * - Test border radius when previous node was deleted
4227
+ * - boxShadow mixing
4228
+ * - Shared between element A in scrolled container and element B (scroll stays the same or changes)
4229
+ * - Shared between element A in transformed container and element B (transform stays the same or changes)
4230
+ * - Shared between element A in scrolled page and element B (scroll stays the same or changes)
4231
+ * ---
4232
+ * - Crossfade opacity of root nodes
4233
+ * - layoutId changes after animation
4234
+ * - layoutId changes mid animation
4235
+ */
4236
+ }
4237
+ }
4238
+ exitAnimationComplete() {
4239
+ this.members.forEach((node) => {
4240
+ const { options, resumingFrom } = node;
4241
+ options.onExitComplete && options.onExitComplete();
4242
+ if (resumingFrom) {
4243
+ resumingFrom.options.onExitComplete &&
4244
+ resumingFrom.options.onExitComplete();
4245
+ }
4246
+ });
4247
+ }
4248
+ scheduleRender() {
4249
+ this.members.forEach((node) => {
4250
+ node.instance && node.scheduleRender(false);
4251
+ });
4252
+ }
4253
+ /**
4254
+ * Clear any leads that have been removed this render to prevent them from being
4255
+ * used in future animations and to prevent memory leaks
4256
+ */
4257
+ removeLeadSnapshot() {
4258
+ if (this.lead && this.lead.snapshot) {
4259
+ this.lead.snapshot = undefined;
4260
+ }
4261
+ }
4262
+ }
4263
+
4264
+ /**
4265
+ * Global registry for shared layout IDs (document-scoped).
4266
+ * This enables shared layout animations between elements with matching
4267
+ * `data-layout-id` attributes across the entire document.
4268
+ *
4269
+ * @example
4270
+ * ```html
4271
+ * <!-- These elements will animate between each other -->
4272
+ * <div data-layout-id="hero">Item A</div>
4273
+ * <div data-layout-id="hero">Item B</div>
4274
+ * ```
4275
+ */
4276
+ const sharedLayoutRegistry = new Map();
4277
+ /**
4278
+ * Register a projection node with a shared layout ID.
4279
+ * When a node with the same layoutId already exists, the new node
4280
+ * will resume from the previous lead node to create a crossfade animation.
4281
+ *
4282
+ * @param layoutId - The shared layout ID
4283
+ * @param node - The projection node to register
4284
+ * @param preserveFollowOpacity - Whether to preserve opacity during crossfade
4285
+ */
4286
+ function registerSharedLayoutNode(layoutId, node, preserveFollowOpacity) {
4287
+ if (!sharedLayoutRegistry.has(layoutId)) {
4288
+ sharedLayoutRegistry.set(layoutId, new NodeStack());
4289
+ }
4290
+ const stack = sharedLayoutRegistry.get(layoutId);
4291
+ stack.add(node);
4292
+ stack.promote(node, preserveFollowOpacity);
4293
+ }
4294
+ /**
4295
+ * Unregister a projection node from the shared layout registry.
4296
+ * This should be called when the element is removed from the DOM
4297
+ * or when its layout ID changes.
4298
+ *
4299
+ * @param layoutId - The shared layout ID
4300
+ * @param node - The projection node to unregister
4301
+ */
4302
+ function unregisterSharedLayoutNode(layoutId, node) {
4303
+ const stack = sharedLayoutRegistry.get(layoutId);
4304
+ if (!stack)
4305
+ return;
4306
+ stack.remove(node);
4307
+ // Clean up empty stacks
4308
+ if (stack.members.length === 0) {
4309
+ sharedLayoutRegistry.delete(layoutId);
4310
+ }
4311
+ }
4312
+ /**
4313
+ * Get the NodeStack for a shared layout ID.
4314
+ * Useful for checking if a layout ID already has registered nodes.
4315
+ *
4316
+ * @param layoutId - The shared layout ID
4317
+ * @returns The NodeStack for this layout ID, or undefined if not registered
4318
+ */
4319
+ function getSharedLayoutStack(layoutId) {
4320
+ return sharedLayoutRegistry.get(layoutId);
4321
+ }
4322
+ /**
4323
+ * Get the current lead node for a shared layout ID.
4324
+ *
4325
+ * @param layoutId - The shared layout ID
4326
+ * @returns The lead projection node, or undefined if not registered
4327
+ */
4328
+ function getSharedLayoutLead(layoutId) {
4329
+ const stack = sharedLayoutRegistry.get(layoutId);
4330
+ return stack?.lead;
4331
+ }
4332
+ /**
4333
+ * Clear all shared layout registrations.
4334
+ * Mainly useful for testing purposes.
4335
+ */
4336
+ function clearSharedLayoutRegistry() {
4337
+ sharedLayoutRegistry.clear();
4338
+ }
4339
+ /**
4340
+ * Check if a layout ID has any registered nodes.
4341
+ *
4342
+ * @param layoutId - The shared layout ID
4343
+ * @returns True if the layout ID has registered nodes
4344
+ */
4345
+ function hasSharedLayoutNodes(layoutId) {
4346
+ const stack = sharedLayoutRegistry.get(layoutId);
4347
+ return stack !== undefined && stack.members.length > 0;
4348
+ }
4349
+ /**
4350
+ * Trigger exit animation complete callbacks for all nodes in a layout group.
4351
+ *
4352
+ * @param layoutId - The shared layout ID
4353
+ */
4354
+ function notifyExitAnimationComplete(layoutId) {
4355
+ const stack = sharedLayoutRegistry.get(layoutId);
4356
+ if (stack) {
4357
+ stack.exitAnimationComplete();
4358
+ }
4359
+ }
4360
+ /**
4361
+ * Schedule render for all nodes in a shared layout group.
4362
+ *
4363
+ * @param layoutId - The shared layout ID
4364
+ */
4365
+ function scheduleSharedLayoutRender(layoutId) {
4366
+ const stack = sharedLayoutRegistry.get(layoutId);
4367
+ if (stack) {
4368
+ stack.scheduleRender();
4369
+ }
4370
+ }
4371
+
4372
+ /**
4373
+ * Helper to create a LayoutNodeFactory from concrete implementations.
4374
+ * This is designed to be called by framer-motion to provide the concrete
4375
+ * HTMLProjectionNode and HTMLVisualElement classes.
4376
+ */
4377
+ function createLayoutNodeFactory(config) {
4378
+ const { ProjectionNode, VisualElement } = config;
4379
+ return {
4380
+ createProjectionNode(element, parent, options = {}) {
4381
+ const latestValues = {};
4382
+ // Get layoutId from options or data attribute
4383
+ const layoutId = options.layoutId ?? element.dataset?.layoutId ?? undefined;
4384
+ // Create visual element with minimal state
4385
+ const visualElement = new VisualElement({
4386
+ visualState: {
4387
+ latestValues,
4388
+ renderState: {
4389
+ transformOrigin: {},
4390
+ transform: {},
4391
+ style: {},
4392
+ vars: {},
4393
+ },
4394
+ },
4395
+ props: {},
4396
+ });
4397
+ // Create projection node
4398
+ const node = new ProjectionNode(latestValues, parent);
4399
+ // Configure the node
4400
+ node.setOptions({
4401
+ scheduleRender: () => {
4402
+ if (visualElement.scheduleRender) {
4403
+ visualElement.scheduleRender();
4404
+ }
4405
+ },
4406
+ visualElement,
4407
+ layout: true,
4408
+ layoutId,
4409
+ transition: options.transition ?? {
4410
+ duration: options.duration ?? 0.3,
4411
+ ease: options.ease,
4412
+ },
4413
+ });
4414
+ // Mount the node
4415
+ node.mount(element);
4416
+ // Link visual element to projection
4417
+ visualElement.projection = node;
4418
+ // Register with shared layout registry if layoutId is present
4419
+ if (layoutId) {
4420
+ registerSharedLayoutNode(layoutId, node);
4421
+ // Store original unmount for cleanup
4422
+ const originalUnmount = node.unmount?.bind(node);
4423
+ node.unmount = () => {
4424
+ unregisterSharedLayoutNode(layoutId, node);
4425
+ if (originalUnmount) {
4426
+ originalUnmount();
4427
+ }
4428
+ };
4429
+ }
4430
+ // Set up animation listener
4431
+ node.addEventListener("didUpdate", ({ delta, hasLayoutChanged, }) => {
4432
+ if (node.resumeFrom) {
4433
+ node.resumingFrom = node.resumeFrom;
4434
+ if (node.resumingFrom) {
4435
+ node.resumingFrom.resumingFrom = undefined;
4436
+ }
4437
+ }
4438
+ if (hasLayoutChanged) {
4439
+ node.setAnimationOrigin(delta);
4440
+ node.startAnimation(options.transition ?? {
4441
+ duration: options.duration ?? 0.3,
4442
+ ease: options.ease,
4443
+ });
4444
+ }
4445
+ });
4446
+ return node;
4447
+ },
4448
+ createVisualElement(_element, _options = {}) {
4449
+ // This is typically not called directly - visual elements
4450
+ // are created as part of createProjectionNode
4451
+ const latestValues = {};
4452
+ return new VisualElement({
4453
+ visualState: {
4454
+ latestValues,
4455
+ renderState: {
4456
+ transformOrigin: {},
4457
+ transform: {},
4458
+ style: {},
4459
+ vars: {},
4460
+ },
4461
+ },
4462
+ props: {},
4463
+ });
4464
+ },
4465
+ };
4466
+ }
4467
+ /**
4468
+ * Initialize the layout system with framer-motion's implementations.
4469
+ * Call this function once at app initialization to enable animateLayout().
4470
+ *
4471
+ * @example
4472
+ * // In framer-motion or your app initialization
4473
+ * import { HTMLProjectionNode, HTMLVisualElement } from 'framer-motion'
4474
+ * import { initLayoutSystem } from 'motion-dom'
4475
+ *
4476
+ * initLayoutSystem({
4477
+ * ProjectionNode: HTMLProjectionNode,
4478
+ * VisualElement: HTMLVisualElement,
4479
+ * })
4480
+ */
4481
+ function initLayoutSystem(config) {
4482
+ const factory = createLayoutNodeFactory(config);
4483
+ setLayoutNodeFactory(factory);
4484
+ }
4485
+
3723
4486
  const { schedule: microtask, cancel: cancelMicrotask } =
3724
4487
  /* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
3725
4488
 
@@ -3967,6 +4730,609 @@ function press(targetOrSelector, onPressStart, options = {}) {
3967
4730
  return cancelEvents;
3968
4731
  }
3969
4732
 
4733
+ const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
4734
+ const numBorders = borders.length;
4735
+ const asNumber$1 = (value) => typeof value === "string" ? parseFloat(value) : value;
4736
+ const isPx = (value) => typeof value === "number" || px.test(value);
4737
+ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
4738
+ if (shouldCrossfadeOpacity) {
4739
+ target.opacity = mixNumber$1(0, lead.opacity ?? 1, easeCrossfadeIn(progress));
4740
+ target.opacityExit = mixNumber$1(follow.opacity ?? 1, 0, easeCrossfadeOut(progress));
4741
+ }
4742
+ else if (isOnlyMember) {
4743
+ target.opacity = mixNumber$1(follow.opacity ?? 1, lead.opacity ?? 1, progress);
4744
+ }
4745
+ /**
4746
+ * Mix border radius
4747
+ */
4748
+ for (let i = 0; i < numBorders; i++) {
4749
+ const borderLabel = `border${borders[i]}Radius`;
4750
+ let followRadius = getRadius(follow, borderLabel);
4751
+ let leadRadius = getRadius(lead, borderLabel);
4752
+ if (followRadius === undefined && leadRadius === undefined)
4753
+ continue;
4754
+ followRadius || (followRadius = 0);
4755
+ leadRadius || (leadRadius = 0);
4756
+ const canMix = followRadius === 0 ||
4757
+ leadRadius === 0 ||
4758
+ isPx(followRadius) === isPx(leadRadius);
4759
+ if (canMix) {
4760
+ target[borderLabel] = Math.max(mixNumber$1(asNumber$1(followRadius), asNumber$1(leadRadius), progress), 0);
4761
+ if (percent.test(leadRadius) || percent.test(followRadius)) {
4762
+ target[borderLabel] += "%";
4763
+ }
4764
+ }
4765
+ else {
4766
+ target[borderLabel] = leadRadius;
4767
+ }
4768
+ }
4769
+ /**
4770
+ * Mix rotation
4771
+ */
4772
+ if (follow.rotate || lead.rotate) {
4773
+ target.rotate = mixNumber$1(follow.rotate || 0, lead.rotate || 0, progress);
4774
+ }
4775
+ }
4776
+ function getRadius(values, radiusName) {
4777
+ return values[radiusName] !== undefined
4778
+ ? values[radiusName]
4779
+ : values.borderRadius;
4780
+ }
4781
+ const easeCrossfadeIn = /*@__PURE__*/ compress(0, 0.5, motionUtils.circOut);
4782
+ const easeCrossfadeOut = /*@__PURE__*/ compress(0.5, 0.95, motionUtils.noop);
4783
+ function compress(min, max, easing) {
4784
+ return (p) => {
4785
+ // Could replace ifs with clamp
4786
+ if (p < min)
4787
+ return 0;
4788
+ if (p > max)
4789
+ return 1;
4790
+ return easing(motionUtils.progress(min, max, p));
4791
+ };
4792
+ }
4793
+
4794
+ /**
4795
+ * Bounding boxes tend to be defined as top, left, right, bottom. For various operations
4796
+ * it's easier to consider each axis individually. This function returns a bounding box
4797
+ * as a map of single-axis min/max values.
4798
+ */
4799
+ function convertBoundingBoxToBox({ top, left, right, bottom, }) {
4800
+ return {
4801
+ x: { min: left, max: right },
4802
+ y: { min: top, max: bottom },
4803
+ };
4804
+ }
4805
+ function convertBoxToBoundingBox({ x, y }) {
4806
+ return { top: y.min, right: x.max, bottom: y.max, left: x.min };
4807
+ }
4808
+ /**
4809
+ * Applies a TransformPoint function to a bounding box. TransformPoint is usually a function
4810
+ * provided by Framer to allow measured points to be corrected for device scaling. This is used
4811
+ * when measuring DOM elements and DOM event points.
4812
+ */
4813
+ function transformBoxPoints(point, transformPoint) {
4814
+ if (!transformPoint)
4815
+ return point;
4816
+ const topLeft = transformPoint({ x: point.left, y: point.top });
4817
+ const bottomRight = transformPoint({ x: point.right, y: point.bottom });
4818
+ return {
4819
+ top: topLeft.y,
4820
+ left: topLeft.x,
4821
+ bottom: bottomRight.y,
4822
+ right: bottomRight.x,
4823
+ };
4824
+ }
4825
+
4826
+ /**
4827
+ * Reset an axis to the provided origin box.
4828
+ *
4829
+ * This is a mutative operation.
4830
+ */
4831
+ function copyAxisInto(axis, originAxis) {
4832
+ axis.min = originAxis.min;
4833
+ axis.max = originAxis.max;
4834
+ }
4835
+ /**
4836
+ * Reset a box to the provided origin box.
4837
+ *
4838
+ * This is a mutative operation.
4839
+ */
4840
+ function copyBoxInto(box, originBox) {
4841
+ copyAxisInto(box.x, originBox.x);
4842
+ copyAxisInto(box.y, originBox.y);
4843
+ }
4844
+ /**
4845
+ * Reset a delta to the provided origin box.
4846
+ *
4847
+ * This is a mutative operation.
4848
+ */
4849
+ function copyAxisDeltaInto(delta, originDelta) {
4850
+ delta.translate = originDelta.translate;
4851
+ delta.scale = originDelta.scale;
4852
+ delta.originPoint = originDelta.originPoint;
4853
+ delta.origin = originDelta.origin;
4854
+ }
4855
+
4856
+ function isIdentityScale(scale) {
4857
+ return scale === undefined || scale === 1;
4858
+ }
4859
+ function hasScale({ scale, scaleX, scaleY }) {
4860
+ return (!isIdentityScale(scale) ||
4861
+ !isIdentityScale(scaleX) ||
4862
+ !isIdentityScale(scaleY));
4863
+ }
4864
+ function hasTransform(values) {
4865
+ return (hasScale(values) ||
4866
+ has2DTranslate(values) ||
4867
+ values.z ||
4868
+ values.rotate ||
4869
+ values.rotateX ||
4870
+ values.rotateY ||
4871
+ values.skewX ||
4872
+ values.skewY);
4873
+ }
4874
+ function has2DTranslate(values) {
4875
+ return is2DTranslate(values.x) || is2DTranslate(values.y);
4876
+ }
4877
+ function is2DTranslate(value) {
4878
+ return value && value !== "0%";
4879
+ }
4880
+
4881
+ /**
4882
+ * Scales a point based on a factor and an originPoint
4883
+ */
4884
+ function scalePoint(point, scale, originPoint) {
4885
+ const distanceFromOrigin = point - originPoint;
4886
+ const scaled = scale * distanceFromOrigin;
4887
+ return originPoint + scaled;
4888
+ }
4889
+ /**
4890
+ * Applies a translate/scale delta to a point
4891
+ */
4892
+ function applyPointDelta(point, translate, scale, originPoint, boxScale) {
4893
+ if (boxScale !== undefined) {
4894
+ point = scalePoint(point, boxScale, originPoint);
4895
+ }
4896
+ return scalePoint(point, scale, originPoint) + translate;
4897
+ }
4898
+ /**
4899
+ * Applies a translate/scale delta to an axis
4900
+ */
4901
+ function applyAxisDelta(axis, translate = 0, scale = 1, originPoint, boxScale) {
4902
+ axis.min = applyPointDelta(axis.min, translate, scale, originPoint, boxScale);
4903
+ axis.max = applyPointDelta(axis.max, translate, scale, originPoint, boxScale);
4904
+ }
4905
+ /**
4906
+ * Applies a translate/scale delta to a box
4907
+ */
4908
+ function applyBoxDelta(box, { x, y }) {
4909
+ applyAxisDelta(box.x, x.translate, x.scale, x.originPoint);
4910
+ applyAxisDelta(box.y, y.translate, y.scale, y.originPoint);
4911
+ }
4912
+ const TREE_SCALE_SNAP_MIN = 0.999999999999;
4913
+ const TREE_SCALE_SNAP_MAX = 1.0000000000001;
4914
+ /**
4915
+ * Apply a tree of deltas to a box. We do this to calculate the effect of all the transforms
4916
+ * in a tree upon our box before then calculating how to project it into our desired viewport-relative box
4917
+ *
4918
+ * This is the final nested loop within updateLayoutDelta for future refactoring
4919
+ */
4920
+ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
4921
+ const treeLength = treePath.length;
4922
+ if (!treeLength)
4923
+ return;
4924
+ // Reset the treeScale
4925
+ treeScale.x = treeScale.y = 1;
4926
+ let node;
4927
+ let delta;
4928
+ for (let i = 0; i < treeLength; i++) {
4929
+ node = treePath[i];
4930
+ delta = node.projectionDelta;
4931
+ /**
4932
+ * TODO: Prefer to remove this, but currently we have motion components with
4933
+ * display: contents in Framer.
4934
+ */
4935
+ const { visualElement } = node.options;
4936
+ if (visualElement &&
4937
+ visualElement.props.style &&
4938
+ visualElement.props.style.display === "contents") {
4939
+ continue;
4940
+ }
4941
+ if (isSharedTransition &&
4942
+ node.options.layoutScroll &&
4943
+ node.scroll &&
4944
+ node !== node.root) {
4945
+ transformBox(box, {
4946
+ x: -node.scroll.offset.x,
4947
+ y: -node.scroll.offset.y,
4948
+ });
4949
+ }
4950
+ if (delta) {
4951
+ // Incoporate each ancestor's scale into a cumulative treeScale for this component
4952
+ treeScale.x *= delta.x.scale;
4953
+ treeScale.y *= delta.y.scale;
4954
+ // Apply each ancestor's calculated delta into this component's recorded layout box
4955
+ applyBoxDelta(box, delta);
4956
+ }
4957
+ if (isSharedTransition && hasTransform(node.latestValues)) {
4958
+ transformBox(box, node.latestValues);
4959
+ }
4960
+ }
4961
+ /**
4962
+ * Snap tree scale back to 1 if it's within a non-perceivable threshold.
4963
+ * This will help reduce useless scales getting rendered.
4964
+ */
4965
+ if (treeScale.x < TREE_SCALE_SNAP_MAX &&
4966
+ treeScale.x > TREE_SCALE_SNAP_MIN) {
4967
+ treeScale.x = 1.0;
4968
+ }
4969
+ if (treeScale.y < TREE_SCALE_SNAP_MAX &&
4970
+ treeScale.y > TREE_SCALE_SNAP_MIN) {
4971
+ treeScale.y = 1.0;
4972
+ }
4973
+ }
4974
+ function translateAxis(axis, distance) {
4975
+ axis.min = axis.min + distance;
4976
+ axis.max = axis.max + distance;
4977
+ }
4978
+ /**
4979
+ * Apply a transform to an axis from the latest resolved motion values.
4980
+ * This function basically acts as a bridge between a flat motion value map
4981
+ * and applyAxisDelta
4982
+ */
4983
+ function transformAxis(axis, axisTranslate, axisScale, boxScale, axisOrigin = 0.5) {
4984
+ const originPoint = mixNumber$1(axis.min, axis.max, axisOrigin);
4985
+ // Apply the axis delta to the final axis
4986
+ applyAxisDelta(axis, axisTranslate, axisScale, originPoint, boxScale);
4987
+ }
4988
+ /**
4989
+ * Apply a transform to a box from the latest resolved motion values.
4990
+ */
4991
+ function transformBox(box, transform) {
4992
+ transformAxis(box.x, transform.x, transform.scaleX, transform.scale, transform.originX);
4993
+ transformAxis(box.y, transform.y, transform.scaleY, transform.scale, transform.originY);
4994
+ }
4995
+
4996
+ const SCALE_PRECISION = 0.0001;
4997
+ const SCALE_MIN = 1 - SCALE_PRECISION;
4998
+ const SCALE_MAX = 1 + SCALE_PRECISION;
4999
+ const TRANSLATE_PRECISION = 0.01;
5000
+ const TRANSLATE_MIN = 0 - TRANSLATE_PRECISION;
5001
+ const TRANSLATE_MAX = 0 + TRANSLATE_PRECISION;
5002
+ function calcLength(axis) {
5003
+ return axis.max - axis.min;
5004
+ }
5005
+ function isNear(value, target, maxDistance) {
5006
+ return Math.abs(value - target) <= maxDistance;
5007
+ }
5008
+ function calcAxisDelta(delta, source, target, origin = 0.5) {
5009
+ delta.origin = origin;
5010
+ delta.originPoint = mixNumber$1(source.min, source.max, delta.origin);
5011
+ delta.scale = calcLength(target) / calcLength(source);
5012
+ delta.translate =
5013
+ mixNumber$1(target.min, target.max, delta.origin) - delta.originPoint;
5014
+ if ((delta.scale >= SCALE_MIN && delta.scale <= SCALE_MAX) ||
5015
+ isNaN(delta.scale)) {
5016
+ delta.scale = 1.0;
5017
+ }
5018
+ if ((delta.translate >= TRANSLATE_MIN &&
5019
+ delta.translate <= TRANSLATE_MAX) ||
5020
+ isNaN(delta.translate)) {
5021
+ delta.translate = 0.0;
5022
+ }
5023
+ }
5024
+ function calcBoxDelta(delta, source, target, origin) {
5025
+ calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : undefined);
5026
+ calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : undefined);
5027
+ }
5028
+ function calcRelativeAxis(target, relative, parent) {
5029
+ target.min = parent.min + relative.min;
5030
+ target.max = target.min + calcLength(relative);
5031
+ }
5032
+ function calcRelativeBox(target, relative, parent) {
5033
+ calcRelativeAxis(target.x, relative.x, parent.x);
5034
+ calcRelativeAxis(target.y, relative.y, parent.y);
5035
+ }
5036
+ function calcRelativeAxisPosition(target, layout, parent) {
5037
+ target.min = layout.min - parent.min;
5038
+ target.max = target.min + calcLength(layout);
5039
+ }
5040
+ function calcRelativePosition(target, layout, parent) {
5041
+ calcRelativeAxisPosition(target.x, layout.x, parent.x);
5042
+ calcRelativeAxisPosition(target.y, layout.y, parent.y);
5043
+ }
5044
+
5045
+ /**
5046
+ * Remove a delta from a point. This is essentially the steps of applyPointDelta in reverse
5047
+ */
5048
+ function removePointDelta(point, translate, scale, originPoint, boxScale) {
5049
+ point -= translate;
5050
+ point = scalePoint(point, 1 / scale, originPoint);
5051
+ if (boxScale !== undefined) {
5052
+ point = scalePoint(point, 1 / boxScale, originPoint);
5053
+ }
5054
+ return point;
5055
+ }
5056
+ /**
5057
+ * Remove a delta from an axis. This is essentially the steps of applyAxisDelta in reverse
5058
+ */
5059
+ function removeAxisDelta(axis, translate = 0, scale = 1, origin = 0.5, boxScale, originAxis = axis, sourceAxis = axis) {
5060
+ if (percent.test(translate)) {
5061
+ translate = parseFloat(translate);
5062
+ const relativeProgress = mixNumber$1(sourceAxis.min, sourceAxis.max, translate / 100);
5063
+ translate = relativeProgress - sourceAxis.min;
5064
+ }
5065
+ if (typeof translate !== "number")
5066
+ return;
5067
+ let originPoint = mixNumber$1(originAxis.min, originAxis.max, origin);
5068
+ if (axis === originAxis)
5069
+ originPoint -= translate;
5070
+ axis.min = removePointDelta(axis.min, translate, scale, originPoint, boxScale);
5071
+ axis.max = removePointDelta(axis.max, translate, scale, originPoint, boxScale);
5072
+ }
5073
+ /**
5074
+ * Remove a transforms from an axis. This is essentially the steps of applyAxisTransforms in reverse
5075
+ * and acts as a bridge between motion values and removeAxisDelta
5076
+ */
5077
+ function removeAxisTransforms(axis, transforms, [key, scaleKey, originKey], origin, sourceAxis) {
5078
+ removeAxisDelta(axis, transforms[key], transforms[scaleKey], transforms[originKey], transforms.scale, origin, sourceAxis);
5079
+ }
5080
+ /**
5081
+ * The names of the motion values we want to apply as translation, scale and origin.
5082
+ */
5083
+ const xKeys = ["x", "scaleX", "originX"];
5084
+ const yKeys = ["y", "scaleY", "originY"];
5085
+ /**
5086
+ * Remove a transforms from an box. This is essentially the steps of applyAxisBox in reverse
5087
+ * and acts as a bridge between motion values and removeAxisDelta
5088
+ */
5089
+ function removeBoxTransforms(box, transforms, originBox, sourceBox) {
5090
+ removeAxisTransforms(box.x, transforms, xKeys, originBox ? originBox.x : undefined, sourceBox ? sourceBox.x : undefined);
5091
+ removeAxisTransforms(box.y, transforms, yKeys, originBox ? originBox.y : undefined, sourceBox ? sourceBox.y : undefined);
5092
+ }
5093
+
5094
+ const createAxisDelta = () => ({
5095
+ translate: 0,
5096
+ scale: 1,
5097
+ origin: 0,
5098
+ originPoint: 0,
5099
+ });
5100
+ const createDelta = () => ({
5101
+ x: createAxisDelta(),
5102
+ y: createAxisDelta(),
5103
+ });
5104
+ const createAxis = () => ({ min: 0, max: 0 });
5105
+ const createBox = () => ({
5106
+ x: createAxis(),
5107
+ y: createAxis(),
5108
+ });
5109
+
5110
+ function isAxisDeltaZero(delta) {
5111
+ return delta.translate === 0 && delta.scale === 1;
5112
+ }
5113
+ function isDeltaZero(delta) {
5114
+ return isAxisDeltaZero(delta.x) && isAxisDeltaZero(delta.y);
5115
+ }
5116
+ function axisEquals(a, b) {
5117
+ return a.min === b.min && a.max === b.max;
5118
+ }
5119
+ function boxEquals(a, b) {
5120
+ return axisEquals(a.x, b.x) && axisEquals(a.y, b.y);
5121
+ }
5122
+ function axisEqualsRounded(a, b) {
5123
+ return (Math.round(a.min) === Math.round(b.min) &&
5124
+ Math.round(a.max) === Math.round(b.max));
5125
+ }
5126
+ function boxEqualsRounded(a, b) {
5127
+ return axisEqualsRounded(a.x, b.x) && axisEqualsRounded(a.y, b.y);
5128
+ }
5129
+ function aspectRatio(box) {
5130
+ return calcLength(box.x) / calcLength(box.y);
5131
+ }
5132
+ function axisDeltaEquals(a, b) {
5133
+ return (a.translate === b.translate &&
5134
+ a.scale === b.scale &&
5135
+ a.originPoint === b.originPoint);
5136
+ }
5137
+
5138
+ /**
5139
+ * This should only ever be modified on the client otherwise it'll
5140
+ * persist through server requests. If we need instanced states we
5141
+ * could lazy-init via root.
5142
+ */
5143
+ const globalProjectionState = {
5144
+ /**
5145
+ * Global flag as to whether the tree has animated since the last time
5146
+ * we resized the window
5147
+ */
5148
+ hasAnimatedSinceResize: true,
5149
+ /**
5150
+ * We set this to true once, on the first update. Any nodes added to the tree beyond that
5151
+ * update will be given a `data-projection-id` attribute.
5152
+ */
5153
+ hasEverUpdated: false,
5154
+ };
5155
+
5156
+ function pixelsToPercent(pixels, axis) {
5157
+ if (axis.max === axis.min)
5158
+ return 0;
5159
+ return (pixels / (axis.max - axis.min)) * 100;
5160
+ }
5161
+ /**
5162
+ * We always correct borderRadius as a percentage rather than pixels to reduce paints.
5163
+ * For example, if you are projecting a box that is 100px wide with a 10px borderRadius
5164
+ * into a box that is 200px wide with a 20px borderRadius, that is actually a 10%
5165
+ * borderRadius in both states. If we animate between the two in pixels that will trigger
5166
+ * a paint each time. If we animate between the two in percentage we'll avoid a paint.
5167
+ */
5168
+ const correctBorderRadius = {
5169
+ correct: (latest, node) => {
5170
+ if (!node.target)
5171
+ return latest;
5172
+ /**
5173
+ * If latest is a string, if it's a percentage we can return immediately as it's
5174
+ * going to be stretched appropriately. Otherwise, if it's a pixel, convert it to a number.
5175
+ */
5176
+ if (typeof latest === "string") {
5177
+ if (px.test(latest)) {
5178
+ latest = parseFloat(latest);
5179
+ }
5180
+ else {
5181
+ return latest;
5182
+ }
5183
+ }
5184
+ /**
5185
+ * If latest is a number, it's a pixel value. We use the current viewportBox to calculate that
5186
+ * pixel value as a percentage of each axis
5187
+ */
5188
+ const x = pixelsToPercent(latest, node.target.x);
5189
+ const y = pixelsToPercent(latest, node.target.y);
5190
+ return `${x}% ${y}%`;
5191
+ },
5192
+ };
5193
+
5194
+ const correctBoxShadow = {
5195
+ correct: (latest, { treeScale, projectionDelta }) => {
5196
+ const original = latest;
5197
+ const shadow = complex.parse(latest);
5198
+ // TODO: Doesn't support multiple shadows
5199
+ if (shadow.length > 5)
5200
+ return original;
5201
+ const template = complex.createTransformer(latest);
5202
+ const offset = typeof shadow[0] !== "number" ? 1 : 0;
5203
+ // Calculate the overall context scale
5204
+ const xScale = projectionDelta.x.scale * treeScale.x;
5205
+ const yScale = projectionDelta.y.scale * treeScale.y;
5206
+ shadow[0 + offset] /= xScale;
5207
+ shadow[1 + offset] /= yScale;
5208
+ /**
5209
+ * Ideally we'd correct x and y scales individually, but because blur and
5210
+ * spread apply to both we have to take a scale average and apply that instead.
5211
+ * We could potentially improve the outcome of this by incorporating the ratio between
5212
+ * the two scales.
5213
+ */
5214
+ const averageScale = mixNumber$1(xScale, yScale, 0.5);
5215
+ // Blur
5216
+ if (typeof shadow[2 + offset] === "number")
5217
+ shadow[2 + offset] /= averageScale;
5218
+ // Spread
5219
+ if (typeof shadow[3 + offset] === "number")
5220
+ shadow[3 + offset] /= averageScale;
5221
+ return template(shadow);
5222
+ },
5223
+ };
5224
+
5225
+ const scaleCorrectors = {
5226
+ borderRadius: {
5227
+ ...correctBorderRadius,
5228
+ applyTo: [
5229
+ "borderTopLeftRadius",
5230
+ "borderTopRightRadius",
5231
+ "borderBottomLeftRadius",
5232
+ "borderBottomRightRadius",
5233
+ ],
5234
+ },
5235
+ borderTopLeftRadius: correctBorderRadius,
5236
+ borderTopRightRadius: correctBorderRadius,
5237
+ borderBottomLeftRadius: correctBorderRadius,
5238
+ borderBottomRightRadius: correctBorderRadius,
5239
+ boxShadow: correctBoxShadow,
5240
+ };
5241
+ function addScaleCorrector(correctors) {
5242
+ for (const key in correctors) {
5243
+ scaleCorrectors[key] = correctors[key];
5244
+ if (isCSSVariableName(key)) {
5245
+ scaleCorrectors[key].isCSSVariable = true;
5246
+ }
5247
+ }
5248
+ }
5249
+
5250
+ function buildProjectionTransform(delta, treeScale, latestTransform) {
5251
+ let transform = "";
5252
+ /**
5253
+ * The translations we use to calculate are always relative to the viewport coordinate space.
5254
+ * But when we apply scales, we also scale the coordinate space of an element and its children.
5255
+ * For instance if we have a treeScale (the culmination of all parent scales) of 0.5 and we need
5256
+ * to move an element 100 pixels, we actually need to move it 200 in within that scaled space.
5257
+ */
5258
+ const xTranslate = delta.x.translate / treeScale.x;
5259
+ const yTranslate = delta.y.translate / treeScale.y;
5260
+ const zTranslate = latestTransform?.z || 0;
5261
+ if (xTranslate || yTranslate || zTranslate) {
5262
+ transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
5263
+ }
5264
+ /**
5265
+ * Apply scale correction for the tree transform.
5266
+ * This will apply scale to the screen-orientated axes.
5267
+ */
5268
+ if (treeScale.x !== 1 || treeScale.y !== 1) {
5269
+ transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
5270
+ }
5271
+ if (latestTransform) {
5272
+ const { transformPerspective, rotate, rotateX, rotateY, skewX, skewY } = latestTransform;
5273
+ if (transformPerspective)
5274
+ transform = `perspective(${transformPerspective}px) ${transform}`;
5275
+ if (rotate)
5276
+ transform += `rotate(${rotate}deg) `;
5277
+ if (rotateX)
5278
+ transform += `rotateX(${rotateX}deg) `;
5279
+ if (rotateY)
5280
+ transform += `rotateY(${rotateY}deg) `;
5281
+ if (skewX)
5282
+ transform += `skewX(${skewX}deg) `;
5283
+ if (skewY)
5284
+ transform += `skewY(${skewY}deg) `;
5285
+ }
5286
+ /**
5287
+ * Apply scale to match the size of the element to the size we want it.
5288
+ * This will apply scale to the element-orientated axes.
5289
+ */
5290
+ const elementScaleX = delta.x.scale * treeScale.x;
5291
+ const elementScaleY = delta.y.scale * treeScale.y;
5292
+ if (elementScaleX !== 1 || elementScaleY !== 1) {
5293
+ transform += `scale(${elementScaleX}, ${elementScaleY})`;
5294
+ }
5295
+ return transform || "none";
5296
+ }
5297
+
5298
+ function eachAxis(callback) {
5299
+ return [callback("x"), callback("y")];
5300
+ }
5301
+
5302
+ function measureViewportBox(instance, transformPoint) {
5303
+ return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
5304
+ }
5305
+ function measurePageBox(element, rootProjectionNode, transformPagePoint) {
5306
+ const viewportBox = measureViewportBox(element, transformPagePoint);
5307
+ const { scroll } = rootProjectionNode;
5308
+ if (scroll) {
5309
+ translateAxis(viewportBox.x, scroll.offset.x);
5310
+ translateAxis(viewportBox.y, scroll.offset.y);
5311
+ }
5312
+ return viewportBox;
5313
+ }
5314
+
5315
+ const compareByDepth = (a, b) => a.depth - b.depth;
5316
+ class FlatTree {
5317
+ constructor() {
5318
+ this.children = [];
5319
+ this.isDirty = false;
5320
+ }
5321
+ add(child) {
5322
+ motionUtils.addUniqueItem(this.children, child);
5323
+ this.isDirty = true;
5324
+ }
5325
+ remove(child) {
5326
+ motionUtils.removeItem(this.children, child);
5327
+ this.isDirty = true;
5328
+ }
5329
+ forEach(callback) {
5330
+ this.isDirty && this.children.sort(compareByDepth);
5331
+ this.isDirty = false;
5332
+ this.children.forEach(callback);
5333
+ }
5334
+ }
5335
+
3970
5336
  function getComputedStyle$1(element, name) {
3971
5337
  const computedStyle = window.getComputedStyle(element);
3972
5338
  return isCSSVar(name)
@@ -4202,6 +5568,25 @@ function recordStats() {
4202
5568
  return reportStats;
4203
5569
  }
4204
5570
 
5571
+ /**
5572
+ * Timeout defined in ms
5573
+ */
5574
+ function delay(callback, timeout) {
5575
+ const start = time.now();
5576
+ const checkElapsed = ({ timestamp }) => {
5577
+ const elapsed = timestamp - start;
5578
+ if (elapsed >= timeout) {
5579
+ cancelFrame(checkElapsed);
5580
+ callback(elapsed - timeout);
5581
+ }
5582
+ };
5583
+ frame.setup(checkElapsed, true);
5584
+ return () => cancelFrame(checkElapsed);
5585
+ }
5586
+ function delayInSeconds(callback, timeout) {
5587
+ return delay(callback, motionUtils.secondsToMilliseconds(timeout));
5588
+ }
5589
+
4205
5590
  /**
4206
5591
  * Checks if an element is specifically an SVGSVGElement (the root SVG element)
4207
5592
  * in a way that works across iframes
@@ -4741,6 +6126,7 @@ const cancelSync = stepsOrder.reduce((acc, key) => {
4741
6126
 
4742
6127
  exports.AsyncMotionValueAnimation = AsyncMotionValueAnimation;
4743
6128
  exports.DOMKeyframesResolver = DOMKeyframesResolver;
6129
+ exports.FlatTree = FlatTree;
4744
6130
  exports.GroupAnimation = GroupAnimation;
4745
6131
  exports.GroupAnimationWithThen = GroupAnimationWithThen;
4746
6132
  exports.JSAnimation = JSAnimation;
@@ -4749,30 +6135,64 @@ exports.MotionValue = MotionValue;
4749
6135
  exports.NativeAnimation = NativeAnimation;
4750
6136
  exports.NativeAnimationExtended = NativeAnimationExtended;
4751
6137
  exports.NativeAnimationWrapper = NativeAnimationWrapper;
6138
+ exports.NodeStack = NodeStack;
4752
6139
  exports.ViewTransitionBuilder = ViewTransitionBuilder;
4753
6140
  exports.acceleratedValues = acceleratedValues;
4754
6141
  exports.activeAnimations = activeAnimations;
4755
6142
  exports.addAttrValue = addAttrValue;
6143
+ exports.addScaleCorrector = addScaleCorrector;
4756
6144
  exports.addStyleValue = addStyleValue;
4757
6145
  exports.alpha = alpha;
4758
6146
  exports.analyseComplexValue = analyseComplexValue;
4759
6147
  exports.animateValue = animateValue;
4760
6148
  exports.animateView = animateView;
4761
6149
  exports.animationMapKey = animationMapKey;
6150
+ exports.applyAxisDelta = applyAxisDelta;
6151
+ exports.applyBoxDelta = applyBoxDelta;
4762
6152
  exports.applyGeneratorOptions = applyGeneratorOptions;
6153
+ exports.applyPointDelta = applyPointDelta;
4763
6154
  exports.applyPxDefaults = applyPxDefaults;
6155
+ exports.applyTreeDeltas = applyTreeDeltas;
6156
+ exports.aspectRatio = aspectRatio;
4764
6157
  exports.attachSpring = attachSpring;
4765
6158
  exports.attrEffect = attrEffect;
6159
+ exports.axisDeltaEquals = axisDeltaEquals;
6160
+ exports.axisEquals = axisEquals;
6161
+ exports.axisEqualsRounded = axisEqualsRounded;
6162
+ exports.boxEquals = boxEquals;
6163
+ exports.boxEqualsRounded = boxEqualsRounded;
6164
+ exports.buildProjectionTransform = buildProjectionTransform;
6165
+ exports.calcAxisDelta = calcAxisDelta;
6166
+ exports.calcBoxDelta = calcBoxDelta;
4766
6167
  exports.calcGeneratorDuration = calcGeneratorDuration;
6168
+ exports.calcLength = calcLength;
6169
+ exports.calcRelativeAxis = calcRelativeAxis;
6170
+ exports.calcRelativeAxisPosition = calcRelativeAxisPosition;
6171
+ exports.calcRelativeBox = calcRelativeBox;
6172
+ exports.calcRelativePosition = calcRelativePosition;
4767
6173
  exports.cancelFrame = cancelFrame;
4768
6174
  exports.cancelMicrotask = cancelMicrotask;
4769
6175
  exports.cancelSync = cancelSync;
6176
+ exports.clearSharedLayoutRegistry = clearSharedLayoutRegistry;
4770
6177
  exports.collectMotionValues = collectMotionValues;
4771
6178
  exports.color = color;
6179
+ exports.compareByDepth = compareByDepth;
4772
6180
  exports.complex = complex;
4773
6181
  exports.containsCSSVariable = containsCSSVariable;
6182
+ exports.convertBoundingBoxToBox = convertBoundingBoxToBox;
6183
+ exports.convertBoxToBoundingBox = convertBoxToBoundingBox;
4774
6184
  exports.convertOffsetToTimes = convertOffsetToTimes;
6185
+ exports.copyAxisDeltaInto = copyAxisDeltaInto;
6186
+ exports.copyAxisInto = copyAxisInto;
6187
+ exports.copyBoxInto = copyBoxInto;
6188
+ exports.correctBorderRadius = correctBorderRadius;
6189
+ exports.correctBoxShadow = correctBoxShadow;
6190
+ exports.createAxis = createAxis;
6191
+ exports.createAxisDelta = createAxisDelta;
6192
+ exports.createBox = createBox;
6193
+ exports.createDelta = createDelta;
4775
6194
  exports.createGeneratorEasing = createGeneratorEasing;
6195
+ exports.createLayoutNodeFactory = createLayoutNodeFactory;
4776
6196
  exports.createRenderBatcher = createRenderBatcher;
4777
6197
  exports.cubicBezierAsString = cubicBezierAsString;
4778
6198
  exports.defaultEasing = defaultEasing;
@@ -4780,9 +6200,13 @@ exports.defaultOffset = defaultOffset;
4780
6200
  exports.defaultTransformValue = defaultTransformValue;
4781
6201
  exports.defaultValueTypes = defaultValueTypes;
4782
6202
  exports.degrees = degrees;
6203
+ exports.delay = delay;
6204
+ exports.delayInSeconds = delayInSeconds;
4783
6205
  exports.dimensionValueTypes = dimensionValueTypes;
6206
+ exports.eachAxis = eachAxis;
4784
6207
  exports.fillOffset = fillOffset;
4785
6208
  exports.fillWildcards = fillWildcards;
6209
+ exports.findCommonAncestor = findCommonAncestor;
4786
6210
  exports.findDimensionValueType = findDimensionValueType;
4787
6211
  exports.findValueType = findValueType;
4788
6212
  exports.flushKeyframeResolvers = flushKeyframeResolvers;
@@ -4794,28 +6218,39 @@ exports.getAnimatableNone = getAnimatableNone;
4794
6218
  exports.getAnimationMap = getAnimationMap;
4795
6219
  exports.getComputedStyle = getComputedStyle$1;
4796
6220
  exports.getDefaultValueType = getDefaultValueType;
6221
+ exports.getLayoutNodeFactory = getLayoutNodeFactory;
4797
6222
  exports.getMixer = getMixer;
4798
6223
  exports.getOriginIndex = getOriginIndex;
6224
+ exports.getSharedLayoutLead = getSharedLayoutLead;
6225
+ exports.getSharedLayoutStack = getSharedLayoutStack;
4799
6226
  exports.getValueAsType = getValueAsType;
4800
6227
  exports.getValueTransition = getValueTransition;
4801
6228
  exports.getVariableValue = getVariableValue;
4802
6229
  exports.getViewAnimationLayerInfo = getViewAnimationLayerInfo;
4803
6230
  exports.getViewAnimations = getViewAnimations;
6231
+ exports.globalProjectionState = globalProjectionState;
6232
+ exports.has2DTranslate = has2DTranslate;
6233
+ exports.hasScale = hasScale;
6234
+ exports.hasSharedLayoutNodes = hasSharedLayoutNodes;
6235
+ exports.hasTransform = hasTransform;
4804
6236
  exports.hex = hex;
4805
6237
  exports.hover = hover;
4806
6238
  exports.hsla = hsla;
4807
6239
  exports.hslaToRgba = hslaToRgba;
4808
6240
  exports.inertia = inertia;
6241
+ exports.initLayoutSystem = initLayoutSystem;
4809
6242
  exports.interpolate = interpolate;
4810
6243
  exports.invisibleValues = invisibleValues;
4811
6244
  exports.isCSSVariableName = isCSSVariableName;
4812
6245
  exports.isCSSVariableToken = isCSSVariableToken;
6246
+ exports.isDeltaZero = isDeltaZero;
4813
6247
  exports.isDragActive = isDragActive;
4814
6248
  exports.isDragging = isDragging;
4815
6249
  exports.isElementKeyboardAccessible = isElementKeyboardAccessible;
4816
6250
  exports.isGenerator = isGenerator;
4817
6251
  exports.isHTMLElement = isHTMLElement;
4818
6252
  exports.isMotionValue = isMotionValue;
6253
+ exports.isNear = isNear;
4819
6254
  exports.isNodeOrChild = isNodeOrChild;
4820
6255
  exports.isPrimaryPointer = isPrimaryPointer;
4821
6256
  exports.isSVGElement = isSVGElement;
@@ -4826,6 +6261,8 @@ exports.makeAnimationInstant = makeAnimationInstant;
4826
6261
  exports.mapEasingToNativeEasing = mapEasingToNativeEasing;
4827
6262
  exports.mapValue = mapValue;
4828
6263
  exports.maxGeneratorDuration = maxGeneratorDuration;
6264
+ exports.measurePageBox = measurePageBox;
6265
+ exports.measureViewportBox = measureViewportBox;
4829
6266
  exports.microtask = microtask;
4830
6267
  exports.mix = mix;
4831
6268
  exports.mixArray = mixArray;
@@ -4835,27 +6272,41 @@ exports.mixImmediate = mixImmediate;
4835
6272
  exports.mixLinearColor = mixLinearColor;
4836
6273
  exports.mixNumber = mixNumber$1;
4837
6274
  exports.mixObject = mixObject;
6275
+ exports.mixValues = mixValues;
4838
6276
  exports.mixVisibility = mixVisibility;
4839
6277
  exports.motionValue = motionValue;
6278
+ exports.notifyExitAnimationComplete = notifyExitAnimationComplete;
4840
6279
  exports.number = number;
4841
6280
  exports.numberValueTypes = numberValueTypes;
6281
+ exports.observeMutation = observeMutation;
4842
6282
  exports.observeTimeline = observeTimeline;
4843
6283
  exports.parseCSSVariable = parseCSSVariable;
4844
6284
  exports.parseValueFromTransform = parseValueFromTransform;
4845
6285
  exports.percent = percent;
6286
+ exports.pixelsToPercent = pixelsToPercent;
4846
6287
  exports.positionalKeys = positionalKeys;
6288
+ exports.preserveElementForExit = preserveElementForExit;
4847
6289
  exports.press = press;
4848
6290
  exports.progressPercentage = progressPercentage;
4849
6291
  exports.propEffect = propEffect;
4850
6292
  exports.px = px;
4851
6293
  exports.readTransformValue = readTransformValue;
4852
6294
  exports.recordStats = recordStats;
6295
+ exports.registerSharedLayoutNode = registerSharedLayoutNode;
6296
+ exports.removeAxisDelta = removeAxisDelta;
6297
+ exports.removeAxisTransforms = removeAxisTransforms;
6298
+ exports.removeBoxTransforms = removeBoxTransforms;
6299
+ exports.removePointDelta = removePointDelta;
4853
6300
  exports.resize = resize;
4854
6301
  exports.resolveElements = resolveElements;
4855
6302
  exports.rgbUnit = rgbUnit;
4856
6303
  exports.rgba = rgba;
4857
6304
  exports.scale = scale;
6305
+ exports.scaleCorrectors = scaleCorrectors;
6306
+ exports.scalePoint = scalePoint;
6307
+ exports.scheduleSharedLayoutRender = scheduleSharedLayoutRender;
4858
6308
  exports.setDragLock = setDragLock;
6309
+ exports.setLayoutNodeFactory = setLayoutNodeFactory;
4859
6310
  exports.setStyle = setStyle;
4860
6311
  exports.spring = spring;
4861
6312
  exports.springValue = springValue;
@@ -4874,9 +6325,15 @@ exports.sync = sync;
4874
6325
  exports.testValueType = testValueType;
4875
6326
  exports.time = time;
4876
6327
  exports.transform = transform;
6328
+ exports.transformAxis = transformAxis;
6329
+ exports.transformBox = transformBox;
6330
+ exports.transformBoxPoints = transformBoxPoints;
4877
6331
  exports.transformPropOrder = transformPropOrder;
4878
6332
  exports.transformProps = transformProps;
4879
6333
  exports.transformValue = transformValue;
4880
6334
  exports.transformValueTypes = transformValueTypes;
6335
+ exports.translateAxis = translateAxis;
6336
+ exports.unregisterSharedLayoutNode = unregisterSharedLayoutNode;
6337
+ exports.unstable_animateLayout = animateLayout;
4881
6338
  exports.vh = vh;
4882
6339
  exports.vw = vw;