motion 12.6.2 → 12.6.3

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 (72) hide show
  1. package/dist/cjs/debug.js +12 -12
  2. package/dist/cjs/index.js +402 -347
  3. package/dist/cjs/mini.js +339 -352
  4. package/dist/cjs/react-client.js +169 -176
  5. package/dist/cjs/react-m.js +18 -22
  6. package/dist/cjs/react-mini.js +275 -336
  7. package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +2 -2
  8. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -4
  9. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -6
  10. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +10 -8
  11. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
  12. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
  13. package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +11 -1
  14. package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +3 -3
  15. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
  16. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
  17. package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +2 -4
  18. package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +4 -6
  19. package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +3 -3
  20. package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
  21. package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +2 -2
  22. package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
  23. package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +1 -2
  24. package/dist/es/framer-motion/dist/es/motion/index.mjs +2 -3
  25. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +3 -5
  26. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +19 -27
  27. package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +1 -1
  28. package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +3 -4
  29. package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
  30. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +5 -6
  31. package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +1 -2
  32. package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
  33. package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +1 -1
  34. package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
  35. package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +2 -3
  36. package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +3 -5
  37. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  38. package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +1 -1
  39. package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -2
  40. package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +2 -3
  41. package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +2 -2
  42. package/dist/es/motion-dom/dist/es/animation/{controls/BaseGroup.mjs → GroupAnimation.mjs} +4 -5
  43. package/dist/es/motion-dom/dist/es/animation/GroupAnimationWithThen.mjs +9 -0
  44. package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +161 -0
  45. package/dist/es/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +1 -1
  46. package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +12 -0
  47. package/dist/es/motion-dom/dist/es/animation/keyframes/hydrate.mjs +26 -0
  48. package/dist/es/motion-dom/dist/es/animation/utils/get-value-transition.mjs +3 -5
  49. package/dist/es/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs +3 -0
  50. package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +14 -0
  51. package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +26 -0
  52. package/dist/es/motion-dom/dist/es/animation/waapi/easing/supported.mjs +15 -0
  53. package/dist/es/{framer-motion/dist/es/animation/animators/waapi/index.mjs → motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs} +8 -6
  54. package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs → motion-dom/dist/es/animation/waapi/supports/partial-keyframes.mjs} +2 -2
  55. package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +14 -0
  56. package/dist/es/motion-dom/dist/es/animation/waapi/utils/linear.mjs +1 -4
  57. package/dist/es/motion-dom/dist/es/animation/waapi/utils/px-values.mjs +39 -0
  58. package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +1 -1
  59. package/dist/es/motion-dom/dist/es/render/dom/style.mjs +15 -0
  60. package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +2 -7
  61. package/dist/es/motion-dom/dist/es/utils/supports/flags.mjs +1 -3
  62. package/dist/es/motion-dom/dist/es/utils/supports/memo.mjs +1 -1
  63. package/dist/es/motion-dom/dist/es/value/index.mjs +1 -1
  64. package/dist/es/motion-utils/dist/es/errors.mjs +2 -4
  65. package/dist/motion.dev.js +402 -347
  66. package/dist/motion.js +1 -1
  67. package/package.json +3 -3
  68. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -116
  69. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
  70. package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +0 -13
  71. package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +0 -85
  72. package/dist/es/motion-dom/dist/es/animation/waapi/utils/easing.mjs +0 -44
@@ -0,0 +1,26 @@
1
+ import { style } from '../../render/dom/style.mjs';
2
+ import { supportsPartialKeyframes } from '../waapi/supports/partial-keyframes.mjs';
3
+ import { pxValues } from '../waapi/utils/px-values.mjs';
4
+
5
+ function hydrateKeyframes(element, name, keyframes, pseudoElement) {
6
+ if (!Array.isArray(keyframes)) {
7
+ keyframes = [keyframes];
8
+ }
9
+ for (let i = 0; i < keyframes.length; i++) {
10
+ if (keyframes[i] === null) {
11
+ keyframes[i] =
12
+ i === 0 && !pseudoElement
13
+ ? style.get(element, name)
14
+ : keyframes[i - 1];
15
+ }
16
+ if (typeof keyframes[i] === "number" && pxValues.has(name)) {
17
+ keyframes[i] = keyframes[i] + "px";
18
+ }
19
+ }
20
+ if (!pseudoElement && !supportsPartialKeyframes() && keyframes.length < 2) {
21
+ keyframes.unshift(style.get(element, name));
22
+ }
23
+ return keyframes;
24
+ }
25
+
26
+ export { hydrateKeyframes };
@@ -1,9 +1,7 @@
1
1
  function getValueTransition(transition, key) {
2
- return transition
3
- ? transition[key] ||
4
- transition["default"] ||
5
- transition
6
- : undefined;
2
+ return (transition?.[key] ??
3
+ transition?.["default"] ??
4
+ transition);
7
5
  }
8
6
 
9
7
  export { getValueTransition };
