motion 11.11.17 → 11.13.0-beta.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 (55) hide show
  1. package/.turbo/turbo-build.log +45 -47
  2. package/README.md +16 -3
  3. package/dist/cjs/index.js +192 -116
  4. package/dist/cjs/mini.js +24 -28
  5. package/dist/cjs/react-client.js +146 -93
  6. package/dist/cjs/react-mini.js +24 -28
  7. package/dist/es/dom/dist/es/gestures/hover.mjs +26 -0
  8. package/dist/es/dom/dist/es/utils/resolve-elements.mjs +22 -0
  9. package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +1 -1
  10. package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
  11. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +2 -1
  12. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +1 -1
  13. package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +1 -1
  14. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +3 -2
  15. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +2 -2
  16. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/linear.mjs +2 -3
  17. package/dist/es/framer-motion/dist/es/animation/generators/spring/defaults.mjs +27 -0
  18. package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +9 -12
  19. package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +53 -17
  20. package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +1 -1
  21. package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +2 -1
  22. package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +1 -1
  23. package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +1 -1
  24. package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +1 -1
  25. package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +1 -1
  26. package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +2 -1
  27. package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +2 -2
  28. package/dist/es/framer-motion/dist/es/events/event-info.mjs +3 -3
  29. package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +2 -1
  30. package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
  31. package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +2 -1
  32. package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +2 -1
  33. package/dist/es/framer-motion/dist/es/gestures/press.mjs +2 -1
  34. package/dist/es/framer-motion/dist/es/motion/index.mjs +1 -1
  35. package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +2 -1
  36. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +2 -1
  37. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +1 -1
  38. package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +2 -1
  39. package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
  40. package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +1 -1
  41. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  42. package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +2 -2
  43. package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +1 -1
  44. package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -1
  45. package/dist/es/framer-motion/dist/es/value/index.mjs +1 -1
  46. package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +1 -1
  47. package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +1 -1
  48. package/dist/es/motion/lib/index.mjs +4 -1
  49. package/dist/es/motion/lib/react.mjs +4 -1
  50. package/dist/motion.dev.js +192 -116
  51. package/dist/motion.js +1 -1
  52. package/package.json +3 -3
  53. package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +0 -28
  54. /package/dist/es/{framer-motion/dist/es/utils → utils/dist/es}/errors.mjs +0 -0
  55. /package/dist/es/{framer-motion/dist/es/utils → utils/dist/es}/noop.mjs +0 -0
