framer-motion 5.3.0 → 5.4.0-beta

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 (73) hide show
  1. package/dist/es/animation/utils/easing.mjs +1 -1
  2. package/dist/es/animation/utils/transitions.mjs +9 -3
  3. package/dist/es/components/AnimatePresence/index.mjs +1 -1
  4. package/dist/es/components/AnimatePresence/use-presence.mjs +1 -27
  5. package/dist/es/components/AnimateSharedLayout.mjs +1 -1
  6. package/dist/es/components/Reorder/Item.mjs +5 -4
  7. package/dist/es/context/MotionContext/index.mjs +1 -1
  8. package/dist/es/events/use-dom-event.mjs +2 -31
  9. package/dist/es/events/use-pointer-event.mjs +2 -5
  10. package/dist/es/gestures/use-hover-gesture.mjs +4 -1
  11. package/dist/es/gestures/use-tap-gesture.mjs +4 -1
  12. package/dist/es/gestures/utils/event-type.mjs +1 -8
  13. package/dist/es/index.mjs +1 -0
  14. package/dist/es/motion/features/viewport/use-viewport.mjs +2 -2
  15. package/dist/es/motion/index.mjs +1 -1
  16. package/dist/es/motion/utils/use-visual-state.mjs +29 -10
  17. package/dist/es/motion/utils/valid-prop.mjs +1 -0
  18. package/dist/es/projection/animation/mix-values.mjs +1 -1
  19. package/dist/es/projection/geometry/models.mjs +1 -11
  20. package/dist/es/projection/node/create-projection-node.mjs +4 -1167
  21. package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
  22. package/dist/es/projection/styles/transform.mjs +5 -5
  23. package/dist/es/render/dom/motion-proxy.mjs +3 -0
  24. package/dist/es/render/dom/utils/css-variables-conversion.mjs +2 -2
  25. package/dist/es/render/dom/utils/filter-props.mjs +3 -1
  26. package/dist/es/render/dom/value-types/dimensions.mjs +1 -8
  27. package/dist/es/render/html/use-props.mjs +6 -4
  28. package/dist/es/render/html/utils/build-transform.mjs +2 -2
  29. package/dist/es/render/svg/utils/path.mjs +1 -1
  30. package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
  31. package/dist/es/render/three/create-visual-element.mjs +42 -0
  32. package/dist/es/render/three/gestures/use-hover.mjs +22 -0
  33. package/dist/es/render/three/gestures/use-tap.mjs +56 -0
  34. package/dist/es/render/three/motion.mjs +30 -0
  35. package/dist/es/render/three/use-render.mjs +11 -0
  36. package/dist/es/render/three/utils/read-value.mjs +43 -0
  37. package/dist/es/render/three/utils/set-value.mjs +59 -0
  38. package/dist/es/render/utils/animation-state.mjs +5 -4
  39. package/dist/es/render/utils/animation.mjs +1 -4
  40. package/dist/es/render/utils/setters.mjs +3 -42
  41. package/dist/es/three-entry.mjs +1 -0
  42. package/dist/es/utils/array.mjs +2 -13
  43. package/dist/es/utils/use-force-update.mjs +13 -9
  44. package/dist/es/utils/use-instant-transition-state.mjs +5 -0
  45. package/dist/es/utils/use-instant-transition.mjs +28 -0
  46. package/dist/framer-motion-three.cjs.js +2995 -0
  47. package/dist/framer-motion.cjs.js +147 -84
  48. package/dist/framer-motion.dev.js +139 -76
  49. package/dist/framer-motion.js +1 -1
  50. package/dist/projection.dev.js +35 -23
  51. package/dist/size-rollup-dom-animation.js +1 -1
  52. package/dist/size-rollup-dom-max.js +1 -1
  53. package/dist/size-rollup-m.js +1 -1
  54. package/package.json +179 -158
  55. package/types/components/Reorder/Item.d.ts +1 -1
  56. package/types/index.d.ts +1 -0
  57. package/types/motion/features/types.d.ts +1 -1
  58. package/types/motion/features/viewport/types.d.ts +1 -1
  59. package/types/render/three/create-visual-element.d.ts +6 -0
  60. package/types/render/three/gestures/use-hover.d.ts +10 -0
  61. package/types/render/three/gestures/use-tap.d.ts +8 -0
  62. package/types/render/three/motion.d.ts +5 -0
  63. package/types/render/three/types.d.ts +24 -0
  64. package/types/render/three/use-render.d.ts +4 -0
  65. package/types/render/three/utils/read-value.d.ts +2 -0
  66. package/types/render/three/utils/set-value.d.ts +2 -0
  67. package/types/render/utils/animation-state.d.ts +1 -1
  68. package/types/render/utils/lifecycles.d.ts +8 -8
  69. package/types/render/utils/setters.d.ts +1 -0
  70. package/types/three-entry.d.ts +1 -0
  71. package/types/utils/use-instant-transition-state.d.ts +3 -0
  72. package/types/utils/use-instant-transition.d.ts +1 -0
  73. package/CHANGELOG.md +0 -1953
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Motion = {}, global.React));
5
- }(this, (function (exports, React) { 'use strict';
5
+ })(this, (function (exports, React) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -15,14 +15,12 @@
15
15
  var d = Object.getOwnPropertyDescriptor(e, k);
16
16
  Object.defineProperty(n, k, d.get ? d : {
17
17
  enumerable: true,
18
- get: function () {
19
- return e[k];
20
- }
18
+ get: function () { return e[k]; }
21
19
  });
22
20
  }
23
21
  });
