motion-dom 13.1.1-alpha.0 → 13.1.1

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 (32) hide show
  1. package/dist/cjs/index.js +29 -72
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/interfaces/visual-element-target.mjs +2 -1
  4. package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
  5. package/dist/es/animation/waapi/supports/waapi.mjs +3 -6
  6. package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
  7. package/dist/es/animation/waapi/utils/accelerated-values.mjs +1 -12
  8. package/dist/es/animation/waapi/utils/accelerated-values.mjs.map +1 -1
  9. package/dist/es/effects/style/index.mjs +4 -11
  10. package/dist/es/effects/style/index.mjs.map +1 -1
  11. package/dist/es/effects/style/transform.mjs +0 -5
  12. package/dist/es/effects/style/transform.mjs.map +1 -1
  13. package/dist/es/index.mjs +1 -1
  14. package/dist/es/projection/node/create-projection-node.mjs +8 -13
  15. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  16. package/dist/es/projection/styles/transform.mjs +1 -3
  17. package/dist/es/projection/styles/transform.mjs.map +1 -1
  18. package/dist/es/projection/utils/has-transform.mjs +1 -7
  19. package/dist/es/projection/utils/has-transform.mjs.map +1 -1
  20. package/dist/es/render/VisualElement.mjs +2 -5
  21. package/dist/es/render/VisualElement.mjs.map +1 -1
  22. package/dist/es/render/html/utils/build-styles.mjs +12 -10
  23. package/dist/es/render/html/utils/build-styles.mjs.map +1 -1
  24. package/dist/es/render/html/utils/build-transform.mjs +0 -5
  25. package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
  26. package/dist/es/value/index.mjs.map +1 -1
  27. package/dist/index.d.ts +1 -3
  28. package/dist/motion-dom.dev.js +29 -72
  29. package/dist/motion-dom.js +1 -1
  30. package/dist/size-rollup-style-effect.js +1 -1
  31. package/dist/size-rollup-style-effect.js.map +1 -1
  32. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -2480,15 +2480,6 @@ const acceleratedValues = new Set([
2480
2480
  "transform",
2481
2481
  "backgroundColor",
2482
2482
  ]);
2483
- function hasIndependentTransform(values) {
2484
- if (!values)
2485
- return false;
2486
- for (const key in values) {
2487
- if (transformProps.has(key))
2488
- return true;
2489
- }
2490
- return false;
2491
- }
2492
2483
 
2493
2484
  const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
