framer-motion 12.23.10 → 12.23.12
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/README.md +79 -65
- 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 +63 -33
- 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 +3 -3
|
@@ -4742,7 +4742,7 @@
|
|
|
4742
4742
|
},
|
|
4743
4743
|
};
|
|
4744
4744
|
|
|
4745
|
-
function
|
|
4745
|
+
function getViewAnimationLayerInfo(pseudoElement) {
|
|
4746
4746
|
const match = pseudoElement.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);
|
|
4747
4747
|
if (!match)
|
|
4748
4748
|
return null;
|
|
@@ -4861,7 +4861,7 @@
|
|
|
4861
4861
|
const { pseudoElement } = effect;
|
|
4862
4862
|
if (!pseudoElement)
|
|
4863
4863
|
continue;
|
|
4864
|
-
const name =
|
|
4864
|
+
const name = getViewAnimationLayerInfo(pseudoElement);
|
|
4865
4865
|
if (!name)
|
|
4866
4866
|
continue;
|
|
4867
4867
|
const targetDefinition = targets.get(name.layer);
|
|
@@ -8286,8 +8286,7 @@
|
|
|
8286
8286
|
{
|
|
8287
8287
|
warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
|
|
8288
8288
|
}
|
|
8289
|
-
|
|
8290
|
-
this.parent.children.add(this);
|
|
8289
|
+
this.parent?.addChild(this);
|
|
8291
8290
|
this.update(this.props, this.presenceContext);
|
|
8292
8291
|
}
|
|
8293
8292
|
unmount() {
|
|
@@ -8297,7 +8296,7 @@
|
|
|
8297
8296
|
this.valueSubscriptions.forEach((remove) => remove());
|
|
8298
8297
|
this.valueSubscriptions.clear();
|
|
8299
8298
|
this.removeFromVariantTree && this.removeFromVariantTree();
|
|
8300
|
-
this.parent
|
|
8299
|
+
this.parent?.removeChild(this);
|
|
8301
8300
|
for (const key in this.events) {
|
|
8302
8301
|
this.events[key].clear();
|
|
8303
8302
|
}
|
|
@@ -8310,6 +8309,15 @@
|
|
|
8310
8309
|
}
|
|
8311
8310
|
this.current = null;
|
|
8312
8311
|
}
|
|
8312
|
+
addChild(child) {
|
|
8313
|
+
this.children.add(child);
|
|
8314
|
+
this.enteringChildren ?? (this.enteringChildren = new Set());
|
|
8315
|
+
this.enteringChildren.add(child);
|
|
8316
|
+
}
|
|
8317
|
+
removeChild(child) {
|
|
8318
|
+
this.children.delete(child);
|
|
8319
|
+
this.enteringChildren && this.enteringChildren.delete(child);
|
|
8320
|
+
}
|
|
8313
8321
|
bindToMotionValue(key, value) {
|
|
8314
8322
|
if (this.valueSubscriptions.has(key)) {
|
|
8315
8323
|
this.valueSubscriptions.get(key)();
|
|
@@ -9660,6 +9668,11 @@
|
|
|
9660
9668
|
});
|
|
9661
9669
|
wantsHandoff.current = false;
|
|
9662
9670
|
}
|
|
9671
|
+
/**
|
|
9672
|
+
* Now we've finished triggering animations for this element we
|
|
9673
|
+
* can wipe the enteringChildren set for the next render.
|
|
9674
|
+
*/
|
|
9675
|
+
visualElement.enteringChildren = undefined;
|
|
9663
9676
|
});
|
|
9664
9677
|
return visualElement;
|
|
9665
9678
|
}
|
|
@@ -9953,6 +9966,20 @@
|
|
|
9953
9966
|
return animations;
|
|
9954
9967
|
}
|
|
9955
9968
|
|
|
9969
|
+
function calcChildStagger(children, child, delayChildren, staggerChildren = 0, staggerDirection = 1) {
|
|
9970
|
+
const index = Array.from(children)
|
|
9971
|
+
.sort((a, b) => a.sortNodePosition(b))
|
|
9972
|
+
.indexOf(child);
|
|
9973
|
+
const numChildren = children.size;
|
|
9974
|
+
const maxStaggerDuration = (numChildren - 1) * staggerChildren;
|
|
9975
|
+
const delayIsFunction = typeof delayChildren === "function";
|
|
9976
|
+
return delayIsFunction
|
|
9977
|
+
? delayChildren(index, numChildren)
|
|
9978
|
+
: staggerDirection === 1
|
|
9979
|
+
? index * staggerChildren
|
|
9980
|
+
: maxStaggerDuration - index * staggerChildren;
|
|
9981
|
+
}
|
|
9982
|
+
|
|
9956
9983
|
function animateVariant(visualElement, variant, options = {}) {
|
|
9957
9984
|
const resolved = resolveVariant(visualElement, variant, options.type === "exit"
|
|
9958
9985
|
? visualElement.presenceContext?.custom
|
|
@@ -9995,31 +10022,17 @@
|
|
|
9995
10022
|
}
|
|
9996
10023
|
function animateChildren(visualElement, variant, delay = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
|
|
9997
10024
|
const animations = [];
|
|
9998
|
-
const
|
|
9999
|
-
const maxStaggerDuration = (numChildren - 1) * staggerChildren;
|
|
10000
|
-
const delayIsFunction = typeof delayChildren === "function";
|
|
10001
|
-
const generateStaggerDuration = delayIsFunction
|
|
10002
|
-
? (i) => delayChildren(i, numChildren)
|
|
10003
|
-
: // Support deprecated staggerChildren
|
|
10004
|
-
staggerDirection === 1
|
|
10005
|
-
? (i = 0) => i * staggerChildren
|
|
10006
|
-
: (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
10007
|
-
Array.from(visualElement.variantChildren)
|
|
10008
|
-
.sort(sortByTreeOrder)
|
|
10009
|
-
.forEach((child, i) => {
|
|
10025
|
+
for (const child of visualElement.variantChildren) {
|
|
10010
10026
|
child.notify("AnimationStart", variant);
|
|
10011
10027
|
animations.push(animateVariant(child, variant, {
|
|
10012
10028
|
...options,
|
|
10013
10029
|
delay: delay +
|
|
10014
|
-
(
|
|
10015
|
-
|
|
10030
|
+
(typeof delayChildren === "function" ? 0 : delayChildren) +
|
|
10031
|
+
calcChildStagger(visualElement.variantChildren, child, delayChildren, staggerChildren, staggerDirection),
|
|
10016
10032
|
}).then(() => child.notify("AnimationComplete", variant)));
|
|
10017
|
-
}
|
|
10033
|
+
}
|
|
10018
10034
|
return Promise.all(animations);
|
|
10019
10035
|
}
|
|
10020
|
-
function sortByTreeOrder(a, b) {
|
|
10021
|
-
return a.sortNodePosition(b);
|
|
10022
|
-
}
|
|
10023
10036
|
|
|
10024
10037
|
function animateVisualElement(visualElement, definition, options = {}) {
|
|
10025
10038
|
visualElement.notify("AnimationStart", definition);
|
|
@@ -10172,9 +10185,6 @@
|
|
|
10172
10185
|
let isInherited = prop === context[type] &&
|
|
10173
10186
|
prop !== props[type] &&
|
|
10174
10187
|
propIsVariant;
|
|
10175
|
-
/**
|
|
10176
|
-
*
|
|
10177
|
-
*/
|
|
10178
10188
|
if (isInherited &&
|
|
10179
10189
|
isInitialRender &&
|
|
10180
10190
|
visualElement.manuallyAnimateOnMount) {
|
|
@@ -10295,9 +10305,6 @@
|
|
|
10295
10305
|
*/
|
|
10296
10306
|
typeState.prevProp = prop;
|
|
10297
10307
|
typeState.prevResolvedValues = resolvedValues;
|
|
10298
|
-
/**
|
|
10299
|
-
*
|
|
10300
|
-
*/
|
|
10301
10308
|
if (typeState.isActive) {
|
|
10302
10309
|
encounteredKeys = { ...encounteredKeys, ...resolvedValues };
|
|
10303
10310
|
}
|
|
@@ -10311,10 +10318,30 @@
|
|
|
10311
10318
|
const willAnimateViaParent = isInherited && variantDidChange;
|
|
10312
10319
|
const needsAnimating = !willAnimateViaParent || handledRemovedValues;
|
|
10313
10320
|
if (shouldAnimateType && needsAnimating) {
|
|
10314
|
-
animations.push(...definitionList.map((animation) =>
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10321
|
+
animations.push(...definitionList.map((animation) => {
|
|
10322
|
+
const options = { type };
|
|
10323
|
+
/**
|
|
10324
|
+
* If we're performing the initial animation, but we're not
|
|
10325
|
+
* rendering at the same time as the variant-controlling parent,
|
|
10326
|
+
* we want to use the parent's transition to calculate the stagger.
|
|
10327
|
+
*/
|
|
10328
|
+
if (typeof animation === "string" &&
|
|
10329
|
+
isInitialRender &&
|
|
10330
|
+
!willAnimateViaParent &&
|
|
10331
|
+
visualElement.manuallyAnimateOnMount &&
|
|
10332
|
+
visualElement.parent) {
|
|
10333
|
+
const { parent } = visualElement;
|
|
10334
|
+
const parentVariant = resolveVariant(parent, animation);
|
|
10335
|
+
if (parent.enteringChildren && parentVariant) {
|
|
10336
|
+
const { delayChildren } = parentVariant.transition || {};
|
|
10337
|
+
options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
|
|
10338
|
+
}
|
|
10339
|
+
}
|
|
10340
|
+
return {
|
|
10341
|
+
animation: animation,
|
|
10342
|
+
options,
|
|
10343
|
+
};
|
|
10344
|
+
}));
|
|
10318
10345
|
}
|
|
10319
10346
|
}
|
|
10320
10347
|
/**
|
|
@@ -14076,6 +14103,7 @@
|
|
|
14076
14103
|
exports.animationMapKey = animationMapKey;
|
|
14077
14104
|
exports.animations = animations;
|
|
14078
14105
|
exports.anticipate = anticipate;
|
|
14106
|
+
exports.applyGeneratorOptions = applyGeneratorOptions;
|
|
14079
14107
|
exports.applyPxDefaults = applyPxDefaults;
|
|
14080
14108
|
exports.attachSpring = attachSpring;
|
|
14081
14109
|
exports.attrEffect = attrEffect;
|
|
@@ -14139,6 +14167,8 @@
|
|
|
14139
14167
|
exports.getValueAsType = getValueAsType;
|
|
14140
14168
|
exports.getValueTransition = getValueTransition$1;
|
|
14141
14169
|
exports.getVariableValue = getVariableValue;
|
|
14170
|
+
exports.getViewAnimationLayerInfo = getViewAnimationLayerInfo;
|
|
14171
|
+
exports.getViewAnimations = getViewAnimations;
|
|
14142
14172
|
exports.hasWarned = hasWarned$1;
|
|
14143
14173
|
exports.hex = hex;
|
|
14144
14174
|
exports.hover = hover;
|