24
22
  }
25
- n['default'] = e;
23
+ n["default"] = e;
26
24
  return Object.freeze(n);
27
25
  }
28
26
 
@@ -1944,7 +1942,7 @@
1944
1942
  }
1945
1943
  else if (typeof definition === "string") {
1946
1944
  // Else lookup from table
1947
- invariant(easingLookup[definition] !== undefined, "Invalid easing type '" + definition + "'");
1945
+ invariant(easingLookup[definition] !== undefined, "Invalid easing type '".concat(definition, "'"));
1948
1946
  return easingLookup[definition];
1949
1947
  }
1950
1948
  return definition;
@@ -2127,6 +2125,18 @@
2127
2125
  return (_a = defaultValueType.getAnimatableNone) === null || _a === void 0 ? void 0 : _a.call(defaultValueType, value);
2128
2126
  }
2129
2127
 
2128
+ var instantAnimationState = {
2129
+ current: false,
2130
+ };
2131
+
2132
+ var isCustomValue = function (v) {
2133
+ return Boolean(v && typeof v === "object" && v.mix && v.toValue);
2134
+ };
2135
+ var resolveFinalValueInKeyframes = function (v) {
2136
+ // TODO maybe throw if v.length - 1 is placeholder token?
2137
+ return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
2138
+ };
2139
+
2130
2140
  /**
2131
2141
  * Decide whether a transition is defined on a given Transition.
2132
2142
  * This filters out orchestration options and returns true
@@ -2244,7 +2254,7 @@
2244
2254
  target = getZeroUnit(origin);
2245
2255
  }
2246
2256
  var isOriginAnimatable = isAnimatable(key, origin);
2247
- warning(isOriginAnimatable === isTargetAnimatable, "You are trying to animate " + key + " from \"" + origin + "\" to \"" + target + "\". " + origin + " is not an animatable value - to enable this animation set " + origin + " to a value animatable to " + target + " via the `style` property.");
2257
+ warning(isOriginAnimatable === isTargetAnimatable, "You are trying to animate ".concat(key, " from \"").concat(origin, "\" to \"").concat(target, "\". ").concat(origin, " is not an animatable value - to enable this animation set ").concat(origin, " to a value animatable to ").concat(target, " via the `style` property."));
2248
2258
  function start() {
2249
2259
  var options = {
2250
2260
  from: origin,
@@ -2268,9 +2278,10 @@
2268
2278
  }
2269
2279
  function set() {
2270
2280
  var _a, _b;
2271
- value.set(target);
2281
+ var finalTarget = resolveFinalValueInKeyframes(target);
2282
+ value.set(finalTarget);
2272
2283
  onComplete();
2273
- (_a = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, target);
2284
+ (_a = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, finalTarget);
2274
2285
  (_b = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onComplete) === null || _b === void 0 ? void 0 : _b.call(valueTransition);
2275
2286
  return { stop: function () { } };
2276
2287
  }
@@ -2302,6 +2313,9 @@
2302
2313
  */