2494
2485
  function hasBrowserOnlyColors(keyframes) {
@@ -2528,8 +2519,7 @@ function supportsBrowserAnimation(options) {
2528
2519
  !(subject instanceof SVGElement)) {
2529
2520
  return false;
2530
2521
  }
2531
- const owner = motionValue.owner;
2532
- const { onUpdate, transformTemplate } = owner.getProps();
2522
+ const { onUpdate, transformTemplate } = motionValue.owner.getProps();
2533
2523
  return (supportsWaapi() &&
2534
2524
  name &&
2535
2525
  /**
@@ -2539,9 +2529,7 @@ function supportsBrowserAnimation(options) {
2539
2529
  (acceleratedValues.has(name) ||
2540
2530
  (colorProperties.has(name) &&
2541
2531
  hasBrowserOnlyColors(keyframes))) &&
2542
- (name !== "transform" ||
2543
- (!transformTemplate &&
2544
- !hasIndependentTransform(owner.latestValues))) &&
2532
+ (name !== "transform" || !transformTemplate) &&
2545
2533
  /**
2546
2534
  * If we're outputting values to onUpdate then we can't use WAAPI as there's
2547
2535
  * no way to read the value from WAAPI every frame.
@@ -3688,6 +3676,7 @@ function getOptimisedAppearId(visualElement) {
3688
3676
  return visualElement.props[optimizedAppearDataAttribute];
3689
3677
  }
3690
3678
 
3679
+ const isBrowser$1 = typeof window !== "undefined";
3691
3680
  /**
3692
3681
  * Decide whether we should block this animation. Previously, we achieved this
3693
3682
  * just by checking whether the key was listed in protectedKeys, but this
@@ -3751,7 +3740,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
3751
3740
  * to see if we're handling off from an existing animation.
3752
3741
  */
3753
3742
  let isHandoff = false;
3754
- if (window.MotionHandoffAnimation) {
3743
+ if (isBrowser$1 && window.MotionHandoffAnimation) {
3755
3744
  const appearId = getOptimisedAppearId(visualElement);
3756
3745
  if (appearId) {
3757
3746
  const startTime = window.MotionHandoffAnimation(appearId, key, frame);
@@ -4512,37 +4501,25 @@ function buildTransform$1(state) {
4512
4501
  ? `${pathRotation}deg`
4513
4502
  : pathRotation}) `;
4514
4503
  }
4515
- const userTransform = state.latest.transform;
4516
- if (userTransform && userTransform !== "none") {
4517
- transformIsDefault = false;
4518
- transform += userTransform;
4519
- }
4520
4504
  return transformIsDefault ? "none" : transform.trim();
4521
4505
  }
4522
4506
 
4523
4507
  const originProps = new Set(["originX", "originY", "originZ"]);
4524
- /**
4525
- * Internal key for the computed transform channel. The user "transform"
4526
- * value now composes into this channel, so it can't share the "transform"
4527
- * key. Prefixed with $ so it can never collide with a real style key
4528
- * (like "transformStyle", which is the transform-style CSS property).
4529
- */
4530
- const computedTransform = "$transform";
4531
4508
  const addStyleValue = (element, state, key, value) => {
4532
4509
  let render = undefined;
4533
4510
  let computed = undefined;
4534
- if (transformProps.has(key) || key === "transform") {
4535
- if (!state.get(computedTransform)) {
4511
+ if (transformProps.has(key)) {
4512
+ if (!state.get("transform")) {
4536
4513
  // If this is an HTML element, we need to set the transform-box to fill-box
4537
4514
  // to normalise the transform relative to the element's bounding box
4538
4515
  if (!isHTMLElement(element) && !state.get("transformBox")) {
4539
4516
  addStyleValue(element, state, "transformBox", new MotionValue("fill-box"));
4540
4517
  }
4541
- state.set(computedTransform, new MotionValue("none"), () => {
4518
+ state.set("transform", new MotionValue("none"), () => {
4542
4519
  element.style.transform = buildTransform$1(state);
4543
4520
  });
4544
4521
  }
4545
- computed = state.get(computedTransform);
4522
+ computed = state.get("transform");
4546
4523
  }
4547
4524
  else if (originProps.has(key)) {
4548
4525
  if (!state.get("transformOrigin")) {
@@ -6817,10 +6794,7 @@ class VisualElement {
6817
6794
  }
6818
6795
  if (value.accelerate &&
6819
6796
  acceleratedValues.has(key) &&
6820
- this.current instanceof HTMLElement &&
6821
- (key !== "transform" ||
6822
- (!this.props.transformTemplate &&
6823
- !hasIndependentTransform(this.latestValues)))) {
6797
+ this.current instanceof HTMLElement) {
6824
6798
  const { factory, keyframes, times, ease, duration } = value.accelerate;
6825
6799
  const animation = new NativeAnimation({
6826
6800
  element: this.current,
@@ -7215,12 +7189,6 @@ function hasTransform(values) {
7215
7189
  values.skewX ||
7216
7190
  values.skewY);
7217
7191
  }
7218
- function hasVisualTransform(values) {
7219
- return (hasTransform(values) ||
7220
- (values.transform &&
7221
- values.transform !== "none" &&
7222
- values.transform !== ""));
7223
- }
7224
7192
  function has2DTranslate(values) {
7225
7193
  return is2DTranslate(values.x) || is2DTranslate(values.y);
7226
7194
  }
@@ -7415,11 +7383,6 @@ function buildTransform(latestValues, transform, transformTemplate) {
7415
7383
  transformIsDefault = false;
7416
7384
  transformString += `rotate(${getValueAsType(pathRotation, numberValueTypes.pathRotation)}) `;
7417
7385
  }
7418
- const userTransform = latestValues.transform;
7419
- if (userTransform && userTransform !== "none") {
7420
- transformIsDefault = false;
7421
- transformString += userTransform;
7422
- }
7423
7386
  transformString = transformString.trim();
7424
7387
  // If we have a custom `transform` template, pass our transform values and
7425
7388
  // generated transformString to that before returning
@@ -7445,7 +7408,7 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
7445
7408
  */
7446
7409
  for (const key in latestValues) {
7447
7410
  const value = latestValues[key];
7448
- if (transformProps.has(key) || key === "transform") {
7411
+ if (transformProps.has(key)) {
7449
7412
  // If this is a transform, flag to enable further transform processing
7450
7413
  hasTransform = true;
7451
7414
  continue;
@@ -7468,15 +7431,17 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
7468
7431
  }
7469
7432
  }
7470
7433
  }
7471
- if (hasTransform || transformTemplate) {
7472
- style.transform = buildTransform(latestValues, state.transform, transformTemplate);
7473
- }
7474
- else if (style.transform) {
7475
- /**
7476
- * If we have previously created a transform but currently don't have any,
7477
- * reset transform style to none.
7478
- */
7479
- style.transform = "none";
7434
+ if (!latestValues.transform) {
7435
+ if (hasTransform || transformTemplate) {
7436
+ style.transform = buildTransform(latestValues, state.transform, transformTemplate);
7437
+ }
7438
+ else if (style.transform) {
7439
+ /**
7440
+ * If we have previously created a transform but currently don't have any,
7441
+ * reset transform style to none.
7442
+ */
7443
+ style.transform = "none";
7444
+ }
7480
7445
  }
7481
7446
  /**
7482
7447
  * Build a transformOrigin style. Uses the same defaults as the browser for
@@ -8481,7 +8446,7 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
8481
8446
  transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
8482
8447
  }
8483
8448
  if (latestTransform) {
8484
- const { transformPerspective, rotate, pathRotation, rotateX, rotateY, skewX, skewY, transform: userTransform, } = latestTransform;
8449
+ const { transformPerspective, rotate, pathRotation, rotateX, rotateY, skewX, skewY, } = latestTransform;
8485
8450
  if (transformPerspective)
8486
8451
  transform = `perspective(${transformPerspective}px) ${transform}`;
8487
8452
  if (rotate)
@@ -8497,8 +8462,6 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
8497
8462
  transform += `skewX(${skewX}deg) `;
8498
8463
  if (skewY)
8499
8464
  transform += `skewY(${skewY}deg) `;
8500
- if (userTransform && userTransform !== "none")
8501
- transform += `${userTransform} `;
8502
8465
  }
8503
8466
  /**
8504
8467
  * Apply scale to match the size of the element to the size we want it.
@@ -8742,14 +8705,14 @@ const transformAxes = ["", "X", "Y", "Z"];
8742
8705
  */
8743
8706
  const animationTarget = 1000;
8744
8707
  let id = 0;
8745
- function resetDistortingTransform(key, visualElement, values, sharedAnimationValues, resetValue = 0) {
8708
+ function resetDistortingTransform(key, visualElement, values, sharedAnimationValues) {
8746
8709
  const { latestValues } = visualElement;
8747
- // Record the distorting transform and then temporarily reset it
8710
+ // Record the distorting transform and then temporarily set it to 0
8748
8711
  if (latestValues[key]) {
8749
8712
  values[key] = latestValues[key];
8750
- visualElement.setStaticValue(key, resetValue);
8713
+ visualElement.setStaticValue(key, 0);
8751
8714
  if (sharedAnimationValues) {
8752
- sharedAnimationValues[key] = resetValue;
8715
+ sharedAnimationValues[key] = 0;
8753
8716
  }
8754
8717
  }
8755
8718
  }
@@ -9328,7 +9291,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
9328
9291
  if (isResetRequested &&
9329
9292
  this.instance &&
9330
9293
  (hasProjection ||
9331
- hasVisualTransform(this.latestValues) ||
9294
+ hasTransform(this.latestValues) ||
9332
9295
  transformTemplateHasChanged)) {
9333
9296
  resetTransform(this.instance, transformTemplateValue);
9334
9297
  this.shouldResetTransform = false;
@@ -9996,8 +9959,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
9996
9959
  latestValues.rotateY ||
9997
9960
  latestValues.rotateZ ||
9998
9961
  latestValues.skewX ||
9999
- latestValues.skewY ||
10000
- (latestValues.transform && latestValues.transform !== "none")) {
9962
+ latestValues.skewY) {
10001
9963
  hasDistortingTransform = true;
10002
9964
  }
10003
9965
  // If there's no distorting values, we don't need to do any more.
@@ -10007,9 +9969,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
10007
9969
  if (latestValues.z) {
10008
9970
  resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
10009
9971
  }
10010
- if (latestValues.transform && latestValues.transform !== "none") {
10011
- resetDistortingTransform("transform", visualElement, resetValues, this.animationValues, "none");
10012
- }
10013
9972
  // Check the skew and rotate value of all axes and reset to 0
10014
9973
  for (let i = 0; i < transformAxes.length; i++) {
10015
9974
  resetDistortingTransform(`rotate${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
@@ -10059,8 +10018,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
10059
10018
  targetStyle.pointerEvents =
10060
10019
  resolveMotionValue(styleProp?.pointerEvents) || "";
10061
10020
  }
10062
- if (this.hasProjected &&
10063
- !hasVisualTransform(this.latestValues)) {
10021
+ if (this.hasProjected && !hasTransform(this.latestValues)) {
10064
10022
  targetStyle.transform = transformTemplate
10065
10023
  ? transformTemplate({}, "")
10066
10024
  : "none";
@@ -10945,7 +10903,6 @@ exports.getViewAnimationLayerInfo = getViewAnimationLayerInfo;
10945
10903
  exports.getViewAnimations = getViewAnimations;
10946
10904
  exports.globalProjectionState = globalProjectionState;
10947
10905
  exports.has2DTranslate = has2DTranslate;
10948
- exports.hasIndependentTransform = hasIndependentTransform;
10949
10906
  exports.hasReducedMotionListener = hasReducedMotionListener;
10950
10907
  exports.hasScale = hasScale;
10951
10908
  exports.hasTransform = hasTransform;