framer-motion 12.23.10 → 12.23.11
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/cjs/client.js +1 -1
- package/dist/cjs/dom.js +11 -3
- package/dist/cjs/{feature-bundle-CQ-jKhGL.js → feature-bundle-PNQ-8QDo.js} +58 -31
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/m.js +5 -0
- package/dist/dom.js +1 -1
- package/dist/es/animation/interfaces/visual-element-variant.mjs +6 -19
- package/dist/es/animation/utils/calc-child-stagger.mjs +15 -0
- package/dist/es/motion/utils/use-visual-element.mjs +5 -0
- package/dist/es/render/VisualElement.mjs +11 -3
- package/dist/es/render/utils/animation-state.mjs +25 -10
- package/dist/framer-motion.dev.js +58 -31
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation-m.js +1 -1
- 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/dist/size-rollup-motion.js +1 -1
- package/dist/types/client.d.ts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{types.d-Bq-Qm38R.d.ts → types.d-Cjd591yU.d.ts} +8 -0
- package/package.json +2 -2
package/dist/cjs/client.js
CHANGED
package/dist/cjs/dom.js
CHANGED
|
@@ -986,8 +986,7 @@ class VisualElement {
|
|
|
986
986
|
if (process.env.NODE_ENV !== "production") {
|
|
987
987
|
motionUtils.warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
|
|
988
988
|
}
|
|
989
|
-
|
|
990
|
-
this.parent.children.add(this);
|
|
989
|
+
this.parent?.addChild(this);
|
|
991
990
|
this.update(this.props, this.presenceContext);
|
|
992
991
|
}
|
|
993
992
|
unmount() {
|
|
@@ -997,7 +996,7 @@ class VisualElement {
|
|
|
997
996
|
this.valueSubscriptions.forEach((remove) => remove());
|
|
998
997
|
this.valueSubscriptions.clear();
|
|
999
998
|
this.removeFromVariantTree && this.removeFromVariantTree();
|
|
1000
|
-
this.parent
|
|
999
|
+
this.parent?.removeChild(this);
|
|
1001
1000
|
for (const key in this.events) {
|
|
1002
1001
|
this.events[key].clear();
|
|
1003
1002
|
}
|
|
@@ -1010,6 +1009,15 @@ class VisualElement {
|
|
|
1010
1009
|
}
|
|
1011
1010
|
this.current = null;
|
|
1012
1011
|
}
|
|
1012
|
+
addChild(child) {
|
|
1013
|
+
this.children.add(child);
|
|
1014
|
+
this.enteringChildren ?? (this.enteringChildren = new Set());
|
|
1015
|
+
this.enteringChildren.add(child);
|
|
1016
|
+
}
|
|
1017
|
+
removeChild(child) {
|
|
1018
|
+
this.children.delete(child);
|
|
1019
|
+
this.enteringChildren && this.enteringChildren.delete(child);
|
|
1020
|
+
}
|
|
1013
1021
|
bindToMotionValue(key, value) {
|
|
1014
1022
|
if (this.valueSubscriptions.has(key)) {
|
|
1015
1023
|
this.valueSubscriptions.get(key)();
|
|
@@ -2960,8 +2960,7 @@ class VisualElement {
|
|
|
2960
2960
|
if (process.env.NODE_ENV !== "production") {
|
|
2961
2961
|
motionUtils.warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
|
|
2962
2962
|
}
|
|
2963
|
-
|
|
2964
|
-
this.parent.children.add(this);
|
|
2963
|
+
this.parent?.addChild(this);
|
|
2965
2964
|
this.update(this.props, this.presenceContext);
|
|
2966
2965
|
}
|
|
2967
2966
|
unmount() {
|
|
@@ -2971,7 +2970,7 @@ class VisualElement {
|
|
|
2971
2970
|
this.valueSubscriptions.forEach((remove) => remove());
|
|
2972
2971
|
this.valueSubscriptions.clear();
|
|
2973
2972
|
this.removeFromVariantTree && this.removeFromVariantTree();
|
|
2974
|
-
this.parent
|
|
2973
|
+
this.parent?.removeChild(this);
|
|
2975
2974
|
for (const key in this.events) {
|
|
2976
2975
|
this.events[key].clear();
|
|
2977
2976
|
}
|
|
@@ -2984,6 +2983,15 @@ class VisualElement {
|
|
|
2984
2983
|
}
|
|
2985
2984
|
this.current = null;
|
|
2986
2985
|
}
|
|
2986
|
+
addChild(child) {
|
|
2987
|
+
this.children.add(child);
|
|
2988
|
+
this.enteringChildren ?? (this.enteringChildren = new Set());
|
|
2989
|
+
this.enteringChildren.add(child);
|
|
2990
|
+
}
|
|
2991
|
+
removeChild(child) {
|
|
2992
|
+
this.children.delete(child);
|
|
2993
|
+
this.enteringChildren && this.enteringChildren.delete(child);
|
|
2994
|
+
}
|
|
2987
2995
|
bindToMotionValue(key, value) {
|
|
2988
2996
|
if (this.valueSubscriptions.has(key)) {
|
|
2989
2997
|
this.valueSubscriptions.get(key)();
|
|
@@ -4183,6 +4191,11 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
4183
4191
|
});
|
|
4184
4192
|
wantsHandoff.current = false;
|
|
4185
4193
|
}
|
|
4194
|
+
/**
|
|
4195
|
+
* Now we've finished triggering animations for this element we
|
|
4196
|
+
* can wipe the enteringChildren set for the next render.
|
|
4197
|
+
*/
|
|
4198
|
+
visualElement.enteringChildren = undefined;
|
|
4186
4199
|
});
|
|
4187
4200
|
return visualElement;
|
|
4188
4201
|
}
|
|
@@ -4436,6 +4449,20 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
4436
4449
|
return animations;
|
|
4437
4450
|
}
|
|
4438
4451
|
|
|
4452
|
+
function calcChildStagger(children, child, delayChildren, staggerChildren = 0, staggerDirection = 1) {
|
|
4453
|
+
const index = Array.from(children)
|
|
4454
|
+
.sort((a, b) => a.sortNodePosition(b))
|
|
4455
|
+
.indexOf(child);
|
|
4456
|
+
const numChildren = children.size;
|
|
4457
|
+
const maxStaggerDuration = (numChildren - 1) * staggerChildren;
|
|
4458
|
+
const delayIsFunction = typeof delayChildren === "function";
|
|
4459
|
+
return delayIsFunction
|
|
4460
|
+
? delayChildren(index, numChildren)
|
|
4461
|
+
: staggerDirection === 1
|
|
4462
|
+
? index * staggerChildren
|
|
4463
|
+
: maxStaggerDuration - index * staggerChildren;
|
|
4464
|
+
}
|
|
4465
|
+
|
|
4439
4466
|
function animateVariant(visualElement, variant, options = {}) {
|
|
4440
4467
|
const resolved = resolveVariant(visualElement, variant, options.type === "exit"
|
|
4441
4468
|
? visualElement.presenceContext?.custom
|
|
@@ -4478,31 +4505,17 @@ function animateVariant(visualElement, variant, options = {}) {
|
|
|
4478
4505
|
}
|
|
4479
4506
|
function animateChildren(visualElement, variant, delay = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
|
|
4480
4507
|
const animations = [];
|
|
4481
|
-
const
|
|
4482
|
-
const maxStaggerDuration = (numChildren - 1) * staggerChildren;
|
|
4483
|
-
const delayIsFunction = typeof delayChildren === "function";
|
|
4484
|
-
const generateStaggerDuration = delayIsFunction
|
|
4485
|
-
? (i) => delayChildren(i, numChildren)
|
|
4486
|
-
: // Support deprecated staggerChildren
|
|
4487
|
-
staggerDirection === 1
|
|
4488
|
-
? (i = 0) => i * staggerChildren
|
|
4489
|
-
: (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
4490
|
-
Array.from(visualElement.variantChildren)
|
|
4491
|
-
.sort(sortByTreeOrder)
|
|
4492
|
-
.forEach((child, i) => {
|
|
4508
|
+
for (const child of visualElement.variantChildren) {
|
|
4493
4509
|
child.notify("AnimationStart", variant);
|
|
4494
4510
|
animations.push(animateVariant(child, variant, {
|
|
4495
4511
|
...options,
|
|
4496
4512
|
delay: delay +
|
|
4497
|
-
(
|
|
4498
|
-
|
|
4513
|
+
(typeof delayChildren === "function" ? 0 : delayChildren) +
|
|
4514
|
+
calcChildStagger(visualElement.variantChildren, child, delayChildren, staggerChildren, staggerDirection),
|
|
4499
4515
|
}).then(() => child.notify("AnimationComplete", variant)));
|
|
4500
|
-
}
|
|
4516
|
+
}
|
|
4501
4517
|
return Promise.all(animations);
|
|
4502
4518
|
}
|
|
4503
|
-
function sortByTreeOrder(a, b) {
|
|
4504
|
-
return a.sortNodePosition(b);
|
|
4505
|
-
}
|
|
4506
4519
|
|
|
4507
4520
|
function animateVisualElement(visualElement, definition, options = {}) {
|
|
4508
4521
|
visualElement.notify("AnimationStart", definition);
|
|
@@ -4655,9 +4668,6 @@ function createAnimationState(visualElement) {
|
|
|
4655
4668
|
let isInherited = prop === context[type] &&
|
|
4656
4669
|
prop !== props[type] &&
|
|
4657
4670
|
propIsVariant;
|
|
4658
|
-
/**
|
|
4659
|
-
*
|
|
4660
|
-
*/
|
|
4661
4671
|
if (isInherited &&
|
|
4662
4672
|
isInitialRender &&
|
|
4663
4673
|
visualElement.manuallyAnimateOnMount) {
|
|
@@ -4778,9 +4788,6 @@ function createAnimationState(visualElement) {
|
|
|
4778
4788
|
*/
|
|
4779
4789
|
typeState.prevProp = prop;
|
|
4780
4790
|
typeState.prevResolvedValues = resolvedValues;
|
|
4781
|
-
/**
|
|
4782
|
-
*
|
|
4783
|
-
*/
|
|
4784
4791
|
if (typeState.isActive) {
|
|
4785
4792
|
encounteredKeys = { ...encounteredKeys, ...resolvedValues };
|
|
4786
4793
|
}
|
|
@@ -4794,10 +4801,30 @@ function createAnimationState(visualElement) {
|
|
|
4794
4801
|
const willAnimateViaParent = isInherited && variantDidChange;
|
|
4795
4802
|
const needsAnimating = !willAnimateViaParent || handledRemovedValues;
|
|
4796
4803
|
if (shouldAnimateType && needsAnimating) {
|
|
4797
|
-
animations.push(...definitionList.map((animation) =>
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4804
|
+
animations.push(...definitionList.map((animation) => {
|
|
4805
|
+
const options = { type };
|
|
4806
|
+
/**
|
|
4807
|
+
* If we're performing the initial animation, but we're not
|
|
4808
|
+
* rendering at the same time as the variant-controlling parent,
|
|
4809
|
+
* we want to use the parent's transition to calculate the stagger.
|
|
4810
|
+
*/
|
|
4811
|
+
if (typeof animation === "string" &&
|
|
4812
|
+
isInitialRender &&
|
|
4813
|
+
!willAnimateViaParent &&
|
|
4814
|
+
visualElement.manuallyAnimateOnMount &&
|
|
4815
|
+
visualElement.parent) {
|
|
4816
|
+
const { parent } = visualElement;
|
|
4817
|
+
const parentVariant = resolveVariant(parent, animation);
|
|
4818
|
+
if (parent.enteringChildren && parentVariant) {
|
|
4819
|
+
const { delayChildren } = parentVariant.transition || {};
|
|
4820
|
+
options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
return {
|
|
4824
|
+
animation: animation,
|
|
4825
|
+
options,
|
|
4826
|
+
};
|
|
4827
|
+
}));
|
|
4801
4828
|
}
|
|
4802
4829
|
}
|
|
4803
4830
|
/**
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var featureBundle = require('./feature-bundle-
|
|
7
|
+
var featureBundle = require('./feature-bundle-PNQ-8QDo.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
package/dist/cjs/m.js
CHANGED
|
@@ -909,6 +909,11 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
909
909
|
});
|
|
910
910
|
wantsHandoff.current = false;
|
|
911
911
|
}
|
|
912
|
+
/**
|
|
913
|
+
* Now we've finished triggering animations for this element we
|
|
914
|
+
* can wipe the enteringChildren set for the next render.
|
|
915
|
+
*/
|
|
916
|
+
visualElement.enteringChildren = undefined;
|
|
912
917
|
});
|
|
913
918
|
return visualElement;
|
|
914
919
|
}
|