2303
2314
  function startAnimation(key, value, target, transition) {
2304
2315
  if (transition === void 0) { transition = {}; }
2316
+ if (instantAnimationState.current) {
2317
+ transition = { type: false };
2318
+ }
2305
2319
  return value.start(function (onComplete) {
2306
2320
  var delayTimer;
2307
2321
  var controls;
@@ -2376,7 +2390,7 @@
2376
2390
  * Mix border radius
2377
2391
  */
2378
2392
  for (var i = 0; i < numBorders; i++) {
2379
- var borderLabel = "border" + borders[i] + "Radius";
2393
+ var borderLabel = "border".concat(borders[i], "Radius");
2380
2394
  var followRadius = getRadius(follow, borderLabel);
2381
2395
  var leadRadius = getRadius(lead, borderLabel);
2382
2396
  if (followRadius === undefined && leadRadius === undefined)
@@ -2833,17 +2847,17 @@
2833
2847
  */
2834
2848
  var xTranslate = delta.x.translate / treeScale.x;
2835
2849
  var yTranslate = delta.y.translate / treeScale.y;
2836
- var transform = "translate3d(" + xTranslate + "px, " + yTranslate + "px, 0) ";
2850
+ var transform = "translate3d(".concat(xTranslate, "px, ").concat(yTranslate, "px, 0) ");
2837
2851
  if (latestTransform) {
2838
2852
  var rotate = latestTransform.rotate, rotateX = latestTransform.rotateX, rotateY = latestTransform.rotateY;
2839
2853
  if (rotate)
2840
- transform += "rotate(" + rotate + "deg) ";
2854
+ transform += "rotate(".concat(rotate, "deg) ");
2841
2855
  if (rotateX)
2842
- transform += "rotateX(" + rotateX + "deg) ";
2856
+ transform += "rotateX(".concat(rotateX, "deg) ");
2843
2857
  if (rotateY)
2844
- transform += "rotateY(" + rotateY + "deg) ";
2858
+ transform += "rotateY(".concat(rotateY, "deg) ");
2845
2859
  }
2846
- transform += "scale(" + delta.x.scale + ", " + delta.y.scale + ")";
2860
+ transform += "scale(".concat(delta.x.scale, ", ").concat(delta.y.scale, ")");
2847
2861
  return transform === identityProjection ? "none" : transform;
2848
2862
  }
2849
2863
 
@@ -2916,14 +2930,6 @@
2916
2930
  return FlatTree;
2917
2931
  }());
2918
2932
 
2919
- var isCustomValue = function (v) {
2920
- return Boolean(v && typeof v === "object" && v.mix && v.toValue);
2921
- };
2922
- var resolveFinalValueInKeyframes = function (v) {
2923
- // TODO maybe throw if v.length - 1 is placeholder token?
2924
- return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
2925
- };
2926
-
2927
2933
  /**
2928
2934
  * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
2929
2935
  *
@@ -3882,7 +3888,7 @@
3882
3888
  styles.transform = transformTemplate(valuesToRender, styles.transform);
3883
3889
  }
3884
3890
  var _g = this.projectionDelta, x = _g.x, y = _g.y;
3885
- styles.transformOrigin = x.origin * 100 + "% " + y.origin * 100 + "% 0";
3891
+ styles.transformOrigin = "".concat(x.origin * 100, "% ").concat(y.origin * 100, "% 0");
3886
3892
  if (lead.animationValues) {
3887
3893
  /**
3888
3894
  * If the lead component is animating, assign this either the entering/leaving
@@ -4088,7 +4094,7 @@
4088
4094
  }
4089
4095
  }
4090
4096
  var searchElement = searchNode && searchNode !== node.root ? searchNode.instance : document;
4091
- var element = searchElement.querySelector("[data-projection-id=\"" + id + "\"]");
4097
+ var element = searchElement.querySelector("[data-projection-id=\"".concat(id, "\"]"));
4092
4098
  if (element)
4093
4099
  node.mount(element, true);
4094
4100
  }
@@ -4171,7 +4177,7 @@
4171
4177
  return this.props.children;
4172
4178
  };
4173
4179
  return VisualElementHandler;
4174
- }(React__default['default'].Component));
4180
+ }(React__default["default"].Component));
4175
4181
 
4176
4182
  /**
4177
4183
  * Create a `motion` component.
@@ -4237,7 +4243,7 @@
4237
4243
  */
4238
4244
  return (React__namespace.createElement(VisualElementHandler, { visualElement: context.visualElement, props: __assign(__assign({}, config), props) },
4239
4245
  features,
4240
- React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, config.isStatic))));
4246
+ React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, config.isStatic, context.visualElement))));
4241
4247
  }
