framer-motion 10.3.4 → 10.4.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 (41) hide show
  1. package/dist/cjs/dom-entry.js +1 -1
  2. package/dist/cjs/index.js +135 -1958
  3. package/dist/cjs/{wrap-196fd3c5.js → wrap-58c66ad3.js} +3790 -1847
  4. package/dist/dom-entry.d.ts +43 -34
  5. package/dist/es/animation/animate.mjs +38 -34
  6. package/dist/es/animation/{create-instant-animation.mjs → animators/instant.mjs} +5 -2
  7. package/dist/es/animation/{js → animators/js}/driver-frameloop.mjs +2 -2
  8. package/dist/es/animation/{js → animators/js}/index.mjs +10 -9
  9. package/dist/es/animation/{waapi → animators/waapi}/create-accelerated-animation.mjs +22 -3
  10. package/dist/es/animation/hooks/animation-controls.mjs +4 -1
  11. package/dist/es/animation/hooks/use-animated-state.mjs +1 -1
  12. package/dist/es/animation/{index.mjs → interfaces/motion-value.mjs} +12 -12
  13. package/dist/es/animation/interfaces/single-value.mjs +11 -0
  14. package/dist/es/animation/interfaces/visual-element-target.mjs +66 -0
  15. package/dist/es/animation/interfaces/visual-element-variant.mjs +63 -0
  16. package/dist/es/animation/interfaces/visual-element.mjs +24 -0
  17. package/dist/es/animation/optimized-appear/start.mjs +1 -1
  18. package/dist/es/animation/utils/create-visual-element.mjs +32 -0
  19. package/dist/es/animation/utils/is-dom-keyframes.mjs +5 -0
  20. package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
  21. package/dist/es/index.mjs +2 -2
  22. package/dist/es/projection/node/create-projection-node.mjs +5 -4
  23. package/dist/es/render/VisualElement.mjs +3 -0
  24. package/dist/es/render/dom/utils/is-svg-element.mjs +5 -0
  25. package/dist/es/render/store.mjs +3 -0
  26. package/dist/es/render/utils/animation-state.mjs +1 -1
  27. package/dist/es/render/utils/motion-values.mjs +1 -1
  28. package/dist/es/utils/interpolate.mjs +6 -0
  29. package/dist/es/value/index.mjs +1 -1
  30. package/dist/es/value/use-spring.mjs +1 -1
  31. package/dist/framer-motion.dev.js +4948 -4872
  32. package/dist/framer-motion.js +1 -1
  33. package/dist/index.d.ts +57 -51
  34. package/dist/projection.dev.js +4982 -5008
  35. package/dist/three-entry.d.ts +6 -10
  36. package/package.json +5 -5
  37. package/dist/es/render/utils/animation.mjs +0 -145
  38. /package/dist/es/animation/{waapi → animators/waapi}/easing.mjs +0 -0
  39. /package/dist/es/animation/{waapi → animators/waapi}/index.mjs +0 -0
  40. /package/dist/es/animation/{waapi → animators/waapi}/supports.mjs +0 -0
  41. /package/dist/es/animation/{waapi → animators/waapi}/utils/get-final-keyframe.mjs +0 -0
@@ -1,5 +1,4 @@
1
1
  import { cancelSync, flushSync, sync } from '../../frameloop/index.mjs';
2
- import { animate } from '../../animation/animate.mjs';
3
2
  import { SubscriptionManager } from '../../utils/subscription-manager.mjs';
4
3
  import { mixValues } from '../animation/mix-values.mjs';
5
4
  import { copyBoxInto } from '../geometry/copy.mjs';
@@ -20,6 +19,8 @@ import { globalProjectionState } from './state.mjs';
20
19
  import { delay } from '../../utils/delay.mjs';
21
20
  import { mix } from '../../utils/mix.mjs';
22
21
  import { record } from '../../debug/record.mjs';
22
+ import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
23
+ import { animateSingleValue } from '../../animation/interfaces/single-value.mjs';
23
24
  import { frameData } from '../../frameloop/data.mjs';
24
25
 
25
26
  const transformAxes = ["", "X", "Y", "Z"];