@@ -0,0 +1,3 @@
1
+ const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
2
+
3
+ export { cubicBezierAsString };
@@ -0,0 +1,14 @@
1
+ import { isBezierDefinition } from '../../../utils/is-bezier-definition.mjs';
2
+ import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
3
+ import { supportedWaapiEasing } from './supported.mjs';
4
+
5
+ function isWaapiSupportedEasing(easing) {
6
+ return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
7
+ !easing ||
8
+ (typeof easing === "string" &&
9
+ (easing in supportedWaapiEasing || supportsLinearEasing())) ||
10
+ isBezierDefinition(easing) ||
11
+ (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
12
+ }
13
+
14
+ export { isWaapiSupportedEasing };
@@ -0,0 +1,26 @@
1
+ import { isBezierDefinition } from '../../../utils/is-bezier-definition.mjs';
2
+ import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
3
+ import { generateLinearEasing } from '../utils/linear.mjs';
4
+ import { cubicBezierAsString } from './cubic-bezier.mjs';
5
+ import { supportedWaapiEasing } from './supported.mjs';
6
+
7
+ function mapEasingToNativeEasing(easing, duration) {
8
+ if (!easing) {
9
+ return undefined;
10
+ }
11
+ else if (typeof easing === "function" && supportsLinearEasing()) {
12
+ return generateLinearEasing(easing, duration);
13
+ }
14
+ else if (isBezierDefinition(easing)) {
15
+ return cubicBezierAsString(easing);
16
+ }
17
+ else if (Array.isArray(easing)) {
18
+ return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) ||
19
+ supportedWaapiEasing.easeOut);
20
+ }
21
+ else {
22
+ return supportedWaapiEasing[easing];
23
+ }
24
+ }
25
+
26
+ export { mapEasingToNativeEasing };
@@ -0,0 +1,15 @@
1
+ import { cubicBezierAsString } from './cubic-bezier.mjs';
2
+
3
+ const supportedWaapiEasing = {
4
+ linear: "linear",
5
+ ease: "ease",
6
+ easeIn: "ease-in",
7
+ easeOut: "ease-out",
8
+ easeInOut: "ease-in-out",
9
+ circIn: /*@__PURE__*/ cubicBezierAsString([0, 0.65, 0.55, 1]),
10
+ circOut: /*@__PURE__*/ cubicBezierAsString([0.55, 0, 1, 0.45]),
11
+ backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
12
+ backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
13
+ };
14
+
15
+ export { supportedWaapiEasing };
@@ -1,10 +1,11 @@
1
- import '../../../../../../motion-utils/dist/es/errors.mjs';
2
- import { mapEasingToNativeEasing } from '../../../../../../motion-dom/dist/es/animation/waapi/utils/easing.mjs';
3
- import { statsBuffer } from '../../../../../../motion-dom/dist/es/stats/buffer.mjs';
4
- import { activeAnimations } from '../../../../../../motion-dom/dist/es/stats/animation-count.mjs';
1
+ import { activeAnimations } from '../../stats/animation-count.mjs';
2
+ import { statsBuffer } from '../../stats/buffer.mjs';
3
+ import { mapEasingToNativeEasing } from './easing/map-easing.mjs';
5
4
 
6
- function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
7
- const keyframeOptions = { [valueName]: keyframes };
5
+ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}, pseudoElement = undefined) {
6
+ const keyframeOptions = {
7
+ [valueName]: keyframes,
8
+ };
8
9
  if (times)
9
10
  keyframeOptions.offset = times;
10
11
  const easing = mapEasingToNativeEasing(ease, duration);
@@ -23,6 +24,7 @@ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duratio
23
24
  fill: "both",
24
25
  iterations: repeat + 1,
25
26
  direction: repeatType === "reverse" ? "alternate" : "normal",
27
+ pseudoElement,
26
28
  });