@@ -1,47 +1,45 @@
1
- (node:86403) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
2
- (Use `node --trace-warnings ...` to show where the warning was created)
3
- 
4
- lib/index.js → dist/motion.dev.js...
5
- created dist/motion.dev.js in 945ms
6
- 
7
- lib/index.js → dist/motion.js...
8
- created dist/motion.js in 1.3s
9
- 
10
- lib/index.js → dist/cjs...
11
- created dist/cjs in 287ms
12
- 
13
- lib/react-client.js → dist/cjs...
14
- created dist/cjs in 320ms
15
- 
16
- lib/react.js → dist/cjs...
17
- created dist/cjs in 4ms
18
- 
19
- lib/mini.js → dist/cjs...
20
- created dist/cjs in 93ms
21
- 
22
- lib/react-mini.js → dist/cjs...
23
- created dist/cjs in 83ms
24
- 
25
- lib/react-m.js → dist/cjs...
26
- created dist/cjs in 94ms
27
- 
28
- lib/index.js, lib/mini.js, lib/react.js, lib/react-mini.js, lib/react-client.js, lib/react-m.js → dist/es...
29
- created dist/es in 683ms
30
- 
31
- types/index.d.ts → dist/index.d.ts...
32
- created dist/index.d.ts in 19ms
33
- 
34
- types/react.d.ts → dist/react.d.ts...
35
- created dist/react.d.ts in 7ms
36
- 
37
- types/react-mini.d.ts → dist/react-mini.d.ts...
38
- created dist/react-mini.d.ts in 2ms
39
- 
40
- types/react-m.d.ts → dist/react-m.d.ts...
41
- created dist/react-m.d.ts in 3ms
42
- 
43
- types/mini.d.ts → dist/mini.d.ts...
44
- created dist/mini.d.ts in 2ms
45
- 
46
- types/react-client.d.ts → dist/react-client.d.ts...
47
- created dist/react-client.d.ts in 2ms
1
+ 
2
+ lib/index.js dist/motion.dev.js...
3
+ created dist/motion.dev.js in 669ms
4
+ 
5
+ lib/index.js dist/motion.js...
6
+ created dist/motion.js in 804ms
7
+ 
8
+ lib/index.js dist/cjs...
9
+ created dist/cjs in 195ms
10
+ 
11
+ lib/react-client.js dist/cjs...
12
+ created dist/cjs in 323ms
13
+ 
14
+ lib/react.js dist/cjs...
15
+ created dist/cjs in 2ms
16
+ 
17
+ lib/mini.js dist/cjs...
18
+ created dist/cjs in 24ms
19
+ 
20
+ lib/react-mini.js dist/cjs...
21
+ created dist/cjs in 20ms
22
+ 
23
+ lib/react-m.js dist/cjs...
24
+ created dist/cjs in 117ms
25
+ 
26
+ lib/index.js, lib/mini.js, lib/react.js, lib/react-mini.js, lib/react-client.js, lib/react-m.js dist/es...
27
+ created dist/es in 599ms
28
+ 
29
+ types/index.d.ts dist/index.d.ts...
30
+ created dist/index.d.ts in 10ms
31
+ 
32
+ types/react.d.ts dist/react.d.ts...
33
+ created dist/react.d.ts in 9ms
34
+ 
35
+ types/react-mini.d.ts dist/react-mini.d.ts...
36
+ created dist/react-mini.d.ts in 3ms
37
+ 
38
+ types/react-m.d.ts dist/react-m.d.ts...
39
+ created dist/react-m.d.ts in 5ms
40
+ 
41
+ types/mini.d.ts dist/mini.d.ts...
42
+ created dist/mini.d.ts in 3ms
43
+ 
44
+ types/react-client.d.ts dist/react-client.d.ts...
45
+ created dist/react-client.d.ts in 1ms
package/README.md CHANGED
@@ -38,14 +38,14 @@ It does all this:
38
38
 
