motion-dom 12.7.3 → 12.7.5-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 (92) hide show
  1. package/dist/cjs/index.js +2946 -475
  2. package/dist/es/animation/AsyncMotionValueAnimation.mjs +178 -0
  3. package/dist/es/animation/GroupAnimation.mjs +6 -15
  4. package/dist/es/animation/JSAnimation.mjs +346 -0
  5. package/dist/es/animation/NativeAnimation.mjs +64 -67
  6. package/dist/es/animation/NativeAnimationExtended.mjs +65 -0
  7. package/dist/es/animation/NativeAnimationWrapper.mjs +14 -0
  8. package/dist/es/animation/drivers/driver-frameloop.mjs +17 -0
  9. package/dist/es/animation/generators/inertia.mjs +87 -0
  10. package/dist/es/animation/generators/keyframes.mjs +49 -0
  11. package/dist/es/animation/generators/spring/defaults.mjs +27 -0
  12. package/dist/es/animation/generators/spring/find.mjs +84 -0
  13. package/dist/es/animation/generators/spring/index.mjs +175 -0
  14. package/dist/es/animation/generators/utils/velocity.mjs +9 -0
  15. package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +131 -0
  16. package/dist/es/animation/keyframes/KeyframesResolver.mjs +156 -0
  17. package/dist/es/animation/keyframes/get-final.mjs +3 -4
  18. package/dist/es/animation/keyframes/offsets/default.mjs +9 -0
  19. package/dist/es/animation/keyframes/offsets/fill.mjs +12 -0
  20. package/dist/es/animation/keyframes/offsets/time.mjs +5 -0
  21. package/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +11 -0
  22. package/dist/es/animation/keyframes/utils/fill-wildcards.mjs +7 -0
  23. package/dist/es/animation/keyframes/utils/is-none.mjs +15 -0
  24. package/dist/es/animation/keyframes/utils/make-none-animatable.mjs +30 -0
  25. package/dist/es/animation/keyframes/utils/unit-conversion.mjs +36 -0
  26. package/dist/es/animation/utils/WithPromise.mjs +28 -0
  27. package/dist/es/animation/utils/active-animations.mjs +9 -0
  28. package/dist/es/animation/utils/can-animate.mjs +42 -0
  29. package/dist/es/animation/utils/css-variables-conversion.mjs +41 -0
  30. package/dist/es/animation/utils/is-animatable.mjs +30 -0
  31. package/dist/es/animation/utils/is-css-variable.mjs +15 -0
  32. package/dist/es/animation/utils/replace-transition-type.mjs +18 -0
  33. package/dist/es/animation/waapi/easing/is-supported.mjs +1 -1
  34. package/dist/es/animation/waapi/easing/map-easing.mjs +5 -3
  35. package/dist/es/animation/waapi/start-waapi-animation.mjs +6 -4
  36. package/dist/es/animation/waapi/supports/waapi.mjs +39 -0
  37. package/dist/es/animation/waapi/utils/accelerated-values.mjs +14 -0
  38. package/dist/es/animation/waapi/utils/apply-generator.mjs +2 -1
  39. package/dist/es/animation/waapi/utils/unsupported-easing.mjs +18 -0
  40. package/dist/es/frameloop/batcher.mjs +2 -1
  41. package/dist/es/frameloop/order.mjs +1 -0
  42. package/dist/es/index.mjs +49 -2
  43. package/dist/es/render/dom/is-css-var.mjs +3 -0
  44. package/dist/es/render/dom/parse-transform.mjs +83 -0
  45. package/dist/es/render/dom/style-computed.mjs +10 -0
  46. package/dist/es/render/dom/style-set.mjs +9 -0
  47. package/dist/es/render/utils/keys-position.mjs +13 -0
  48. package/dist/es/render/utils/keys-transform.mjs +28 -0
  49. package/dist/es/scroll/observe.mjs +18 -0
  50. package/dist/es/stats/index.mjs +2 -0
  51. package/dist/es/utils/interpolate.mjs +74 -0
  52. package/dist/es/utils/mix/color.mjs +47 -0
  53. package/dist/es/utils/mix/complex.mjs +92 -0
  54. package/dist/es/utils/mix/immediate.mjs +5 -0
  55. package/dist/es/utils/mix/index.mjs +14 -0
  56. package/dist/es/utils/mix/number.mjs +26 -0
  57. package/dist/es/utils/mix/visibility.mjs +16 -0
  58. package/dist/es/value/index.mjs +3 -1
  59. package/dist/es/value/types/auto.mjs +9 -0
  60. package/dist/es/value/types/color/hex.mjs +40 -0
  61. package/dist/es/value/types/color/hsla-to-rgba.mjs +42 -0
  62. package/dist/es/value/types/color/hsla.mjs +22 -0
  63. package/dist/es/value/types/color/index.mjs +27 -0
  64. package/dist/es/value/types/color/rgba.mjs +25 -0
  65. package/dist/es/value/types/color/utils.mjs +29 -0
  66. package/dist/es/value/types/complex/filter.mjs +30 -0
  67. package/dist/es/value/types/complex/index.mjs +91 -0
  68. package/dist/es/value/types/dimensions.mjs +15 -0
  69. package/dist/es/value/types/int.mjs +8 -0
  70. package/dist/es/value/types/maps/defaults.mjs +30 -0
  71. package/dist/es/value/types/maps/number.mjs +51 -0
  72. package/dist/es/value/types/maps/transform.mjs +31 -0
  73. package/dist/es/value/types/numbers/index.mjs +17 -0
  74. package/dist/es/value/types/numbers/units.mjs +18 -0
  75. package/dist/es/value/types/test.mjs +6 -0
  76. package/dist/es/value/types/utils/animatable-none.mjs +15 -0
  77. package/dist/es/value/types/utils/color-regex.mjs +3 -0
  78. package/dist/es/value/types/utils/find.mjs +15 -0
  79. package/dist/es/value/types/utils/float-regex.mjs +3 -0
  80. package/dist/es/value/types/utils/get-as-type.mjs +10 -0
  81. package/dist/es/value/types/utils/is-nullish.mjs +5 -0
  82. package/dist/es/value/types/utils/sanitize.mjs +5 -0
  83. package/dist/es/value/types/utils/single-color-regex.mjs +3 -0
  84. package/dist/es/view/start.mjs +4 -3
  85. package/dist/index.d.ts +945 -444
  86. package/dist/motion-dom.dev.js +2945 -475
  87. package/dist/motion-dom.js +1 -1
  88. package/package.json +3 -3
  89. package/dist/es/animation/keyframes/hydrate.mjs +0 -26
  90. package/dist/es/animation/waapi/utils/attach-timeline.mjs +0 -6
  91. package/dist/es/render/dom/style.mjs +0 -15
  92. package/dist/es/utils/is-bezier-definition.mjs +0 -3