@@ -198,8 +199,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
198
199
  mount(instance, isLayoutDirty = false) {
199
200
  if (this.instance)
200
201
  return;
201
- this.isSVG =
202
- instance instanceof SVGElement && instance.tagName !== "svg";
202
+ this.isSVG = isSVGElement(instance);
203
203
  this.instance = instance;
204
204
  const { layoutId, layout, visualElement } = this.options;
205
205
  if (visualElement && !visualElement.current) {
@@ -954,8 +954,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
954
954
  */
955
955
  this.pendingAnimation = sync.update(() => {
956
956
  globalProjectionState.hasAnimatedSinceResize = true;
957
- this.currentAnimation = animate(0, animationTarget, {
957
+ this.currentAnimation = animateSingleValue(0, animationTarget, {
958
958
  ...options,
959
+ // keyframes: [0, animationTarget],÷
959
960
  onUpdate: (latest) => {
960
961
  this.mixTargetDelta(latest);
961
962
  options.onUpdate && options.onUpdate(latest);
@@ -16,6 +16,7 @@ import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
16
16
  import { warnOnce } from '../utils/warn-once.mjs';
17
17
  import { featureDefinitions } from '../motion/features/definitions.mjs';
18
18
  import { variantProps } from './utils/variant-props.mjs';
19
+ import { visualElementStore } from './store.mjs';
19
20
 
20
21
  const featureNames = Object.keys(featureDefinitions);
21
22
  const numFeatures = featureNames.length;
@@ -146,6 +147,7 @@ class VisualElement {
146
147
  }
147
148
  mount(instance) {
148
149
  this.current = instance;
150
+ visualElementStore.set(instance, this);
149
151
  if (this.projection) {
150
152
  this.projection.mount(instance);
151
153
  }
@@ -170,6 +172,7 @@ class VisualElement {
170
172
  this.update(this.props, this.presenceContext);
171
173
  }
172
174
  unmount() {
175
+ visualElementStore.delete(this.current);
173
176
  this.projection && this.projection.unmount();
174
177
  cancelSync.update(this.notifyUpdate);
175
178
  cancelSync.render(this.render);
@@ -0,0 +1,5 @@
1
+ function isSVGElement(element) {
2
+ return element instanceof SVGElement && element.tagName !== "svg";
3
+ }
4
+
5
+ export { isSVGElement };
@@ -0,0 +1,3 @@
1
+ const visualElementStore = new WeakMap();
2
+
3
+ export { visualElementStore };
@@ -1,10 +1,10 @@
1
1
  import { isAnimationControls } from '../../animation/utils/is-animation-controls.mjs';
2
2
  import { isKeyframesTarget } from '../../animation/utils/is-keyframes-target.mjs';
3
3
  import { shallowCompare } from '../../utils/shallow-compare.mjs';
4
- import { animateVisualElement } from './animation.mjs';
5
4
  import { isVariantLabel } from './is-variant-label.mjs';
6
5
  import { resolveVariant } from './resolve-dynamic-variants.mjs';
7
6
  import { variantPriorityOrder } from './variant-props.mjs';
7
+ import { animateVisualElement } from '../../animation/interfaces/visual-element.mjs';
8
8
 
9
9
  const reversePriorityOrder = [...variantPriorityOrder].reverse();
10
10
  const numAnimationTypes = variantPriorityOrder.length;
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
22
22
  * and warn against mismatches.
23
23
  */
24
24
  if (process.env.NODE_ENV === "development") {
25
- warnOnce(nextValue.version === "10.3.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.3.4 may not work as expected.`);
25
+ warnOnce(nextValue.version === "10.4.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.4.0 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -65,6 +65,12 @@ function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {})
65
65
  const inputLength = input.length;
66
66
  invariant(inputLength === output.length, "Both input and output ranges must be the same length");
67
67
  invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, "Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.");
68
+ /**
69
+ * If we're only provided a single input, we can just make a function
70
+ * that returns the output.
71
+ */
72
+ if (inputLength === 1)
73
+ return () => output[0];
68
74
  // If input runs highest -> lowest, reverse both arrays
69
75
  if (input[0] > input[inputLength - 1]) {
70
76
  input = [...input].reverse();
@@ -26,7 +26,7 @@ class MotionValue {
26
26
  * This will be replaced by the build step with the latest version number.
27
27
  * When MotionValues are provided to motion components, warn if versions are mixed.
28
28
  */
29
- this.version = "10.3.4";
29
+ this.version = "10.4.0";
30
30
  /**
31
31
  * Duration, in milliseconds, since last updating frame.
32
32
  *
@@ -3,7 +3,7 @@ import { isMotionValue } from './utils/is-motion-value.mjs';
3
3
  import { useMotionValue } from './use-motion-value.mjs';
4
4
  import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
5
5
  import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
6
- import { animateValue } from '../animation/js/index.mjs';
6
+ import { animateValue } from '../animation/animators/js/index.mjs';
7
7
 
8
8
  /**
9
9
  * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.