39
39
  - [Springs](https://motion.dev/docs/react-transitions#spring)
40
40
  - [Keyframes](https://motion.dev/docs/react-animation#keyframes)
41
- - [Layout animations](https://motion/dev/docs/react-layout-animations)
41
+ - [Layout animations](https://motion.dev/docs/react-layout-animations)
42
42
  - [Shared layout animations](https://motion.dev/docs/react-layout-animations#shared-layout-animations)
43
43
  - [Gestures (drag/tap/hover)](https://motion.dev/docs/react-gestures)
44
44
  - [Scroll animations](https://motion.dev/docs/react-scroll-animations)
45
45
  - [SVG paths](https://motion.dev/docs/react-animation#svg-line-drawing)
46
46
  - [Exit animations](https://motion.dev/docs/react-animation#exit-animations)
47
- - [Server-side rendering](https://motion.dev//docs/react-motion-component#server-side-rendering)
48
- - [Independent transforms](https://motion.dev/docs/react-motion-component#independent-transforms)
47
+ - [Server-side rendering](https://motion.dev/docs/react-motion-component#server-side-rendering)
48
+ - [Independent transforms](https://motion.dev/docs/react-motion-component#style)
49
49
  - [Orchestrate animations across components](https://motion.dev/docs/react-animation#orchestration)
50
50
  - [CSS variables](https://motion.dev/docs/react-animation#css-variables)
51
51
 
@@ -101,6 +101,10 @@ Motion powers Framer animations, the web builder for creative pros. Design and s
101
101
 
102
102
  <a href="https://linear.app"><img alt="Linear" src="https://github.com/user-attachments/assets/a93710bb-d8ed-40e3-b0fb-1c5b3e2b16bb" width="300px" height="200px"></a>
103
103
 
104
+ ### Gold
105
+
106
+ <a href="https://liveblocks.io"><img alt="Liveblocks" src="https://github.com/user-attachments/assets/31436a47-951e-4eab-9a68-bdd54ccf9444" width="225px" height="150px"></a>
107
+
104
108
  ### Silver
105
109
 
106
110
  <a href="https://www.frontend.fyi/?utm_source=motion"><img alt="Frontend.fyi" src="https://github.com/user-attachments/assets/07d23aa5-69db-44a0-849d-90177e6fc817" width="150px" height="100px"></a>
@@ -109,7 +113,16 @@ Motion powers Framer animations, the web builder for creative pros. Design and s
109
113
 
110
114
  <a href="https://firecrawl.dev"><img alt="Firecrawl" src="https://github.com/user-attachments/assets/cba90e54-1329-4353-8fba-85beef4d2ee9" width="150px" height="100px"></a>
111
115
 
116
+ <a href="https://puzzmo.com"><img alt="Puzzmo" src="https://github.com/user-attachments/assets/aa2d5586-e5e2-43b9-8446-db456e4b0758" width="150px" height="100px"></a>
117
+
118
+ <a href="https://buildui.com"><img alt="Build UI" src="https://github.com/user-attachments/assets/024bfcd5-50e8-4b3d-a115-d5c6d6030d1c" width="150px" height="100px"></a>
119
+
120
+ <a href="https://hover.dev"><img alt="Hover" src="https://github.com/user-attachments/assets/4715b555-d2ac-4cb7-9f35-d36d708827b3" width="150px" height="100px"></a>
121
+
112
122
  ### Personal
113
123
 
114
124
  - [Nusu](https://x.com/nusualabuga)
115
125
  - [OlegWock](https://sinja.io)
126
+ - [Lambert Weller](https://github.com/l-mbert)
127
+ - [Jake LeBoeuf](https://jklb.wf)
128
+ - [Han Lee](https://github.com/hahnlee)
package/dist/cjs/index.js CHANGED
@@ -2,6 +2,67 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ const noop = (any) => any;
6
+
7
+ exports.warning = noop;
8
+ exports.invariant = noop;
9
+ if (process.env.NODE_ENV !== "production") {
10
+ exports.warning = (check, message) => {
11
+ if (!check && typeof console !== "undefined") {
12
+ console.warn(message);
13
+ }
14
+ };
15
+ exports.invariant = (check, message) => {
16
+ if (!check) {
17
+ throw new Error(message);
18
+ }
19
+ };
20
+ }
21
+
22
+ function resolveElements(elementOrSelector, scope, selectorCache) {
23
+ var _a;
24
+ if (elementOrSelector instanceof Element) {
25
+ return [elementOrSelector];
26
+ }
27
+ else if (typeof elementOrSelector === "string") {
28
+ let root = document;
29
+ if (scope) {
30
+ // TODO: Refactor to utils package
31
+ // invariant(
32
+ // Boolean(scope.current),
33
+ // "Scope provided, but no element detected."
34
+ // )
35
+ root = scope.current;
36
+ }
37
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
38
+ return elements ? Array.from(elements) : [];
39
+ }
40
+ return Array.from(elementOrSelector);
41
+ }
42
+
43
+ function hover(elementOrSelector, onHoverStart) {
44
+ const elements = resolveElements(elementOrSelector);
45
+ const cancelGesture = new AbortController();
46
+ const options = { signal: cancelGesture.signal };
47
+ const onPointerEnter = (enterEvent) => {
48
+ if (enterEvent.pointerType === "touch")
49
+ return;
50
+ const { target } = enterEvent;
51
+ const onHoverEnd = onHoverStart(enterEvent);
52
+ if (onHoverEnd && target) {
53
+ const onPointerLeave = (leaveEvent) => {
54
+ onHoverEnd(leaveEvent);
55
+ target.removeEventListener("pointerleave", onPointerLeave);
56
+ };
57
+ target.addEventListener("pointerleave", onPointerLeave, options);
58
+ }
59
+ };
60
+ elements.forEach((element) => {
61
+ element.addEventListener("pointerenter", onPointerEnter, options);
62
+ });
63
+ return () => cancelGesture.abort();
64
+ }
65
+
5
66
  function addUniqueItem(arr, item) {
6
67
  if (arr.indexOf(item) === -1)
7
68
  arr.push(item);
@@ -74,8 +135,6 @@ const MotionGlobalConfig = {
74
135
  useManualTiming: false,
75
136
  };
76
137
 
77
- const noop = (any) => any;
78
-
79
138
  function createRenderStep(runNextFrame) {
80
139
  /**
81
140
  * We create and reuse two queues, one to queue jobs for the current frame
@@ -279,7 +338,7 @@ class MotionValue {
279
338
  * This will be replaced by the build step with the latest version number.
280
339
  * When MotionValues are provided to motion components, warn if versions are mixed.
281
340
  */
282
- this.version = "11.11.17";
341
+ this.version = "11.13.0-beta.0";
283
342
  /**
284
343
  * Tracks whether this value can output a velocity. Currently this is only true
285
344
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -647,6 +706,34 @@ class GroupPlaybackControls {
647
706
  }
648
707
  }
649
708
 
709
+ /*
710
+ Progress within given range
711
+
712
+ Given a lower limit and an upper limit, we return the progress
713
+ (expressed as a number 0-1) represented by the given value, and
714
+ limit that progress to within 0-1.
715
+
716
+ @param [number]: Lower limit
717
+ @param [number]: Upper limit
718
+ @param [number]: Value to find progress within given range
719
+ @return [number]: Progress of value within range as expressed 0-1
720
+ */
721
+ const progress = (from, to, value) => {
722
+ const toFromDifference = to - from;
723
+ return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
724
+ };
725
+
726
+ const generateLinearEasing = (easing, duration, // as milliseconds
727
+ resolution = 10 // as milliseconds
728
+ ) => {
729
+ let points = "";
730
+ const numPoints = Math.max(Math.round(duration / resolution), 2);
731
+ for (let i = 0; i < numPoints; i++) {
732
+ points += easing(progress(0, numPoints - 1, i)) + ", ";
733
+ }
734
+ return `linear(${points.substring(0, points.length - 2)})`;
735
+ };
736
+
650
737
  /**
651
738
  * Converts seconds to milliseconds
652
739
  *
@@ -662,21 +749,6 @@ function calcGeneratorVelocity(resolveValue, t, current) {
662
749
  return velocityPerSecond(current - resolveValue(prevT), t - prevT);
663
750
  }
664
751
 
665
- exports.warning = noop;
666
- exports.invariant = noop;
667
- if (process.env.NODE_ENV !== "production") {
668
- exports.warning = (check, message) => {
669
- if (!check && typeof console !== "undefined") {
670
- console.warn(message);
671
- }
672
- };
673
- exports.invariant = (check, message) => {
674
- if (!check) {
675
- throw new Error(message);
676
- }
677
- };
678
- }
679
-
680
752
  const clamp = (min, max, v) => {
681
753
  if (v > max)
682
754
  return max;
@@ -685,21 +757,43 @@ const clamp = (min, max, v) => {
685
757
  return v;
686
758
  };
687
759
 
760
+ const springDefaults = {
761
+ // Default spring physics
762
+ stiffness: 100,
763
+ damping: 10,
764
+ mass: 1.0,
765
+ velocity: 0.0,
766
+ // Default duration/bounce-based options
767
+ duration: 800, // in ms
768
+ bounce: 0.3,
769
+ visualDuration: 0.3, // in seconds
770
+ // Rest thresholds
771
+ restSpeed: {
772
+ granular: 0.01,
773
+ default: 2,
774
+ },
775
+ restDelta: {
776
+ granular: 0.005,
777
+ default: 0.5,
778
+ },
779
+ // Limits
780
+ minDuration: 0.01, // in seconds
781
+ maxDuration: 10.0, // in seconds
782
+ minDamping: 0.05,
783
+ maxDamping: 1,
784
+ };
785
+
688
786
  const safeMin = 0.001;
689
- const minDuration = 0.01;
690
- const maxDuration$1 = 10.0;
691
- const minDamping = 0.05;
692
- const maxDamping = 1;
693
- function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, }) {
787
+ function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass, }) {
694
788
  let envelope;
695
789
  let derivative;
696
- exports.warning(duration <= secondsToMilliseconds(maxDuration$1), "Spring duration must be 10 seconds or less");
790
+ exports.warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
697
791
  let dampingRatio = 1 - bounce;
698
792
  /**
699
793
  * Restrict dampingRatio and duration to within acceptable ranges.
700
794
  */
701
- dampingRatio = clamp(minDamping, maxDamping, dampingRatio);
702
- duration = clamp(minDuration, maxDuration$1, millisecondsToSeconds(duration));
795
+ dampingRatio = clamp(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
796
+ duration = clamp(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds(duration));
703
797
  if (dampingRatio < 1) {
704
798
  /**
705
799
  * Underdamped spring
@@ -743,8 +837,8 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
743
837
  duration = secondsToMilliseconds(duration);
744
838
  if (isNaN(undampedFreq)) {
745
839
  return {
746
- stiffness: 100,
747
- damping: 10,
840
+ stiffness: springDefaults.stiffness,
841
+ damping: springDefaults.damping,
748
842
  duration,
749
843
  };
750
844
  }
@@ -769,6 +863,22 @@ function calcAngularFreq(undampedFreq, dampingRatio) {
769
863
  return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
770
864
  }
771
865
 
866
+ /**
867
+ * Implement a practical max duration for keyframe generation
868
+ * to prevent infinite loops
869
+ */
870
+ const maxGeneratorDuration = 20000;
871
+ function calcGeneratorDuration(generator) {
872
+ let duration = 0;
873
+ const timeStep = 50;
874
+ let state = generator.next(duration);
875
+ while (!state.done && duration < maxGeneratorDuration) {
876
+ duration += timeStep;
877
+ state = generator.next(duration);
878
+ }
879
+ return duration >= maxGeneratorDuration ? Infinity : duration;
880
+ }
881
+
772
882
  const durationKeys = ["duration", "bounce"];
773
883
  const physicsKeys = ["stiffness", "damping", "mass"];
774
884
  function isSpringType(options, keys) {
@@ -776,29 +886,51 @@ function isSpringType(options, keys) {
776
886
  }
777
887
  function getSpringOptions(options) {
778
888
  let springOptions = {
779
- velocity: 0.0,
780
- stiffness: 100,
781
- damping: 10,
782
- mass: 1.0,
889
+ velocity: springDefaults.velocity,
890
+ stiffness: springDefaults.stiffness,
891
+ damping: springDefaults.damping,
892
+ mass: springDefaults.mass,
783
893
  isResolvedFromDuration: false,
784
894
  ...options,
785
895
  };
786
896
  // stiffness/damping/mass overrides duration/bounce
787
897
  if (!isSpringType(options, physicsKeys) &&
788
898
  isSpringType(options, durationKeys)) {
789
- const derived = findSpring(options);
790
- springOptions = {
791
- ...springOptions,
792
- ...derived,
793
- mass: 1.0,
794
- };
795
- springOptions.isResolvedFromDuration = true;
899
+ if (options.visualDuration) {
900
+ const visualDuration = options.visualDuration;
901
+ const root = (2 * Math.PI) / (visualDuration * 1.2);
902
+ const stiffness = root * root;
903
+ const damping = 2 * clamp(0.05, 1, 1 - options.bounce) * Math.sqrt(stiffness);
904
+ springOptions = {
905
+ ...springOptions,
906
+ mass: springDefaults.mass,
907
+ stiffness,
908
+ damping,
909
+ };
910
+ }
911
+ else {
912
+ const derived = findSpring(options);
913
+ springOptions = {
914
+ ...springOptions,
915
+ ...derived,
916
+ mass: springDefaults.mass,
917
+ };
918
+ springOptions.isResolvedFromDuration = true;
919
+ }
796
920
  }
797
921
  return springOptions;
798
922
  }
799
- function spring({ keyframes, restDelta, restSpeed, ...options }) {
800
- const origin = keyframes[0];
801
- const target = keyframes[keyframes.length - 1];
923
+ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
924
+ const options = typeof optionsOrVisualDuration !== "object"
925
+ ? {
926
+ visualDuration: optionsOrVisualDuration,
927
+ keyframes: [0, 1],
928
+ bounce,
929
+ }
930
+ : optionsOrVisualDuration;
931
+ let { restSpeed, restDelta } = options;
932
+ const origin = options.keyframes[0];
933
+ const target = options.keyframes[options.keyframes.length - 1];
802
934
  /**
803
935
  * This is the Iterator-spec return value. We ensure it's mutable rather than using a generator
804
936
  * to reduce GC during animation.
@@ -820,8 +952,12 @@ function spring({ keyframes, restDelta, restSpeed, ...options }) {
820
952
  * ratio between feeling good and finishing as soon as changes are imperceptible.
821
953
  */
822
954
  const isGranularScale = Math.abs(initialDelta) < 5;
823
- restSpeed || (restSpeed = isGranularScale ? 0.01 : 2);
824
- restDelta || (restDelta = isGranularScale ? 0.005 : 0.5);
955
+ restSpeed || (restSpeed = isGranularScale
956
+ ? springDefaults.restSpeed.granular
957
+ : springDefaults.restSpeed.default);
958
+ restDelta || (restDelta = isGranularScale
959
+ ? springDefaults.restDelta.granular
960
+ : springDefaults.restDelta.default);
825
961
  let resolveSpring;
826
962
  if (dampingRatio < 1) {
827
963
  const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
@@ -862,7 +998,7 @@ function spring({ keyframes, restDelta, restSpeed, ...options }) {
862
998
  dampedAngularFreq);
863
999
  };
864
1000
  }
865
- return {
1001
+ const generator = {
866
1002
  calculatedDuration: isResolvedFromDuration ? duration || null : null,
867
1003
  next: (t) => {
868
1004
  const current = resolveSpring(t);
@@ -890,23 +1026,13 @@ function spring({ keyframes, restDelta, restSpeed, ...options }) {
890
1026
  state.value = state.done ? target : current;
891
1027
  return state;
892
1028
  },
1029
+ toString: () => {
1030
+ const calculatedDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
1031
+ const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
1032
+ return calculatedDuration + "ms " + easing;
1033
+ },
893
1034
  };
894
- }
895
-
896
- /**
897
- * Implement a practical max duration for keyframe generation
898
- * to prevent infinite loops
899
- */
900
- const maxGeneratorDuration = 20000;
901
- function calcGeneratorDuration(generator) {
902
- let duration = 0;
903
- const timeStep = 50;
904
- let state = generator.next(duration);
905
- while (!state.done && duration < maxGeneratorDuration) {
906
- duration += timeStep;
907
- state = generator.next(duration);
908
- }
909
- return duration >= maxGeneratorDuration ? Infinity : duration;
1035
+ return generator;
910
1036
  }
911
1037
 
912
1038
  /**
@@ -947,23 +1073,6 @@ const mixNumber$1 = (from, to, progress) => {
947
1073
  return from + (to - from) * progress;
948
1074
  };
949
1075
 
950
- /*
951
- Progress within given range
952
-
953
- Given a lower limit and an upper limit, we return the progress
954
- (expressed as a number 0-1) represented by the given value, and
955
- limit that progress to within 0-1.
956
-
957
- @param [number]: Lower limit
958
- @param [number]: Upper limit
959
- @param [number]: Value to find progress within given range
960
- @return [number]: Progress of value within range as expressed 0-1
961
- */
962
- const progress = (from, to, value) => {
963
- const toFromDifference = to - from;
964
- return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
965
- };
966
-
967
1076
  function fillOffset(offset, remaining) {
968
1077
  const min = offset[offset.length - 1];
969
1078
  for (let i = 1; i <= remaining; i++) {
@@ -980,31 +1089,6 @@ function defaultOffset$1(arr) {
980
1089
 
981
1090
  const isMotionValue = (value) => Boolean(value && value.getVelocity);
982
1091
 
983
- function resolveElements(elements, scope, selectorCache) {
984
- var _a;
985
- if (typeof elements === "string") {
986
- let root = document;
987
- if (scope) {
988
- exports.invariant(Boolean(scope.current), "Scope provided, but no element detected.");
989
- root = scope.current;
990
- }
991
- if (selectorCache) {
992
- (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = root.querySelectorAll(elements));
993
- elements = selectorCache[elements];
994
- }
995
- else {
996
- elements = root.querySelectorAll(elements);
997
- }
998
- }
999
- else if (elements instanceof Element) {
1000
- elements = [elements];
1001
- }
1002
- /**
1003
- * Return an empty array
1004
- */
1005
- return Array.from(elements || []);
1006
- }
1007
-
1008
1092
  function isDOMKeyframes(keyframes) {
1009
1093
  return typeof keyframes === "object" && !Array.isArray(keyframes);
1010
1094
  }
@@ -3322,18 +3406,6 @@ const acceleratedValues = new Set([
3322
3406
  // "background-color"
3323
3407
  ]);
3324
3408
 
3325
- // Create a linear easing point for every 10 ms
3326
- const resolution = 10;
3327
- const generateLinearEasing = (easing, duration // as milliseconds
3328
- ) => {
3329
- let points = "";
3330
- const numPoints = Math.max(Math.round(duration / resolution), 2);
3331
- for (let i = 0; i < numPoints; i++) {
3332
- points += easing(progress(0, numPoints - 1, i)) + ", ";
3333
- }
3334
- return `linear(${points.substring(0, points.length - 2)})`;
3335
- };
3336
-
3337
3409
  /**
3338
3410
  * Add the ability for test suites to manually set support flags
3339
3411
  * to better test more environments.
@@ -4103,7 +4175,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4103
4175
  * and warn against mismatches.
4104
4176
  */
4105
4177
  if (process.env.NODE_ENV === "development") {
4106
- warnOnce(nextValue.version === "11.11.17", `Attempting to mix Motion versions ${nextValue.version} with 11.11.17 may not work as expected.`);
4178
+ warnOnce(nextValue.version === "11.13.0-beta.0", `Attempting to mix Motion versions ${nextValue.version} with 11.13.0-beta.0 may not work as expected.`);
4107
4179
  }
4108
4180
  }
4109
4181
  else if (isMotionValue(prevValue)) {
@@ -5251,6 +5323,7 @@ class NativeAnimation {
5251
5323
  valueKeyframes = [valueKeyframes];
5252
5324
  }
5253
5325
  hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
5326
+ // TODO: Replace this with toString()?
5254
5327
  if (isGenerator(options.type)) {
5255
5328
  const generatorOptions = createGeneratorEasing(options, 100, options.type);
5256
5329
  options.ease = supportsLinearEasing()
@@ -6123,6 +6196,7 @@ exports.easeOut = easeOut;
6123
6196
  exports.frame = frame;
6124
6197
  exports.frameData = frameData;
6125
6198
  exports.frameSteps = frameSteps;
6199
+ exports.hover = hover;
6126
6200
  exports.inView = inView;
6127
6201
  exports.inertia = inertia;
6128
6202
  exports.interpolate = interpolate;
@@ -6130,8 +6204,10 @@ exports.keyframes = keyframes;
6130
6204
  exports.mirrorEasing = mirrorEasing;
6131
6205
  exports.mix = mix;
6132
6206
  exports.motionValue = motionValue;
6207
+ exports.noop = noop;
6133
6208
  exports.pipe = pipe;
6134
6209
  exports.progress = progress;
6210
+ exports.resolveElements = resolveElements;
6135
6211
  exports.reverseEasing = reverseEasing;
6136
6212
  exports.scroll = scroll;
6137
6213
  exports.scrollInfo = scrollInfo;
package/dist/cjs/mini.js CHANGED
@@ -91,6 +91,27 @@ class GroupPlaybackControls {
91
91
  }
92
92
  }
93
93
 
94
+ function resolveElements(elementOrSelector, scope, selectorCache) {
95
+ var _a;
96
+ if (elementOrSelector instanceof Element) {
97
+ return [elementOrSelector];
98
+ }
99
+ else if (typeof elementOrSelector === "string") {
100
+ let root = document;
101
+ if (scope) {
102
+ // TODO: Refactor to utils package
103
+ // invariant(
104
+ // Boolean(scope.current),
105
+ // "Scope provided, but no element detected."
106
+ // )
107
+ root = scope.current;
108
+ }
109
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
110
+ return elements ? Array.from(elements) : [];
111
+ }
112
+ return Array.from(elementOrSelector);
113
+ }
114
+
94
115
  const noop = (any) => any;
95
116
 
96
117
  let invariant = noop;
@@ -102,31 +123,6 @@ if (process.env.NODE_ENV !== "production") {
102
123
  };
103
124
  }
104
125
 
105
- function resolveElements(elements, scope, selectorCache) {
106
- var _a;
107
- if (typeof elements === "string") {
108
- let root = document;
109
- if (scope) {
110
- invariant(Boolean(scope.current), "Scope provided, but no element detected.");
111
- root = scope.current;
112
- }
113
- if (selectorCache) {
114
- (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = root.querySelectorAll(elements));
115
- elements = selectorCache[elements];
116
- }
117
- else {
118
- elements = root.querySelectorAll(elements);
119
- }
120
- }
121
- else if (elements instanceof Element) {
122
- elements = [elements];
123
- }
124
- /**
125
- * Return an empty array
126
- */
127
- return Array.from(elements || []);
128
- }
129
-
130
126
  /**
131
127
  * Converts seconds to milliseconds
132
128
  *
@@ -163,9 +159,8 @@ const progress = (from, to, value) => {
163
159
  return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
164
160
  };
165
161
 
166
- // Create a linear easing point for every 10 ms
167
- const resolution = 10;
168
- const generateLinearEasing = (easing, duration // as milliseconds
162
+ const generateLinearEasing = (easing, duration, // as milliseconds
163
+ resolution = 10 // as milliseconds
169
164
  ) => {
170
165
  let points = "";
171
166
  const numPoints = Math.max(Math.round(duration / resolution), 2);
@@ -403,6 +398,7 @@ class NativeAnimation {
403
398
  valueKeyframes = [valueKeyframes];
404
399
  }
405
400
  hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
401
+ // TODO: Replace this with toString()?
406
402
  if (isGenerator(options.type)) {
407
403
  const generatorOptions = createGeneratorEasing(options, 100, options.type);
408
404
  options.ease = supportsLinearEasing()