@@ -0,0 +1,51 @@
1
+ import { int } from '../int.mjs';
2
+ import { alpha } from '../numbers/index.mjs';
3
+ import { px } from '../numbers/units.mjs';
4
+ import { transformValueTypes } from './transform.mjs';
5
+
6
+ const numberValueTypes = {
7
+ // Border props
8
+ borderWidth: px,
9
+ borderTopWidth: px,
10
+ borderRightWidth: px,
11
+ borderBottomWidth: px,
12
+ borderLeftWidth: px,
13
+ borderRadius: px,
14
+ radius: px,
15
+ borderTopLeftRadius: px,
16
+ borderTopRightRadius: px,
17
+ borderBottomRightRadius: px,
18
+ borderBottomLeftRadius: px,
19
+ // Positioning props
20
+ width: px,
21
+ maxWidth: px,
22
+ height: px,
23
+ maxHeight: px,
24
+ top: px,
25
+ right: px,
26
+ bottom: px,
27
+ left: px,
28
+ // Spacing props
29
+ padding: px,
30
+ paddingTop: px,
31
+ paddingRight: px,
32
+ paddingBottom: px,
33
+ paddingLeft: px,
34
+ margin: px,
35
+ marginTop: px,
36
+ marginRight: px,
37
+ marginBottom: px,
38
+ marginLeft: px,
39
+ // Misc
40
+ backgroundPositionX: px,
41
+ backgroundPositionY: px,
42
+ ...transformValueTypes,
43
+ zIndex: int,
44
+ size: px,
45
+ // SVG
46
+ fillOpacity: alpha,
47
+ strokeOpacity: alpha,
48
+ numOctaves: int,
49
+ };
50
+
51
+ export { numberValueTypes };
@@ -0,0 +1,31 @@
1
+ import { scale, alpha } from '../numbers/index.mjs';
2
+ import { degrees, px, progressPercentage } from '../numbers/units.mjs';
3
+
4
+ const transformValueTypes = {
5
+ rotate: degrees,
6
+ rotateX: degrees,
7
+ rotateY: degrees,
8
+ rotateZ: degrees,
9
+ scale,
10
+ scaleX: scale,
11
+ scaleY: scale,
12
+ scaleZ: scale,
13
+ skew: degrees,
14
+ skewX: degrees,
15
+ skewY: degrees,
16
+ distance: px,
17
+ translateX: px,
18
+ translateY: px,
19
+ translateZ: px,
20
+ x: px,
21
+ y: px,
22
+ z: px,
23
+ perspective: px,
24
+ transformPerspective: px,
25
+ opacity: alpha,
26
+ originX: progressPercentage,
27
+ originY: progressPercentage,
28
+ originZ: px,
29
+ };
30
+
31
+ export { transformValueTypes };
@@ -0,0 +1,17 @@
1
+ import { clamp } from 'motion-utils';
2
+
3
+ const number = {
4
+ test: (v) => typeof v === "number",
5
+ parse: parseFloat,
6
+ transform: (v) => v,
7
+ };
8
+ const alpha = {
9
+ ...number,
10
+ transform: (v) => clamp(0, 1, v),
11
+ };
12
+ const scale = {
13
+ ...number,
14
+ default: 1,
15
+ };
16
+
17
+ export { alpha, number, scale };
@@ -0,0 +1,18 @@
1
+ /*#__NO_SIDE_EFFECTS__*/
2
+ const createUnitType = (unit) => ({
3
+ test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
4
+ parse: parseFloat,
5
+ transform: (v) => `${v}${unit}`,
6
+ });
7
+ const degrees = /*@__PURE__*/ createUnitType("deg");
8
+ const percent = /*@__PURE__*/ createUnitType("%");
9
+ const px = /*@__PURE__*/ createUnitType("px");
10
+ const vh = /*@__PURE__*/ createUnitType("vh");
11
+ const vw = /*@__PURE__*/ createUnitType("vw");
12
+ const progressPercentage = /*@__PURE__*/ (() => ({
13
+ ...percent,
14
+ parse: (v) => percent.parse(v) / 100,
15
+ transform: (v) => percent.transform(v * 100),
16
+ }))();
17
+
18
+ export { degrees, percent, progressPercentage, px, vh, vw };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Tests a provided value against a ValueType
3
+ */
4
+ const testValueType = (v) => (type) => type.test(v);
5
+
6
+ export { testValueType };
@@ -0,0 +1,15 @@
1
+ import { complex } from '../complex/index.mjs';
2
+ import { filter } from '../complex/filter.mjs';
3
+ import { getDefaultValueType } from '../maps/defaults.mjs';
4
+
5
+ function getAnimatableNone(key, value) {
6
+ let defaultValueType = getDefaultValueType(key);
7
+ if (defaultValueType !== filter)
8
+ defaultValueType = complex;
9
+ // If value is not recognised as animatable, ie "one", create an animatable version origin based on the target
10
+ return defaultValueType.getAnimatableNone
11
+ ? defaultValueType.getAnimatableNone(value)
12
+ : undefined;
13
+ }
14
+
15
+ export { getAnimatableNone };
@@ -0,0 +1,3 @@
1
+ const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
2
+
3
+ export { colorRegex };
@@ -0,0 +1,15 @@
1
+ import { color } from '../color/index.mjs';
2
+ import { complex } from '../complex/index.mjs';
3
+ import { dimensionValueTypes } from '../dimensions.mjs';
4
+ import { testValueType } from '../test.mjs';
5
+
6
+ /**
7
+ * A list of all ValueTypes
8
+ */
9
+ const valueTypes = [...dimensionValueTypes, color, complex];
10
+ /**
11
+ * Tests a value against the list of ValueTypes
12
+ */
13
+ const findValueType = (v) => valueTypes.find(testValueType(v));
14
+
15
+ export { findValueType };
@@ -0,0 +1,3 @@
1
+ const floatRegex = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
2
+
3
+ export { floatRegex };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Provided a value and a ValueType, returns the value as that value type.
3
+ */
4
+ const getValueAsType = (value, type) => {
5
+ return type && typeof value === "number"
6
+ ? type.transform(value)
7
+ : value;
8
+ };
9
+
10
+ export { getValueAsType };
@@ -0,0 +1,5 @@
1
+ function isNullish(v) {
2
+ return v == null;
3
+ }
4
+
5
+ export { isNullish };
@@ -0,0 +1,5 @@
1
+ // If this number is a decimal, make it just five decimal places
2
+ // to avoid exponents
3
+ const sanitize = (v) => Math.round(v * 100000) / 100000;
4
+
5
+ export { sanitize };
@@ -0,0 +1,3 @@
1
+ const singleColorRegex = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;
2
+
3
+ export { singleColorRegex };
@@ -1,6 +1,7 @@
1
1
  import { secondsToMilliseconds } from 'motion-utils';