4242
4248
  return React.forwardRef(MotionComponent);
4243
4249
  }
@@ -4269,6 +4275,9 @@
4269
4275
  if (customMotionComponentConfig === void 0) { customMotionComponentConfig = {}; }
4270
4276
  return createMotionComponent(createConfig(Component, customMotionComponentConfig));
4271
4277
  }
4278
+ if (typeof Proxy === "undefined") {
4279
+ return custom;
4280
+ }
4272
4281
  /**
4273
4282
  * A cache of generated `motion` components, e.g `motion.div`, `motion.input` etc.
4274
4283
  * Rather than generating them anew every render.
@@ -4385,7 +4394,7 @@
4385
4394
  var numTransformKeys = transformKeys.length;
4386
4395
  for (var i = 0; i < numTransformKeys; i++) {
4387
4396
  var key = transformKeys[i];
4388
- transformString += (translateAlias[key] || key) + "(" + transform[key] + ") ";
4397
+ transformString += "".concat(translateAlias[key] || key, "(").concat(transform[key], ") ");
4389
4398
  if (key === "z")
4390
4399
  transformHasZ = true;
4391
4400
  }
@@ -4411,7 +4420,7 @@
4411
4420
  */
4412
4421
  function buildTransformOrigin(_a) {
4413
4422
  var _b = _a.originX, originX = _b === void 0 ? "50%" : _b, _c = _a.originY, originY = _c === void 0 ? "50%" : _c, _d = _a.originZ, originZ = _d === void 0 ? 0 : _d;
4414
- return originX + " " + originY + " " + originZ;
4423
+ return "".concat(originX, " ").concat(originY, " ").concat(originZ);
4415
4424
  }
4416
4425
 
