motion-dom 12.35.2 → 12.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -60,8 +60,7 @@ function createRenderStep(runNextFrame, stepName) {
60
60
  const queue = addToCurrentFrame ? thisFrame : nextFrame;
61
61
  if (keepAlive)
62
62
  toKeepAlive.add(callback);
63
- if (!queue.has(callback))
64
- queue.add(callback);
63
+ queue.add(callback);
65
64
  return callback;
66
65
  },
67
66
  /**
@@ -86,7 +85,10 @@ function createRenderStep(runNextFrame, stepName) {
86
85
  return;
87
86
  }
88
87
  isProcessing = true;
89
- [thisFrame, nextFrame] = [nextFrame, thisFrame];
88
+ // Swap this frame and the next to avoid GC
89
+ const prevFrame = thisFrame;
90
+ thisFrame = nextFrame;
91
+ nextFrame = prevFrame;
90
92
  // Execute this frame
91
93
  thisFrame.forEach(triggerCallback);
92
94
  /**
@@ -125,11 +127,12 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
125
127
  }, {});
126
128
  const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;
127
129
  const processBatch = () => {
128
- const timestamp = motionUtils.MotionGlobalConfig.useManualTiming
130
+ const useManualTiming = motionUtils.MotionGlobalConfig.useManualTiming;
131
+ const timestamp = useManualTiming
129
132
  ? state.timestamp
130
133
  : performance.now();
131
134
  runNextFrame = false;
132
- if (!motionUtils.MotionGlobalConfig.useManualTiming) {
135
+ if (!useManualTiming) {
133
136
  state.delta = useDefaultElapsed
134
137
  ? 1000 / 60
135
138
  : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
@@ -1862,8 +1865,18 @@ function removeNonTranslationalTransform(visualElement) {
1862
1865
  }
1863
1866
  const positionalValues = {
1864
1867
  // Dimensions
1865
- width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
1866
- height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
1868
+ width: ({ x }, { paddingLeft = "0", paddingRight = "0", boxSizing }) => {
1869
+ const width = x.max - x.min;
1870
+ return boxSizing === "border-box"
1871
+ ? width
1872
+ : width - parseFloat(paddingLeft) - parseFloat(paddingRight);
1873
+ },
1874
+ height: ({ y }, { paddingTop = "0", paddingBottom = "0", boxSizing }) => {
1875
+ const height = y.max - y.min;
1876
+ return boxSizing === "border-box"
1877
+ ? height
1878
+ : height - parseFloat(paddingTop) - parseFloat(paddingBottom);
1879
+ },
1867
1880
  top: (_bbox, { top }) => parseFloat(top),
1868
1881
  left: (_bbox, { left }) => parseFloat(left),
1869
1882
  bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
@@ -2555,7 +2568,9 @@ class AsyncMotionValueAnimation extends WithPromise {
2555
2568
  * If we can't animate this value with the resolved keyframes
2556
2569
  * then we should complete it immediately.
2557
2570
  */
2571
+ let canAnimateValue = true;
2558
2572
  if (!canAnimate(keyframes, name, type, velocity)) {
2573
+ canAnimateValue = false;
2559
2574
  if (motionUtils.MotionGlobalConfig.instantAnimations || !delay) {
2560
2575
  onUpdate?.(getFinalKeyframe$1(keyframes, options, finalKeyframe));
2561
2576
  }
@@ -2592,8 +2607,13 @@ class AsyncMotionValueAnimation extends WithPromise {
2592
2607
  * Animate via WAAPI if possible. If this is a handoff animation, the optimised animation will be running via
2593
2608
  * WAAPI. Therefore, this animation must be JS to ensure it runs "under" the
2594
2609
  * optimised animation.
2610
+ *
2611
+ * Also skip WAAPI when keyframes aren't animatable, as the resolved
2612
+ * values may not be valid CSS and would trigger browser warnings.
2595
2613
  */
2596
- const useWaapi = !isHandoff && supportsBrowserAnimation(resolvedOptions);
2614
+ const useWaapi = canAnimateValue &&
2615
+ !isHandoff &&
2616
+ supportsBrowserAnimation(resolvedOptions);
2597
2617
  const element = resolvedOptions.motionValue?.owner?.current;
2598
2618
  const animation = useWaapi
2599
2619
  ? new NativeAnimationExtended({
@@ -4201,7 +4221,9 @@ const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
4201
4221
  * that works across iframes
4202
4222
  */
4203
4223
  function isHTMLElement(element) {
4204
- return motionUtils.isObject(element) && "offsetHeight" in element;
4224
+ return (motionUtils.isObject(element) &&
4225
+ "offsetHeight" in element &&
4226
+ !("ownerSVGElement" in element));
4205
4227
  }
4206
4228
 
4207
4229
  const translateAlias$1 = {
@@ -4981,7 +5003,16 @@ function attachFollow(value, source, options = {}) {
4981
5003
  frame.postRender(scheduleAnimation);
4982
5004
  }, stopAnimation);
4983
5005
  if (isMotionValue(source)) {
4984
- const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
5006
+ let skipNextAnimation = options.skipInitialAnimation === true;
5007
+ const removeSourceOnChange = source.on("change", (v) => {
5008
+ if (skipNextAnimation) {
5009
+ skipNextAnimation = false;
5010
+ value.jump(parseValue(v, unit), false);
5011
+ }
5012
+ else {
5013
+ value.set(parseValue(v, unit));
5014
+ }
5015
+ });
4985
5016
  const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
4986
5017
  return () => {
4987
5018
  removeSourceOnChange();
@@ -9095,6 +9126,12 @@ function notifyLayoutUpdate(node) {
9095
9126
  axisSnapshot.max = axisSnapshot.min + length;
9096
9127
  });
9097
9128
  }
9129
+ else if (animationType === "x" || animationType === "y") {
9130
+ const snapAxis = animationType === "x" ? "y" : "x";
9131
+ copyAxisInto(isShared
9132
+ ? snapshot.measuredBox[snapAxis]
9133
+ : snapshot.layoutBox[snapAxis], layout[snapAxis]);
9134
+ }
9098
9135
  else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
9099
9136
  eachAxis((axis) => {
9100
9137
  const axisSnapshot = isShared