2
2
  import { GroupAnimation } from '../animation/GroupAnimation.mjs';
3
3
  import { NativeAnimation } from '../animation/NativeAnimation.mjs';
4
+ import { NativeAnimationWrapper } from '../animation/NativeAnimationWrapper.mjs';
4
5
  import { getValueTransition } from '../animation/utils/get-value-transition.mjs';
5
6
  import { mapEasingToNativeEasing } from '../animation/waapi/easing/map-easing.mjs';
6
7
  import { applyGeneratorOptions } from '../animation/waapi/utils/apply-generator.mjs';
@@ -85,11 +86,11 @@ function startViewAnimation(builder) {
85
86
  valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
86
87
  valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
87
88
  const animation = new NativeAnimation({
89
+ ...valueOptions,
88
90
  element: document.documentElement,
89
91
  name: valueName,
90
92
  pseudoElement: `::view-transition-${type}(${target})`,
91
93
  keyframes: valueKeyframes,
92
- transition: valueOptions,
93
94
  });
94
95
  animations.push(animation);
95
96
  }
@@ -130,14 +131,14 @@ function startViewAnimation(builder) {
130
131
  duration: animationTransition.duration,
131
132
  easing,
132
133
  });
133
- animations.push(new NativeAnimation({ animation }));
134
+ animations.push(new NativeAnimationWrapper(animation));
134
135
  }
135
136
  else if (hasOpacity(targetDefinition, "enter") &&
136
137
  hasOpacity(targetDefinition, "exit") &&
137
138
  effect
138
139
  .getKeyframes()
139
140
  .some((keyframe) => keyframe.mixBlendMode)) {
140
- animations.push(new NativeAnimation({ animation }));
141
+ animations.push(new NativeAnimationWrapper(animation));
141
142
  }
142
143
  else {
143
144
  animation.cancel();