4417
4426
  /**
@@ -4533,17 +4542,19 @@
4533
4542
  // The `any` isn't ideal but it is the type of createElement props argument
4534
4543
  var htmlProps = {};
4535
4544
  var style = useStyle(props, visualState, isStatic);
4536
- if (Boolean(props.drag)) {
4545
+ if (Boolean(props.drag) && props.dragListener !== false) {
4537
4546
  // Disable the ghost element when a user drags
4538
4547
  htmlProps.draggable = false;
4539
4548
  // Disable text selection
4540
- style.userSelect = style.WebkitUserSelect = style.WebkitTouchCallout =
4541
- "none";
4549
+ style.userSelect =
4550
+ style.WebkitUserSelect =
4551
+ style.WebkitTouchCallout =
4552
+ "none";
4542
4553
  // Disable scrolling on the draggable direction
4543
4554
  style.touchAction =
4544
4555
  props.drag === true
4545
4556
  ? "none"
4546
- : "pan-" + (props.drag === "x" ? "y" : "x");
4557
+ : "pan-".concat(props.drag === "x" ? "y" : "x");
4547
4558
  }
4548
4559
  htmlProps.style = style;
4549
4560
  return htmlProps;
@@ -4568,6 +4579,7 @@
4568
4579
  "inherit",
4569
4580
  "layout",
4570
4581
  "layoutId",
4582
+ "layoutDependency",
4571
4583
  "onLayoutAnimationComplete",
4572
4584
  "onLayoutMeasure",
4573
4585
  "onBeforeLayoutMeasure",
@@ -4657,7 +4669,9 @@
4657
4669
  for (var key in props) {
4658
4670
  if (shouldForward(key) ||
4659
4671
  (forwardMotionProps === true && isValidMotionProp(key)) ||
4660
- (!isDom && !isValidMotionProp(key))) {
4672
+ (!isDom && !isValidMotionProp(key)) ||
4673
+ // If trying to use native HTML drag events, forward drag listeners
4674
+ (props["draggable"] && key.startsWith("onDrag"))) {
4661
4675
  filteredProps[key] = props[key];
4662
4676
  }
4663
4677
  }
@@ -4676,7 +4690,7 @@
4676
4690
  function calcSVGTransformOrigin(dimensions, originX, originY) {
4677
4691
  var pxOriginX = calcOrigin$1(originX, dimensions.x, dimensions.width);
4678
4692
  var pxOriginY = calcOrigin$1(originY, dimensions.y, dimensions.height);
4679
- return pxOriginX + " " + pxOriginY;
4693
+ return "".concat(pxOriginX, " ").concat(pxOriginY);
4680
4694
  }
4681
4695
 
4682
4696
  var dashKeys = {
@@ -4708,7 +4722,7 @@
4708
4722
  // Build the dash array
4709
4723
  var pathLength = px.transform(length);
4710
4724
  var pathSpacing = px.transform(spacing);
4711
- attrs[keys.array] = pathLength + " " + pathSpacing;
4725
+ attrs[keys.array] = "".concat(pathLength, " ").concat(pathSpacing);
4712
4726
  }
4713
4727
 
4714
4728
  /**
@@ -4869,13 +4883,17 @@
4869
4883
  }
4870
4884
  return state;
4871
4885
  }
4872
- var makeUseVisualState = function (config) { return function (props, isStatic) {
4873
- var context = React.useContext(MotionContext);
4874
- var presenceContext = React.useContext(PresenceContext);
4875
- return isStatic
4876
- ? makeState(config, props, context, presenceContext)
4877
- : useConstant(function () { return makeState(config, props, context, presenceContext); });
4878
- }; };
4886
+ var makeUseVisualState = function (config) {
4887
+ return function (props, isStatic) {
4888
+ var context = React.useContext(MotionContext);
4889
+ var presenceContext = React.useContext(PresenceContext);
4890
+ return isStatic
4891
+ ? makeState(config, props, context, presenceContext)
4892
+ : useConstant(function () {
4893
+ return makeState(config, props, context, presenceContext);
4894
+ });
4895
+ };
4896
+ };
4879
4897
  function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
4880
4898
  var values = {};
4881
4899
  var blockInitialAnimation = (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false;
@@ -4893,7 +4911,8 @@
4893
4911
  initial !== null && initial !== void 0 ? initial : (initial = context.initial);
4894
4912
  animate !== null && animate !== void 0 ? animate : (animate = context.animate);
4895
4913
  }
4896
- var variantToSet = blockInitialAnimation || initial === false ? animate : initial;
4914
+ var initialAnimationIsBlocked = blockInitialAnimation || initial === false;
4915
+ var variantToSet = initialAnimationIsBlocked ? animate : initial;
4897
4916
  if (variantToSet &&
4898
4917
  typeof variantToSet !== "boolean" &&
4899
4918
  !isAnimationControls(variantToSet)) {
@@ -4903,8 +4922,22 @@
4903
4922
  if (!resolved)
4904
4923
  return;
4905
4924
  var transitionEnd = resolved.transitionEnd; resolved.transition; var target = __rest(resolved, ["transitionEnd", "transition"]);
4906
- for (var key in target)
4907
- values[key] = target[key];
4925
+ for (var key in target) {
4926
+ var valueTarget = target[key];
4927
+ if (Array.isArray(valueTarget)) {
4928
+ /**
4929
+ * Take final keyframe if the initial animation is blocked because
4930
+ * we want to initialise at the end of that blocked animation.
4931
+ */
4932
+ var index = initialAnimationIsBlocked
4933
+ ? valueTarget.length - 1
4934
+ : 0;
4935
+ valueTarget = valueTarget[index];
4936
+ }
4937
+ if (valueTarget !== null) {
4938
+ values[key] = valueTarget;
4939
+ }
4940
+ }
4908
4941
  for (var key in transitionEnd)
4909
4942
  values[key] = transitionEnd[key];
4910
4943
  });
@@ -5185,8 +5218,11 @@
5185
5218
  var _a;
5186
5219
  if (!isMouseEvent(event) || isDragActive())
5187
5220
  return;
5188
- callback === null || callback === void 0 ? void 0 : callback(event, info);
5221
+ /**
5222
+ * Ensure we trigger animations before firing event callback
5223
+ */
5189
5224
  (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Hover, isActive);
5225
+ callback === null || callback === void 0 ? void 0 : callback(event, info);
5190
5226
  };
