framer-motion 5.2.0 → 5.3.1
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.
- package/dist/es/animation/utils/transitions.mjs +8 -2
- package/dist/es/components/Reorder/Item.mjs +4 -3
- package/dist/es/gestures/use-hover-gesture.mjs +4 -1
- package/dist/es/gestures/use-tap-gesture.mjs +4 -1
- package/dist/es/index.mjs +1 -0
- package/dist/es/motion/features/definitions.mjs +6 -0
- package/dist/es/motion/features/gestures.mjs +2 -0
- package/dist/es/motion/features/viewport/observers.mjs +52 -0
- package/dist/es/motion/features/viewport/use-viewport.mjs +97 -0
- package/dist/es/motion/utils/use-visual-state.mjs +29 -10
- package/dist/es/motion/utils/valid-prop.mjs +5 -0
- package/dist/es/projection/node/create-projection-node.mjs +1 -1
- package/dist/es/render/dom/utils/unit-conversion.mjs +8 -1
- package/dist/es/render/utils/animation-state.mjs +7 -4
- package/dist/es/render/utils/setters.mjs +1 -3
- package/dist/es/render/utils/types.mjs +1 -0
- package/dist/es/utils/use-instant-transition-state.mjs +5 -0
- package/dist/es/utils/use-instant-transition.mjs +28 -0
- package/dist/es/utils/warn-once.mjs +11 -0
- package/dist/framer-motion.cjs.js +259 -33
- package/dist/framer-motion.dev.js +259 -33
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +29 -8
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/package.json +11 -11
- package/types/components/Reorder/Item.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/motion/features/types.d.ts +2 -0
- package/types/motion/features/viewport/observers.d.ts +3 -0
- package/types/motion/features/viewport/types.d.ts +20 -0
- package/types/motion/features/viewport/use-viewport.d.ts +2 -0
- package/types/motion/types.d.ts +2 -1
- package/types/render/utils/animation-state.d.ts +1 -1
- package/types/render/utils/types.d.ts +1 -0
- package/types/utils/use-instant-transition-state.d.ts +3 -0
- package/types/utils/use-instant-transition.d.ts +1 -0
- package/types/utils/warn-once.d.ts +2 -0
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
"whileTap",
|
|
136
136
|
"whileFocus",
|
|
137
137
|
"whileDrag",
|
|
138
|
+
"whileInView",
|
|
138
139
|
]),
|
|
139
140
|
exit: createDefinition(["exit"]),
|
|
140
141
|
drag: createDefinition(["drag", "dragControls"]),
|
|
@@ -147,6 +148,11 @@
|
|
|
147
148
|
"onPanSessionStart",
|
|
148
149
|
"onPanEnd",
|
|
149
150
|
]),
|
|
151
|
+
inView: createDefinition([
|
|
152
|
+
"whileInView",
|
|
153
|
+
"onViewportEnter",
|
|
154
|
+
"onViewportLeave",
|
|
155
|
+
]),
|
|
150
156
|
};
|
|
151
157
|
function loadFeatures(features) {
|
|
152
158
|
for (var key in features) {
|
|
@@ -2121,6 +2127,18 @@
|
|
|
2121
2127
|
return (_a = defaultValueType.getAnimatableNone) === null || _a === void 0 ? void 0 : _a.call(defaultValueType, value);
|
|
2122
2128
|
}
|
|
2123
2129
|
|
|
2130
|
+
var instantAnimationState = {
|
|
2131
|
+
current: false,
|
|
2132
|
+
};
|
|
2133
|
+
|
|
2134
|
+
var isCustomValue = function (v) {
|
|
2135
|
+
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
2136
|
+
};
|
|
2137
|
+
var resolveFinalValueInKeyframes = function (v) {
|
|
2138
|
+
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
2139
|
+
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
2140
|
+
};
|
|
2141
|
+
|
|
2124
2142
|
/**
|
|
2125
2143
|
* Decide whether a transition is defined on a given Transition.
|
|
2126
2144
|
* This filters out orchestration options and returns true
|
|
@@ -2262,9 +2280,10 @@
|
|
|
2262
2280
|
}
|
|
2263
2281
|
function set() {
|
|
2264
2282
|
var _a, _b;
|
|
2265
|
-
|
|
2283
|
+
var finalTarget = resolveFinalValueInKeyframes(target);
|
|
2284
|
+
value.set(finalTarget);
|
|
2266
2285
|
onComplete();
|
|
2267
|
-
(_a = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition,
|
|
2286
|
+
(_a = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, finalTarget);
|
|
2268
2287
|
(_b = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onComplete) === null || _b === void 0 ? void 0 : _b.call(valueTransition);
|
|
2269
2288
|
return { stop: function () { } };
|
|
2270
2289
|
}
|
|
@@ -2296,6 +2315,9 @@
|
|
|
2296
2315
|
*/
|
|
2297
2316
|
function startAnimation(key, value, target, transition) {
|
|
2298
2317
|
if (transition === void 0) { transition = {}; }
|
|
2318
|
+
if (instantAnimationState.current) {
|
|
2319
|
+
transition = { type: false };
|
|
2320
|
+
}
|
|
2299
2321
|
return value.start(function (onComplete) {
|
|
2300
2322
|
var delayTimer;
|
|
2301
2323
|
var controls;
|
|
@@ -2910,14 +2932,6 @@
|
|
|
2910
2932
|
return FlatTree;
|
|
2911
2933
|
}());
|
|
2912
2934
|
|
|
2913
|
-
var isCustomValue = function (v) {
|
|
2914
|
-
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
2915
|
-
};
|
|
2916
|
-
var resolveFinalValueInKeyframes = function (v) {
|
|
2917
|
-
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
2918
|
-
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
2919
|
-
};
|
|
2920
|
-
|
|
2921
2935
|
/**
|
|
2922
2936
|
* If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
|
|
2923
2937
|
*
|
|
@@ -3219,7 +3233,7 @@
|
|
|
3219
3233
|
node.updateScroll();
|
|
3220
3234
|
}
|
|
3221
3235
|
var _d = this.options, layoutId = _d.layoutId, layout = _d.layout;
|
|
3222
|
-
if (
|
|
3236
|
+
if (layoutId === undefined && !layout)
|
|
3223
3237
|
return;
|
|
3224
3238
|
var transformTemplate = (_c = this.options.visualElement) === null || _c === void 0 ? void 0 : _c.getProps().transformTemplate;
|
|
3225
3239
|
this.prevTransformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
|
|
@@ -4562,6 +4576,7 @@
|
|
|
4562
4576
|
"inherit",
|
|
4563
4577
|
"layout",
|
|
4564
4578
|
"layoutId",
|
|
4579
|
+
"layoutDependency",
|
|
4565
4580
|
"onLayoutAnimationComplete",
|
|
4566
4581
|
"onLayoutMeasure",
|
|
4567
4582
|
"onBeforeLayoutMeasure",
|
|
@@ -4599,6 +4614,10 @@
|
|
|
4599
4614
|
"whileFocus",
|
|
4600
4615
|
"whileTap",
|
|
4601
4616
|
"whileHover",
|
|
4617
|
+
"whileInView",
|
|
4618
|
+
"onViewportEnter",
|
|
4619
|
+
"onViewportLeave",
|
|
4620
|
+
"viewport",
|
|
4602
4621
|
"layoutScroll",
|
|
4603
4622
|
]);
|
|
4604
4623
|
/**
|
|
@@ -4859,13 +4878,17 @@
|
|
|
4859
4878
|
}
|
|
4860
4879
|
return state;
|
|
4861
4880
|
}
|
|
4862
|
-
var makeUseVisualState = function (config) {
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4881
|
+
var makeUseVisualState = function (config) {
|
|
4882
|
+
return function (props, isStatic) {
|
|
4883
|
+
var context = React.useContext(MotionContext);
|
|
4884
|
+
var presenceContext = React.useContext(PresenceContext);
|
|
4885
|
+
return isStatic
|
|
4886
|
+
? makeState(config, props, context, presenceContext)
|
|
4887
|
+
: useConstant(function () {
|
|
4888
|
+
return makeState(config, props, context, presenceContext);
|
|
4889
|
+
});
|
|
4890
|
+
};
|
|
4891
|
+
};
|
|
4869
4892
|
function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
|
|
4870
4893
|
var values = {};
|
|
4871
4894
|
var blockInitialAnimation = (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false;
|
|
@@ -4883,7 +4906,8 @@
|
|
|
4883
4906
|
initial !== null && initial !== void 0 ? initial : (initial = context.initial);
|
|
4884
4907
|
animate !== null && animate !== void 0 ? animate : (animate = context.animate);
|
|
4885
4908
|
}
|
|
4886
|
-
var
|
|
4909
|
+
var initialAnimationIsBlocked = blockInitialAnimation || initial === false;
|
|
4910
|
+
var variantToSet = initialAnimationIsBlocked ? animate : initial;
|
|
4887
4911
|
if (variantToSet &&
|
|
4888
4912
|
typeof variantToSet !== "boolean" &&
|
|
4889
4913
|
!isAnimationControls(variantToSet)) {
|
|
@@ -4893,8 +4917,22 @@
|
|
|
4893
4917
|
if (!resolved)
|
|
4894
4918
|
return;
|
|
4895
4919
|
var transitionEnd = resolved.transitionEnd; resolved.transition; var target = __rest(resolved, ["transitionEnd", "transition"]);
|
|
4896
|
-
for (var key in target)
|
|
4897
|
-
|
|
4920
|
+
for (var key in target) {
|
|
4921
|
+
var valueTarget = target[key];
|
|
4922
|
+
if (Array.isArray(valueTarget)) {
|
|
4923
|
+
/**
|
|
4924
|
+
* Take final keyframe if the initial animation is blocked because
|
|
4925
|
+
* we want to initialise at the end of that blocked animation.
|
|
4926
|
+
*/
|
|
4927
|
+
var index = initialAnimationIsBlocked
|
|
4928
|
+
? valueTarget.length - 1
|
|
4929
|
+
: 0;
|
|
4930
|
+
valueTarget = valueTarget[index];
|
|
4931
|
+
}
|
|
4932
|
+
if (valueTarget !== null) {
|
|
4933
|
+
values[key] = valueTarget;
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4898
4936
|
for (var key in transitionEnd)
|
|
4899
4937
|
values[key] = transitionEnd[key];
|
|
4900
4938
|
});
|
|
@@ -4953,6 +4991,7 @@
|
|
|
4953
4991
|
AnimationType["Tap"] = "whileTap";
|
|
4954
4992
|
AnimationType["Drag"] = "whileDrag";
|
|
4955
4993
|
AnimationType["Focus"] = "whileFocus";
|
|
4994
|
+
AnimationType["InView"] = "whileInView";
|
|
4956
4995
|
AnimationType["Exit"] = "exit";
|
|
4957
4996
|
})(AnimationType || (AnimationType = {}));
|
|
4958
4997
|
|
|
@@ -5174,8 +5213,11 @@
|
|
|
5174
5213
|
var _a;
|
|
5175
5214
|
if (!isMouseEvent(event) || isDragActive())
|
|
5176
5215
|
return;
|
|
5177
|
-
|
|
5216
|
+
/**
|
|
5217
|
+
* Ensure we trigger animations before firing event callback
|
|
5218
|
+
*/
|
|
5178
5219
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Hover, isActive);
|
|
5220
|
+
callback === null || callback === void 0 ? void 0 : callback(event, info);
|
|
5179
5221
|
};
|
|
5180
5222
|
}
|
|
5181
5223
|
function useHoverGesture(_a) {
|
|
@@ -5255,19 +5297,173 @@
|
|
|
5255
5297
|
return;
|
|
5256
5298
|
isPressing.current = true;
|
|
5257
5299
|
cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp), addPointerEvent(window, "pointercancel", onPointerCancel));
|
|
5258
|
-
|
|
5300
|
+
/**
|
|
5301
|
+
* Ensure we trigger animations before firing event callback
|
|
5302
|
+
*/
|
|
5259
5303
|
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Tap, true);
|
|
5304
|
+
onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
|
|
5260
5305
|
}
|
|
5261
5306
|
usePointerEvent(visualElement, "pointerdown", hasPressListeners ? onPointerDown : undefined);
|
|
5262
5307
|
useUnmountEffect(removePointerEndListener);
|
|
5263
5308
|
}
|
|
5264
5309
|
|
|
5310
|
+
var warned = new Set();
|
|
5311
|
+
function warnOnce(condition, message, element) {
|
|
5312
|
+
if (condition || warned.has(message))
|
|
5313
|
+
return;
|
|
5314
|
+
console.warn(message);
|
|
5315
|
+
if (element)
|
|
5316
|
+
console.warn(element);
|
|
5317
|
+
warned.add(message);
|
|
5318
|
+
}
|
|
5319
|
+
|
|
5320
|
+
/**
|
|
5321
|
+
* Map an IntersectionHandler callback to an element. We only ever make one handler for one
|
|
5322
|
+
* element, so even though these handlers might all be triggered by different
|
|
5323
|
+
* observers, we can keep them in the same map.
|
|
5324
|
+
*/
|
|
5325
|
+
var observerCallbacks = new WeakMap();
|
|
5326
|
+
/**
|
|
5327
|
+
* Multiple observers can be created for multiple element/document roots. Each with
|
|
5328
|
+
* different settings. So here we store dictionaries of observers to each root,
|
|
5329
|
+
* using serialised settings (threshold/margin) as lookup keys.
|
|
5330
|
+
*/
|
|
5331
|
+
var observers = new WeakMap();
|
|
5332
|
+
var fireObserverCallback = function (entry) {
|
|
5333
|
+
var _a;
|
|
5334
|
+
(_a = observerCallbacks.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);
|
|
5335
|
+
};
|
|
5336
|
+
var fireAllObserverCallbacks = function (entries) {
|
|
5337
|
+
entries.forEach(fireObserverCallback);
|
|
5338
|
+
};
|
|
5339
|
+
function initIntersectionObserver(_a) {
|
|
5340
|
+
var root = _a.root, options = __rest(_a, ["root"]);
|
|
5341
|
+
var lookupRoot = root || document;
|
|
5342
|
+
/**
|
|
5343
|
+
* If we don't have an observer lookup map for this root, create one.
|
|
5344
|
+
*/
|
|
5345
|
+
if (!observers.has(lookupRoot)) {
|
|
5346
|
+
observers.set(lookupRoot, {});
|
|
5347
|
+
}
|
|
5348
|
+
var rootObservers = observers.get(lookupRoot);
|
|
5349
|
+
var key = JSON.stringify(options);
|
|
5350
|
+
/**
|
|
5351
|
+
* If we don't have an observer for this combination of root and settings,
|
|
5352
|
+
* create one.
|
|
5353
|
+
*/
|
|
5354
|
+
if (!rootObservers[key]) {
|
|
5355
|
+
rootObservers[key] = new IntersectionObserver(fireAllObserverCallbacks, __assign({ root: root }, options));
|
|
5356
|
+
}
|
|
5357
|
+
return rootObservers[key];
|
|
5358
|
+
}
|
|
5359
|
+
function observeIntersection(element, options, callback) {
|
|
5360
|
+
var rootInteresectionObserver = initIntersectionObserver(options);
|
|
5361
|
+
observerCallbacks.set(element, callback);
|
|
5362
|
+
rootInteresectionObserver.observe(element);
|
|
5363
|
+
return function () {
|
|
5364
|
+
observerCallbacks.delete(element);
|
|
5365
|
+
rootInteresectionObserver.unobserve(element);
|
|
5366
|
+
};
|
|
5367
|
+
}
|
|
5368
|
+
|
|
5369
|
+
function useViewport(_a) {
|
|
5370
|
+
var visualElement = _a.visualElement, whileInView = _a.whileInView, onViewportEnter = _a.onViewportEnter, onViewportLeave = _a.onViewportLeave, _b = _a.viewport, viewport = _b === void 0 ? {} : _b;
|
|
5371
|
+
var state = React.useRef({
|
|
5372
|
+
hasEnteredView: false,
|
|
5373
|
+
isInView: false,
|
|
5374
|
+
});
|
|
5375
|
+
var shouldObserve = Boolean(whileInView || onViewportEnter || onViewportLeave);
|
|
5376
|
+
if (viewport.once && state.current.hasEnteredView)
|
|
5377
|
+
shouldObserve = false;
|
|
5378
|
+
var useObserver = typeof IntersectionObserver === "undefined"
|
|
5379
|
+
? useMissingIntersectionObserver
|
|
5380
|
+
: useIntersectionObserver;
|
|
5381
|
+
useObserver(shouldObserve, state.current, visualElement, viewport);
|
|
5382
|
+
}
|
|
5383
|
+
var thresholdNames = {
|
|
5384
|
+
some: 0,
|
|
5385
|
+
all: 1,
|
|
5386
|
+
};
|
|
5387
|
+
function useIntersectionObserver(shouldObserve, state, visualElement, _a) {
|
|
5388
|
+
var root = _a.root, rootMargin = _a.margin, _b = _a.amount, amount = _b === void 0 ? "some" : _b, once = _a.once;
|
|
5389
|
+
React.useEffect(function () {
|
|
5390
|
+
if (!shouldObserve)
|
|
5391
|
+
return;
|
|
5392
|
+
var options = {
|
|
5393
|
+
root: root === null || root === void 0 ? void 0 : root.current,
|
|
5394
|
+
rootMargin: rootMargin,
|
|
5395
|
+
threshold: typeof amount === "number" ? amount : thresholdNames[amount],
|
|
5396
|
+
};
|
|
5397
|
+
var intersectionCallback = function (entry) {
|
|
5398
|
+
var _a;
|
|
5399
|
+
var isIntersecting = entry.isIntersecting;
|
|
5400
|
+
/**
|
|
5401
|
+
* If there's been no change in the viewport state, early return.
|
|
5402
|
+
*/
|
|
5403
|
+
if (state.isInView === isIntersecting)
|
|
5404
|
+
return;
|
|
5405
|
+
state.isInView = isIntersecting;
|
|
5406
|
+
/**
|
|
5407
|
+
* Handle hasEnteredView. If this is only meant to run once, and
|
|
5408
|
+
* element isn't visible, early return. Otherwise set hasEnteredView to true.
|
|
5409
|
+
*/
|
|
5410
|
+
if (once && !isIntersecting && state.hasEnteredView) {
|
|
5411
|
+
return;
|
|
5412
|
+
}
|
|
5413
|
+
else if (isIntersecting) {
|
|
5414
|
+
state.hasEnteredView = true;
|
|
5415
|
+
}
|
|
5416
|
+
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, isIntersecting);
|
|
5417
|
+
/**
|
|
5418
|
+
* Use the latest committed props rather than the ones in scope
|
|
5419
|
+
* when this observer is created
|
|
5420
|
+
*/
|
|
5421
|
+
var props = visualElement.getProps();
|
|
5422
|
+
var callback = isIntersecting
|
|
5423
|
+
? props.onViewportEnter
|
|
5424
|
+
: props.onViewportLeave;
|
|
5425
|
+
callback === null || callback === void 0 ? void 0 : callback();
|
|
5426
|
+
};
|
|
5427
|
+
return observeIntersection(visualElement.getInstance(), options, intersectionCallback);
|
|
5428
|
+
}, [shouldObserve, root, rootMargin, amount]);
|
|
5429
|
+
}
|
|
5430
|
+
/**
|
|
5431
|
+
* If IntersectionObserver is missing, we activate inView and fire onViewportEnter
|
|
5432
|
+
* on mount. This way, the page will be in the state the author expects users
|
|
5433
|
+
* to see it in for everyone.
|
|
5434
|
+
*/
|
|
5435
|
+
function useMissingIntersectionObserver(shouldObserve, state, visualElement) {
|
|
5436
|
+
React.useEffect(function () {
|
|
5437
|
+
if (!shouldObserve)
|
|
5438
|
+
return;
|
|
5439
|
+
{
|
|
5440
|
+
warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
|
|
5441
|
+
}
|
|
5442
|
+
/**
|
|
5443
|
+
* Fire this in an rAF because, at this point, the animation state
|
|
5444
|
+
* won't have flushed for the first time and there's certain logic in
|
|
5445
|
+
* there that behaves differently on the initial animation.
|
|
5446
|
+
*
|
|
5447
|
+
* This hook should be quite rarely called so setting this in an rAF
|
|
5448
|
+
* is preferred to changing the behaviour of the animation state.
|
|
5449
|
+
*/
|
|
5450
|
+
requestAnimationFrame(function () {
|
|
5451
|
+
var _a;
|
|
5452
|
+
state.hasEnteredView = true;
|
|
5453
|
+
var onViewportEnter = visualElement.getProps().onViewportEnter;
|
|
5454
|
+
onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter();
|
|
5455
|
+
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, true);
|
|
5456
|
+
});
|
|
5457
|
+
}, [shouldObserve]);
|
|
5458
|
+
}
|
|
5459
|
+
|
|
5265
5460
|
var makeRenderlessComponent = function (hook) { return function (props) {
|
|
5266
5461
|
hook(props);
|
|
5267
5462
|
return null;
|
|
5268
5463
|
}; };
|
|
5269
5464
|
|
|
5270
5465
|
var gestureAnimations = {
|
|
5466
|
+
inView: makeRenderlessComponent(useViewport),
|
|
5271
5467
|
tap: makeRenderlessComponent(useTapGesture),
|
|
5272
5468
|
focus: makeRenderlessComponent(useFocusGesture),
|
|
5273
5469
|
hover: makeRenderlessComponent(useHoverGesture),
|
|
@@ -5409,9 +5605,7 @@
|
|
|
5409
5605
|
}
|
|
5410
5606
|
function setTarget(visualElement, definition) {
|
|
5411
5607
|
var resolved = resolveVariant(visualElement, definition);
|
|
5412
|
-
var _a = resolved
|
|
5413
|
-
? visualElement.makeTargetAnimatable(resolved, false)
|
|
5414
|
-
: {}, _b = _a.transitionEnd, transitionEnd = _b === void 0 ? {} : _b; _a.transition; var target = __rest(_a, ["transitionEnd", "transition"]);
|
|
5608
|
+
var _a = resolved ? visualElement.makeTargetAnimatable(resolved, false) : {}, _b = _a.transitionEnd, transitionEnd = _b === void 0 ? {} : _b; _a.transition; var target = __rest(_a, ["transitionEnd", "transition"]);
|
|
5415
5609
|
target = __assign(__assign({}, target), transitionEnd);
|
|
5416
5610
|
for (var key in target) {
|
|
5417
5611
|
var value = resolveFinalValueInKeyframes(target[key]);
|
|
@@ -5638,6 +5832,7 @@
|
|
|
5638
5832
|
|
|
5639
5833
|
var variantPriorityOrder = [
|
|
5640
5834
|
AnimationType.Animate,
|
|
5835
|
+
AnimationType.InView,
|
|
5641
5836
|
AnimationType.Focus,
|
|
5642
5837
|
AnimationType.Hover,
|
|
5643
5838
|
AnimationType.Tap,
|
|
@@ -5764,7 +5959,8 @@
|
|
|
5764
5959
|
* a changed value or a value that was removed in a higher priority, we set
|
|
5765
5960
|
* this to true and add this prop to the animation list.
|
|
5766
5961
|
*/
|
|
5767
|
-
var
|
|
5962
|
+
var variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
|
|
5963
|
+
var shouldAnimateType = variantDidChange ||
|
|
5768
5964
|
// If we're making this variant active, we want to always make it active
|
|
5769
5965
|
(type === changedActiveType &&
|
|
5770
5966
|
typeState.isActive &&
|
|
@@ -5815,7 +6011,7 @@
|
|
|
5815
6011
|
* detect whether any value has changed. If it has, we animate it.
|
|
5816
6012
|
*/
|
|
5817
6013
|
if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {
|
|
5818
|
-
if (!shallowCompare(next, prev)) {
|
|
6014
|
+
if (!shallowCompare(next, prev) || variantDidChange) {
|
|
5819
6015
|
markToAnimate(key);
|
|
5820
6016
|
}
|
|
5821
6017
|
else {
|
|
@@ -5932,7 +6128,7 @@
|
|
|
5932
6128
|
getState: function () { return state; },
|
|
5933
6129
|
};
|
|
5934
6130
|
}
|
|
5935
|
-
function
|
|
6131
|
+
function checkVariantsDidChange(prev, next) {
|
|
5936
6132
|
if (typeof next === "string") {
|
|
5937
6133
|
return next !== prev;
|
|
5938
6134
|
}
|
|
@@ -5954,6 +6150,7 @@
|
|
|
5954
6150
|
var _a;
|
|
5955
6151
|
return _a = {},
|
|
5956
6152
|
_a[AnimationType.Animate] = createTypeState(true),
|
|
6153
|
+
_a[AnimationType.InView] = createTypeState(),
|
|
5957
6154
|
_a[AnimationType.Hover] = createTypeState(),
|
|
5958
6155
|
_a[AnimationType.Tap] = createTypeState(),
|
|
5959
6156
|
_a[AnimationType.Drag] = createTypeState(),
|
|
@@ -7463,11 +7660,18 @@
|
|
|
7463
7660
|
var element = visualElement.getInstance();
|
|
7464
7661
|
var elementComputedStyle = getComputedStyle(element);
|
|
7465
7662
|
var display = elementComputedStyle.display;
|
|
7663
|
+
var origin = {};
|
|
7466
7664
|
// If the element is currently set to display: "none", make it visible before
|
|
7467
7665
|
// measuring the target bounding box
|
|
7468
7666
|
if (display === "none") {
|
|
7469
7667
|
visualElement.setStaticValue("display", target.display || "block");
|
|
7470
7668
|
}
|
|
7669
|
+
/**
|
|
7670
|
+
* Record origins before we render and update styles
|
|
7671
|
+
*/
|
|
7672
|
+
changedKeys.forEach(function (key) {
|
|
7673
|
+
origin[key] = positionalValues[key](originBbox, elementComputedStyle);
|
|
7674
|
+
});
|
|
7471
7675
|
// Apply the latest values (as set in checkAndConvertChangedValueTypes)
|
|
7472
7676
|
visualElement.syncRender();
|
|
7473
7677
|
var targetBbox = visualElement.measureViewportBox();
|
|
@@ -7475,7 +7679,7 @@
|
|
|
7475
7679
|
// Restore styles to their **calculated computed style**, not their actual
|
|
7476
7680
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
7477
7681
|
var value = visualElement.getValue(key);
|
|
7478
|
-
setAndResetVelocity(value,
|
|
7682
|
+
setAndResetVelocity(value, origin[key]);
|
|
7479
7683
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
7480
7684
|
});
|
|
7481
7685
|
return target;
|
|
@@ -8577,7 +8781,7 @@
|
|
|
8577
8781
|
return isMotionValue(value) ? value : useMotionValue(defaultValue);
|
|
8578
8782
|
}
|
|
8579
8783
|
function ReorderItem(_a, externalRef) {
|
|
8580
|
-
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"]);
|
|
8784
|
+
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"]);
|
|
8581
8785
|
var Component = useConstant(function () { return motion(as); });
|
|
8582
8786
|
var context = React.useContext(ReorderContext);
|
|
8583
8787
|
var point = {
|
|
@@ -8594,10 +8798,11 @@
|
|
|
8594
8798
|
React.useEffect(function () {
|
|
8595
8799
|
registerItem(value, layout.current);
|
|
8596
8800
|
}, [context]);
|
|
8597
|
-
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 (
|
|
8598
|
-
var velocity =
|
|
8801
|
+
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) {
|
|
8802
|
+
var velocity = gesturePoint.velocity;
|
|
8599
8803
|
velocity[axis] &&
|
|
8600
8804
|
updateOrder(value, point[axis].get(), velocity[axis]);
|
|
8805
|
+
onDrag === null || onDrag === void 0 ? void 0 : onDrag(event, gesturePoint);
|
|
8601
8806
|
}, onLayoutMeasure: function (measured) {
|
|
8602
8807
|
layout.current = measured;
|
|
8603
8808
|
}, ref: externalRef }), children));
|
|
@@ -9159,6 +9364,26 @@
|
|
|
9159
9364
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
9160
9365
|
}
|
|
9161
9366
|
|
|
9367
|
+
function useInstantTransition() {
|
|
9368
|
+
var _a = __read(useForceUpdate(), 2), forceUpdate = _a[0], forcedRenderCount = _a[1];
|
|
9369
|
+
var startInstantLayoutTransition = useInstantLayoutTransition();
|
|
9370
|
+
React.useEffect(function () {
|
|
9371
|
+
/**
|
|
9372
|
+
* Unblock after two animation frames, otherwise this will unblock too soon.
|
|
9373
|
+
*/
|
|
9374
|
+
sync.postRender(function () {
|
|
9375
|
+
return sync.postRender(function () { return (instantAnimationState.current = false); });
|
|
9376
|
+
});
|
|
9377
|
+
}, [forcedRenderCount]);
|
|
9378
|
+
return function (callback) {
|
|
9379
|
+
startInstantLayoutTransition(function () {
|
|
9380
|
+
instantAnimationState.current = true;
|
|
9381
|
+
forceUpdate();
|
|
9382
|
+
callback();
|
|
9383
|
+
});
|
|
9384
|
+
};
|
|
9385
|
+
}
|
|
9386
|
+
|
|
9162
9387
|
function useResetProjection() {
|
|
9163
9388
|
var reset = React__namespace.useCallback(function () {
|
|
9164
9389
|
var root = rootProjectionNode.current;
|
|
@@ -9302,6 +9527,7 @@
|
|
|
9302
9527
|
exports.useDragControls = useDragControls;
|
|
9303
9528
|
exports.useElementScroll = useElementScroll;
|
|
9304
9529
|
exports.useInstantLayoutTransition = useInstantLayoutTransition;
|
|
9530
|
+
exports.useInstantTransition = useInstantTransition;
|
|
9305
9531
|
exports.useIsPresent = useIsPresent;
|
|
9306
9532
|
exports.useMotionTemplate = useMotionTemplate;
|
|
9307
9533
|
exports.useMotionValue = useMotionValue;
|