27
29
  if (statsBuffer.value) {
28
30
  animation.finished.finally(() => {
@@ -1,5 +1,5 @@
1
- import '../../../../../../../motion-utils/dist/es/errors.mjs';
2
- import { memo } from '../../../../../../../motion-utils/dist/es/memo.mjs';
1
+ import '../../../../../../motion-utils/dist/es/errors.mjs';
2
+ import { memo } from '../../../../../../motion-utils/dist/es/memo.mjs';
3
3
 
4
4
  const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
5
5
  try {
@@ -0,0 +1,14 @@
1
+ import { isGenerator } from '../../generators/utils/is-generator.mjs';
2
+
3
+ function applyGeneratorOptions({ type, ...options }) {
4
+ if (isGenerator(type)) {
5
+ return type.applyToOptions(options);
6
+ }
7
+ else {
8
+ options.duration ?? (options.duration = 300);
9
+ options.ease ?? (options.ease = "easeOut");
10
+ }
11
+ return options;
12
+ }
13
+
14
+ export { applyGeneratorOptions };
@@ -1,13 +1,10 @@
1
- import '../../../../../../motion-utils/dist/es/errors.mjs';
2
- import { progress } from '../../../../../../motion-utils/dist/es/progress.mjs';
3
-
4
1
  const generateLinearEasing = (easing, duration, // as milliseconds
5
2
  resolution = 10 // as milliseconds
6
3
  ) => {
7
4
  let points = "";
8
5
  const numPoints = Math.max(Math.round(duration / resolution), 2);
9
6
  for (let i = 0; i < numPoints; i++) {
10
- points += easing(progress(0, numPoints - 1, i)) + ", ";
7
+ points += easing(i / (numPoints - 1)) + ", ";
11
8
  }
12
9
  return `linear(${points.substring(0, points.length - 2)})`;
13
10
  };
@@ -0,0 +1,39 @@
1
+ const pxValues = new Set([
2
+ // Border props
3
+ "borderWidth",
4
+ "borderTopWidth",
5
+ "borderRightWidth",
6
+ "borderBottomWidth",
7
+ "borderLeftWidth",
8
+ "borderRadius",
9
+ "radius",
10
+ "borderTopLeftRadius",
11
+ "borderTopRightRadius",
12
+ "borderBottomRightRadius",
13
+ "borderBottomLeftRadius",
14
+ // Positioning props
15
+ "width",
16
+ "maxWidth",
17
+ "height",
18
+ "maxHeight",
19
+ "top",
20
+ "right",
21
+ "bottom",
22
+ "left",
23
+ // Spacing props
24
+ "padding",
25
+ "paddingTop",
26
+ "paddingRight",
27
+ "paddingBottom",
28
+ "paddingLeft",
29
+ "margin",
30
+ "marginTop",
31
+ "marginRight",
32
+ "marginBottom",
33
+ "marginLeft",
34
+ // Misc
35
+ "backgroundPositionX",
36
+ "backgroundPositionY",
37
+ ]);
38
+
39
+ export { pxValues };
@@ -69,7 +69,7 @@ function press(targetOrSelector, onPressStart, options = {}) {
69
69
  if (target instanceof HTMLElement) {
70
70
  target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
71
71
  if (!isElementKeyboardAccessible(target) &&
72
- target.tabIndex === null) {
72
+ !target.hasAttribute("tabindex")) {
73
73
  target.tabIndex = 0;
74
74
  }
75
75
  }
@@ -0,0 +1,15 @@
1
+ const isCSSVar = (name) => name.startsWith("--");
2
+ const style = {
3
+ set: (element, name, value) => {
4
+ isCSSVar(name)
5
+ ? element.style.setProperty(name, value)
6
+ : (element.style[name] = value);
7
+ },
8
+ get: (element, name) => {
9
+ return isCSSVar(name)
10
+ ? element.style.getPropertyValue(name)
11
+ : element.style[name];
12
+ },
13
+ };
14
+
15
+ export { style };
@@ -1,19 +1,14 @@
1
1
  function resolveElements(elementOrSelector, scope, selectorCache) {
2
- var _a;
3
2
  if (elementOrSelector instanceof EventTarget) {
4
3
  return [elementOrSelector];
5
4
  }
6
5
  else if (typeof elementOrSelector === "string") {
7
6
  let root = document;
8
7
  if (scope) {
9
- // TODO: Refactor to utils package
10
- // invariant(
11
- // Boolean(scope.current),
12
- // "Scope provided, but no element detected."
13
- // )
14
8
  root = scope.current;
15
9
  }
16
- const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
10
+ const elements = selectorCache?.[elementOrSelector] ??
11
+ root.querySelectorAll(elementOrSelector);
17
12
  return elements ? Array.from(elements) : [];
18
13
  }
19
14
  return Array.from(elementOrSelector);
@@ -2,8 +2,6 @@
2
2
  * Add the ability for test suites to manually set support flags
3
3
  * to better test more environments.
4
4
  */
5
- const supportsFlags = {
6
- linearEasing: undefined,
7
- };
5
+ const supportsFlags = {};
8
6
 
9
7
  export { supportsFlags };
@@ -4,7 +4,7 @@ import { supportsFlags } from './flags.mjs';
4
4
 
5
5
  function memoSupports(callback, supportsFlag) {
6
6
  const memoized = memo(callback);
7
- return () => { var _a; return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized(); };
7
+ return () => supportsFlags[supportsFlag] ?? memoized();
8
8
  }
9
9
 
10
10
  export { memoSupports };
@@ -33,7 +33,7 @@ class MotionValue {
33
33
  * This will be replaced by the build step with the latest version number.
34
34
  * When MotionValues are provided to motion components, warn if versions are mixed.
35
35
  */
36
- this.version = "12.6.1";
36
+ this.version = "12.6.3";
37
37
  /**
38
38
  * Tracks whether this value can output a velocity. Currently this is only true
39
39
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -1,7 +1,5 @@
1
- import { noop } from './noop.mjs';
2
-
3
- let warning = noop;
4
- let invariant = noop;
1
+ let warning = () => { };
2
+ let invariant = () => { };
5
3
  if (process.env.NODE_ENV !== "production") {
6
4
  warning = (check, message) => {
7
5
  if (!check && typeof console !== "undefined") {