5191
5227
  }
5192
5228
  function useHoverGesture(_a) {
@@ -5266,8 +5302,11 @@
5266
5302
  return;
5267
5303
  isPressing.current = true;
5268
5304
  cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp), addPointerEvent(window, "pointercancel", onPointerCancel));
5269
- onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
5305
+ /**
5306
+ * Ensure we trigger animations before firing event callback
5307
+ */
5270
5308
  (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Tap, true);
5309
+ onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
5271
5310
  }
5272
5311
  usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined);
5273
5312
  useUnmountEffect(removePointerEndListener);
@@ -5388,7 +5427,7 @@
5388
5427
  var callback = isIntersecting
5389
5428
  ? props.onViewportEnter
5390
5429
  : props.onViewportLeave;
5391
- callback === null || callback === void 0 ? void 0 : callback();
5430
+ callback === null || callback === void 0 ? void 0 : callback(entry);
5392
5431
  };
5393
5432
  return observeIntersection(visualElement.getInstance(), options, intersectionCallback);
5394
5433
  }, [shouldObserve, root, rootMargin, amount]);
@@ -5417,7 +5456,7 @@
5417
5456
  var _a;
5418
5457
  state.hasEnteredView = true;
5419
5458
  var onViewportEnter = visualElement.getProps().onViewportEnter;
5420
- onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter();
5459
+ onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter(null);
5421
5460
  (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, true);
5422
5461
  });
5423
5462
  }, [shouldObserve]);
@@ -5571,9 +5610,7 @@
5571
5610
  }
5572
5611
  function setTarget(visualElement, definition) {
5573
5612
  var resolved = resolveVariant(visualElement, definition);
5574
- var _a = resolved
5575
- ? visualElement.makeTargetAnimatable(resolved, false)
5576
- : {}, _b = _a.transitionEnd, transitionEnd = _b === void 0 ? {} : _b; _a.transition; var target = __rest(_a, ["transitionEnd", "transition"]);
5613
+ var _a = resolved ? visualElement.makeTargetAnimatable(resolved, false) : {}, _b = _a.transitionEnd, transitionEnd = _b === void 0 ? {} : _b; _a.transition; var target = __rest(_a, ["transitionEnd", "transition"]);
5577
5614
  target = __assign(__assign({}, target), transitionEnd);
5578
5615
  for (var key in target) {
5579
5616
  var value = resolveFinalValueInKeyframes(target[key]);
@@ -5927,7 +5964,8 @@
5927
5964
  * a changed value or a value that was removed in a higher priority, we set
5928
5965
  * this to true and add this prop to the animation list.
5929
5966
  */
5930
- var shouldAnimateType = variantsHaveChanged(typeState.prevProp, prop) ||
5967
+ var variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
5968
+ var shouldAnimateType = variantDidChange ||
5931
5969
  // If we're making this variant active, we want to always make it active
5932
5970
  (type === changedActiveType &&
5933
5971
  typeState.isActive &&
@@ -5978,7 +6016,7 @@
5978
6016
  * detect whether any value has changed. If it has, we animate it.
5979
6017
  */
5980
6018
  if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {
5981
- if (!shallowCompare(next, prev)) {
6019
+ if (!shallowCompare(next, prev) || variantDidChange) {
5982
6020
  markToAnimate(key);
5983
6021
  }
5984
6022
  else {
@@ -6095,7 +6133,7 @@
6095
6133
  getState: function () { return state; },
6096
6134
  };
6097
6135
  }
6098
- function variantsHaveChanged(prev, next) {
6136
+ function checkVariantsDidChange(prev, next) {
6099
6137
  if (typeof next === "string") {
6100
6138
  return next !== prev;
6101
6139
  }
@@ -7454,7 +7492,7 @@
7454
7492
  var maxDepth = 4;
7455
7493
  function getVariableValue(current, element, depth) {
7456
7494
  if (depth === void 0) { depth = 1; }
7457
- invariant(depth <= maxDepth, "Max CSS variable fallback depth detected in property \"" + current + "\". This may indicate a circular fallback dependency.");
7495
+ invariant(depth <= maxDepth, "Max CSS variable fallback depth detected in property \"".concat(current, "\". This may indicate a circular fallback dependency."));
7458
7496
  var _a = __read(parseCSSVariable(current), 2), token = _a[0], fallback = _a[1];
7459
7497
  // No CSS variable detected
7460
7498
  if (!token)
@@ -7481,7 +7519,7 @@
7481
7519
  var _b;
7482
7520
  var target = __rest(_a, []);
7483
7521
  var element = visualElement.getInstance();
7484
- if (!(element instanceof HTMLElement))
7522
+ if (!(element instanceof Element))
7485
7523
  return { target: target, transitionEnd: transitionEnd };
7486
7524
  // If `transitionEnd` isn't `undefined`, clone it. We could clone `target` and `transitionEnd`
7487
7525
  // only if they change but I think this reads clearer and this isn't a performance-critical path.
@@ -7928,7 +7966,7 @@
7928
7966
  */
7929
7967
  var x = pixelsToPercent(latest, node.target.x);
7930
7968
  var y = pixelsToPercent(latest, node.target.y);
7931
- return x + "% " + y + "%";
7969
+ return "".concat(x, "% ").concat(y, "%");
7932
7970
  },
7933
7971
  };
7934
7972
 
@@ -8084,11 +8122,11 @@
8084
8122
  return null;
8085
8123
  };
8086
8124
  return MeasureLayoutWithContext;
8087
- }(React__default['default'].Component));
8125
+ }(React__default["default"].Component));
8088
8126
  function MeasureLayout(props) {
8089
8127
  var _a = __read(usePresence(), 2), isPresent = _a[0], safeToRemove = _a[1];
8090
8128
  var layoutGroup = React.useContext(LayoutGroupContext);
8091
- return (React__default['default'].createElement(MeasureLayoutWithContext, __assign({}, props, { layoutGroup: layoutGroup, switchLayoutGroup: React.useContext(SwitchLayoutGroupContext), isPresent: isPresent, safeToRemove: safeToRemove })));
8129
+ return (React__default["default"].createElement(MeasureLayoutWithContext, __assign({}, props, { layoutGroup: layoutGroup, switchLayoutGroup: React.useContext(SwitchLayoutGroupContext), isPresent: isPresent, safeToRemove: safeToRemove })));
8092
8130
  }
8093
8131
  var defaultScaleCorrectors = {
8094
8132
  borderRadius: __assign(__assign({}, correctBorderRadius), { applyTo: [
@@ -8176,15 +8214,18 @@
8176
8214
  var m = createMotionProxy(createDomMotionConfig);
8177
8215
 
8178
8216
  function useForceUpdate() {
8179
- var unloadingRef = React.useRef(false);
8217
+ var isUnmountingRef = React.useRef(false);
8180
8218
  var _a = __read(React.useState(0), 2), forcedRenderCount = _a[0], setForcedRenderCount = _a[1];
8181
- useUnmountEffect(function () { return (unloadingRef.current = true); });
8182
- return [
8183
- React.useCallback(function () {
8184
- !unloadingRef.current && setForcedRenderCount(forcedRenderCount + 1);
8185
- }, [forcedRenderCount]),
8186
- forcedRenderCount,
8187
- ];
8219
+ useUnmountEffect(function () { return (isUnmountingRef.current = true); });
8220
+ var forceRender = React.useCallback(function () {
8221
+ !isUnmountingRef.current && setForcedRenderCount(forcedRenderCount + 1);
8222
+ }, [forcedRenderCount]);
8223
+ /**
8224
+ * Defer this to the end of the next animation frame in case there are multiple
8225
+ * synchronous calls.
8226
+ */
8227
+ var deferredForceRender = React.useCallback(function () { return sync.postRender(forceRender); }, [forceRender]);
8228
+ return [deferredForceRender, forcedRenderCount];
8188
8229
  }
8189
8230
 
8190
8231
  var presenceId = 0;
@@ -8257,7 +8298,7 @@
8257
8298
  var key = getChildKey(child);
8258
8299
  if (seenChildren) {
8259
8300
  if (seenChildren.has(key)) {
8260
- console.warn("Children of AnimatePresence require unique keys. \"" + key + "\" is a duplicate.");
8301
+ console.warn("Children of AnimatePresence require unique keys. \"".concat(key, "\" is a duplicate."));
8261
8302
  }
8262
8303
  seenChildren.add(key);
8263
8304
  }
@@ -8457,7 +8498,7 @@
8457
8498
  var id = 0;
8458
8499
  var AnimateSharedLayout = function (_a) {
8459
8500
  var children = _a.children;
8460
- return (React__namespace.createElement(LayoutGroup, { id: useConstant(function () { return "asl-" + id++; }) }, children));
8501
+ return (React__namespace.createElement(LayoutGroup, { id: useConstant(function () { return "asl-".concat(id++); }) }, children));
8461
8502
  };
8462
8503
 
8463
8504
  /**
@@ -8748,7 +8789,7 @@
8748
8789
  return isMotionValue(value) ? value : useMotionValue(defaultValue);
8749
8790
  }
8750
8791
  function ReorderItem(_a, externalRef) {
8751
- var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, props = __rest(_a, ["children", "style", "value", "as"]);
8792
+ var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, props = __rest(_a, ["children", "style", "value", "as", "onDrag"]);
8752
8793
  var Component = useConstant(function () { return motion(as); });
8753
8794
  var context = React.useContext(ReorderContext);
8754
8795
  var point = {
@@ -8757,7 +8798,7 @@
8757
8798
  };
8758
8799
  var zIndex = useTransform([point.x, point.y], function (_a) {
8759
8800
  var _b = __read(_a, 2), latestX = _b[0], latestY = _b[1];
8760
- return latestX || latestY ? 1 : 0;
8801
+ return latestX || latestY ? 1 : "unset";
8761
8802
  });
8762
8803
  var layout = React.useRef(null);
8763
8804
  invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
@@ -8765,10 +8806,11 @@
8765
8806
  React.useEffect(function () {
8766
8807
  registerItem(value, layout.current);
8767
8808
  }, [context]);
8768
- return (React__namespace.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout: true, onDrag: function (_event, _a) {
8769
- var velocity = _a.velocity;
8809
+ return (React__namespace.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout: true, onDrag: function (event, gesturePoint) {
8810
+ var velocity = gesturePoint.velocity;
8770
8811
  velocity[axis] &&
8771
8812
  updateOrder(value, point[axis].get(), velocity[axis]);
8813
+ onDrag === null || onDrag === void 0 ? void 0 : onDrag(event, gesturePoint);
8772
8814
  }, onLayoutMeasure: function (measured) {
8773
8815
  layout.current = measured;
8774
8816
  }, ref: externalRef }), children));
@@ -9330,6 +9372,26 @@
9330
9372
  cb === null || cb === void 0 ? void 0 : cb();
9331
9373
  }
9332
9374
 
9375
+ function useInstantTransition() {
9376
+ var _a = __read(useForceUpdate(), 2), forceUpdate = _a[0], forcedRenderCount = _a[1];
9377
+ var startInstantLayoutTransition = useInstantLayoutTransition();
9378
+ React.useEffect(function () {
9379
+ /**
9380
+ * Unblock after two animation frames, otherwise this will unblock too soon.
9381
+ */
9382
+ sync.postRender(function () {
9383
+ return sync.postRender(function () { return (instantAnimationState.current = false); });
9384
+ });
9385
+ }, [forcedRenderCount]);
9386
+ return function (callback) {
9387
+ startInstantLayoutTransition(function () {
9388
+ instantAnimationState.current = true;
9389
+ forceUpdate();
9390
+ callback();
9391
+ });
9392
+ };
9393
+ }
9394
+
9333
9395
  function useResetProjection() {
9334
9396
  var reset = React__namespace.useCallback(function () {
9335
9397
  var root = rootProjectionNode.current;
@@ -9473,6 +9535,7 @@
9473
9535
  exports.useDragControls = useDragControls;
9474
9536
  exports.useElementScroll = useElementScroll;
9475
9537
  exports.useInstantLayoutTransition = useInstantLayoutTransition;
9538
+ exports.useInstantTransition = useInstantTransition;
9476
9539
  exports.useIsPresent = useIsPresent;
9477
9540
  exports.useMotionTemplate = useMotionTemplate;
9478
9541
  exports.useMotionValue = useMotionValue;
@@ -9487,4 +9550,4 @@
9487
9550
 
9488
9551
  Object.defineProperty(exports, '__esModule', { value: true });
9489
9552
 
9490
- })));
9553
+ }));