motion-v 0.3.1-beta.1 → 0.4.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/cjs/index.js +1826 -47
- package/dist/es/components/LayoutGroup.vue.mjs +39 -0
- package/dist/es/components/LayoutGroup.vue2.mjs +4 -0
- package/dist/es/components/Motion.vue.mjs +22 -10
- package/dist/es/components/context.mjs +12 -1
- package/dist/es/components/group.mjs +30 -0
- package/dist/es/components/use-force-update.mjs +11 -0
- package/dist/es/constants/index.mjs +8 -2
- package/dist/es/external/.pnpm/@vueuse_shared@12.0.0_typescript@5.5.4/external/@vueuse/shared/index.mjs +6 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/events/add-dom-event.mjs +7 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/frameloop/microtask.mjs +6 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/animation/mix-values.mjs +60 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/geometry/copy.mjs +19 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/geometry/delta-apply.mjs +81 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/geometry/delta-calc.mjs +55 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/geometry/delta-remove.mjs +40 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/geometry/models.mjs +13 -1
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/geometry/utils.mjs +34 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +13 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +28 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/node/create-projection-node.mjs +1086 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/node/state.mjs +15 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/shared/stack.mjs +94 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +26 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +25 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/scale-correction.mjs +4 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/transform.mjs +36 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/utils/each-axis.mjs +6 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/utils/has-transform.mjs +20 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/render/utils/compare-by-depth.mjs +4 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/render/utils/flat-tree.mjs +24 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/utils/resolve-value.mjs +4 -0
- package/dist/es/external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +9 -0
- package/dist/es/features/events.mjs +2 -2
- package/dist/es/features/feature-manager.mjs +3 -1
- package/dist/es/features/gestures/hover.mjs +1 -1
- package/dist/es/features/gestures/in-view.mjs +1 -1
- package/dist/es/features/gestures/press.mjs +1 -1
- package/dist/es/features/layout/config.mjs +21 -0
- package/dist/es/features/layout/layout.mjs +74 -0
- package/dist/es/features/layout/utils.mjs +8 -0
- package/dist/es/features/svg.mjs +1 -1
- package/dist/es/index.mjs +17 -0
- package/dist/es/state/create-visual-element.mjs +9 -0
- package/dist/es/state/motion-state.mjs +24 -11
- package/dist/es/state/style.mjs +2 -2
- package/dist/es/state/transform.mjs +0 -1
- package/dist/es/value/use-motion-value-event.mjs +11 -0
- package/dist/es/value/use-velocity.mjs +20 -0
- package/dist/src/components/LayoutGroup.d.ts +30 -0
- package/dist/src/components/context.d.ts +17 -0
- package/dist/src/components/group.d.ts +7 -0
- package/dist/src/components/use-force-update.d.ts +2 -0
- package/dist/src/features/index.d.ts +1 -0
- package/dist/src/features/layout/config.d.ts +8 -0
- package/dist/src/features/layout/layout.d.ts +10 -0
- package/dist/src/features/layout/types.d.ts +7 -0
- package/dist/src/features/layout/utils.d.ts +4 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/state/create-visual-element.d.ts +1 -0
- package/dist/src/state/motion-state.d.ts +1 -2
- package/dist/src/types/state.d.ts +2 -1
- package/dist/src/value/index.d.ts +4 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const vue = require("vue");
|
|
4
|
-
const core = require("@vueuse/core");
|
|
5
4
|
function addUniqueItem$1(arr, item) {
|
|
6
5
|
if (arr.indexOf(item) === -1)
|
|
7
6
|
arr.push(item);
|
|
@@ -2832,6 +2831,9 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
2832
2831
|
const isKeyframesTarget = (v) => {
|
|
2833
2832
|
return Array.isArray(v);
|
|
2834
2833
|
};
|
|
2834
|
+
const isCustomValue = (v) => {
|
|
2835
|
+
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
2836
|
+
};
|
|
2835
2837
|
const resolveFinalValueInKeyframes = (v) => {
|
|
2836
2838
|
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
2837
2839
|
};
|
|
@@ -2945,6 +2947,9 @@ function isSVGElement$2(element) {
|
|
|
2945
2947
|
return element instanceof SVGElement && element.tagName !== "svg";
|
|
2946
2948
|
}
|
|
2947
2949
|
const scaleCorrectors = {};
|
|
2950
|
+
function addScaleCorrector(correctors) {
|
|
2951
|
+
Object.assign(scaleCorrectors, correctors);
|
|
2952
|
+
}
|
|
2948
2953
|
function isForcedMotionValue(key, { layout, layoutId }) {
|
|
2949
2954
|
return transformProps.has(key) || key.startsWith("origin") || (layout || layoutId !== void 0) && (!!scaleCorrectors[key] || key === "opacity");
|
|
2950
2955
|
}
|
|
@@ -3066,6 +3071,16 @@ for (const key in featureProps) {
|
|
|
3066
3071
|
}
|
|
3067
3072
|
const valueTypes = [...dimensionValueTypes, color, complex];
|
|
3068
3073
|
const findValueType = (v) => valueTypes.find(testValueType(v));
|
|
3074
|
+
const createAxisDelta = () => ({
|
|
3075
|
+
translate: 0,
|
|
3076
|
+
scale: 1,
|
|
3077
|
+
origin: 0,
|
|
3078
|
+
originPoint: 0
|
|
3079
|
+
});
|
|
3080
|
+
const createDelta = () => ({
|
|
3081
|
+
x: createAxisDelta(),
|
|
3082
|
+
y: createAxisDelta()
|
|
3083
|
+
});
|
|
3069
3084
|
const createAxis = () => ({ min: 0, max: 0 });
|
|
3070
3085
|
const createBox = () => ({
|
|
3071
3086
|
x: createAxis(),
|
|
@@ -3481,12 +3496,12 @@ function buildTransform(latestValues, transform2, transformTemplate) {
|
|
|
3481
3496
|
}
|
|
3482
3497
|
function buildHTMLStyles(state2, latestValues, transformTemplate) {
|
|
3483
3498
|
const { style: style2, vars, transformOrigin } = state2;
|
|
3484
|
-
let
|
|
3499
|
+
let hasTransform2 = false;
|
|
3485
3500
|
let hasTransformOrigin = false;
|
|
3486
3501
|
for (const key in latestValues) {
|
|
3487
3502
|
const value = latestValues[key];
|
|
3488
3503
|
if (transformProps.has(key)) {
|
|
3489
|
-
|
|
3504
|
+
hasTransform2 = true;
|
|
3490
3505
|
continue;
|
|
3491
3506
|
} else if (isCSSVariableName(key)) {
|
|
3492
3507
|
vars[key] = value;
|
|
@@ -3502,7 +3517,7 @@ function buildHTMLStyles(state2, latestValues, transformTemplate) {
|
|
|
3502
3517
|
}
|
|
3503
3518
|
}
|
|
3504
3519
|
if (!latestValues.transform) {
|
|
3505
|
-
if (
|
|
3520
|
+
if (hasTransform2 || transformTemplate) {
|
|
3506
3521
|
style2.transform = buildTransform(latestValues, state2.transform, transformTemplate);
|
|
3507
3522
|
} else if (style2.transform) {
|
|
3508
3523
|
style2.transform = "none";
|
|
@@ -3665,6 +3680,90 @@ function transformBoxPoints(point2, transformPoint) {
|
|
|
3665
3680
|
right: bottomRight.x
|
|
3666
3681
|
};
|
|
3667
3682
|
}
|
|
3683
|
+
function isIdentityScale(scale2) {
|
|
3684
|
+
return scale2 === void 0 || scale2 === 1;
|
|
3685
|
+
}
|
|
3686
|
+
function hasScale({ scale: scale2, scaleX, scaleY }) {
|
|
3687
|
+
return !isIdentityScale(scale2) || !isIdentityScale(scaleX) || !isIdentityScale(scaleY);
|
|
3688
|
+
}
|
|
3689
|
+
function hasTransform(values) {
|
|
3690
|
+
return hasScale(values) || has2DTranslate(values) || values.z || values.rotate || values.rotateX || values.rotateY || values.skewX || values.skewY;
|
|
3691
|
+
}
|
|
3692
|
+
function has2DTranslate(values) {
|
|
3693
|
+
return is2DTranslate(values.x) || is2DTranslate(values.y);
|
|
3694
|
+
}
|
|
3695
|
+
function is2DTranslate(value) {
|
|
3696
|
+
return value && value !== "0%";
|
|
3697
|
+
}
|
|
3698
|
+
function scalePoint(point2, scale2, originPoint) {
|
|
3699
|
+
const distanceFromOrigin = point2 - originPoint;
|
|
3700
|
+
const scaled = scale2 * distanceFromOrigin;
|
|
3701
|
+
return originPoint + scaled;
|
|
3702
|
+
}
|
|
3703
|
+
function applyPointDelta(point2, translate, scale2, originPoint, boxScale) {
|
|
3704
|
+
if (boxScale !== void 0) {
|
|
3705
|
+
point2 = scalePoint(point2, boxScale, originPoint);
|
|
3706
|
+
}
|
|
3707
|
+
return scalePoint(point2, scale2, originPoint) + translate;
|
|
3708
|
+
}
|
|
3709
|
+
function applyAxisDelta(axis, translate = 0, scale2 = 1, originPoint, boxScale) {
|
|
3710
|
+
axis.min = applyPointDelta(axis.min, translate, scale2, originPoint, boxScale);
|
|
3711
|
+
axis.max = applyPointDelta(axis.max, translate, scale2, originPoint, boxScale);
|
|
3712
|
+
}
|
|
3713
|
+
function applyBoxDelta(box, { x, y }) {
|
|
3714
|
+
applyAxisDelta(box.x, x.translate, x.scale, x.originPoint);
|
|
3715
|
+
applyAxisDelta(box.y, y.translate, y.scale, y.originPoint);
|
|
3716
|
+
}
|
|
3717
|
+
const TREE_SCALE_SNAP_MIN = 0.999999999999;
|
|
3718
|
+
const TREE_SCALE_SNAP_MAX = 1.0000000000001;
|
|
3719
|
+
function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
|
|
3720
|
+
const treeLength = treePath.length;
|
|
3721
|
+
if (!treeLength)
|
|
3722
|
+
return;
|
|
3723
|
+
treeScale.x = treeScale.y = 1;
|
|
3724
|
+
let node;
|
|
3725
|
+
let delta;
|
|
3726
|
+
for (let i = 0; i < treeLength; i++) {
|
|
3727
|
+
node = treePath[i];
|
|
3728
|
+
delta = node.projectionDelta;
|
|
3729
|
+
const { visualElement } = node.options;
|
|
3730
|
+
if (visualElement && visualElement.props.style && visualElement.props.style.display === "contents") {
|
|
3731
|
+
continue;
|
|
3732
|
+
}
|
|
3733
|
+
if (isSharedTransition && node.options.layoutScroll && node.scroll && node !== node.root) {
|
|
3734
|
+
transformBox(box, {
|
|
3735
|
+
x: -node.scroll.offset.x,
|
|
3736
|
+
y: -node.scroll.offset.y
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
if (delta) {
|
|
3740
|
+
treeScale.x *= delta.x.scale;
|
|
3741
|
+
treeScale.y *= delta.y.scale;
|
|
3742
|
+
applyBoxDelta(box, delta);
|
|
3743
|
+
}
|
|
3744
|
+
if (isSharedTransition && hasTransform(node.latestValues)) {
|
|
3745
|
+
transformBox(box, node.latestValues);
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
if (treeScale.x < TREE_SCALE_SNAP_MAX && treeScale.x > TREE_SCALE_SNAP_MIN) {
|
|
3749
|
+
treeScale.x = 1;
|
|
3750
|
+
}
|
|
3751
|
+
if (treeScale.y < TREE_SCALE_SNAP_MAX && treeScale.y > TREE_SCALE_SNAP_MIN) {
|
|
3752
|
+
treeScale.y = 1;
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
function translateAxis(axis, distance2) {
|
|
3756
|
+
axis.min = axis.min + distance2;
|
|
3757
|
+
axis.max = axis.max + distance2;
|
|
3758
|
+
}
|
|
3759
|
+
function transformAxis(axis, axisTranslate, axisScale, boxScale, axisOrigin = 0.5) {
|
|
3760
|
+
const originPoint = mixNumber$1(axis.min, axis.max, axisOrigin);
|
|
3761
|
+
applyAxisDelta(axis, axisTranslate, axisScale, originPoint, boxScale);
|
|
3762
|
+
}
|
|
3763
|
+
function transformBox(box, transform2) {
|
|
3764
|
+
transformAxis(box.x, transform2.x, transform2.scaleX, transform2.scale, transform2.originX);
|
|
3765
|
+
transformAxis(box.y, transform2.y, transform2.scaleY, transform2.scale, transform2.originY);
|
|
3766
|
+
}
|
|
3668
3767
|
function measureViewportBox(instance, transformPoint) {
|
|
3669
3768
|
return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
|
|
3670
3769
|
}
|
|
@@ -3798,9 +3897,9 @@ function animateSubject(subject, keyframes2, options, scope) {
|
|
|
3798
3897
|
exports.invariant(Boolean(numSubjects), "No valid elements provided.");
|
|
3799
3898
|
for (let i = 0; i < numSubjects; i++) {
|
|
3800
3899
|
const thisSubject = subjects[i];
|
|
3801
|
-
const
|
|
3900
|
+
const createVisualElement2 = thisSubject instanceof Element ? createDOMVisualElement : createObjectVisualElement;
|
|
3802
3901
|
if (!visualElementStore.has(thisSubject)) {
|
|
3803
|
-
|
|
3902
|
+
createVisualElement2(thisSubject);
|
|
3804
3903
|
}
|
|
3805
3904
|
const visualElement = visualElementStore.get(thisSubject);
|
|
3806
3905
|
const transition = { ...options };
|
|
@@ -4226,17 +4325,17 @@ function resolveEdge(edge, length, inset = 0) {
|
|
|
4226
4325
|
edge = namedEdges[edge];
|
|
4227
4326
|
}
|
|
4228
4327
|
if (typeof edge === "string") {
|
|
4229
|
-
const
|
|
4328
|
+
const asNumber2 = parseFloat(edge);
|
|
4230
4329
|
if (edge.endsWith("px")) {
|
|
4231
|
-
delta =
|
|
4330
|
+
delta = asNumber2;
|
|
4232
4331
|
} else if (edge.endsWith("%")) {
|
|
4233
|
-
edge =
|
|
4332
|
+
edge = asNumber2 / 100;
|
|
4234
4333
|
} else if (edge.endsWith("vw")) {
|
|
4235
|
-
delta =
|
|
4334
|
+
delta = asNumber2 / 100 * document.documentElement.clientWidth;
|
|
4236
4335
|
} else if (edge.endsWith("vh")) {
|
|
4237
|
-
delta =
|
|
4336
|
+
delta = asNumber2 / 100 * document.documentElement.clientHeight;
|
|
4238
4337
|
} else {
|
|
4239
|
-
edge =
|
|
4338
|
+
edge = asNumber2;
|
|
4240
4339
|
}
|
|
4241
4340
|
}
|
|
4242
4341
|
if (typeof edge === "number") {
|
|
@@ -4622,6 +4721,13 @@ function useAnimationFrame(callback) {
|
|
|
4622
4721
|
frame.update(provideTimeSinceStart, true);
|
|
4623
4722
|
}
|
|
4624
4723
|
const [injectMotion, provideMotion] = createContext("Motion");
|
|
4724
|
+
const [injectLayoutGroup, provideLayoutGroup] = createContext("LayoutGroup");
|
|
4725
|
+
function shouldInheritGroup(inherit) {
|
|
4726
|
+
return inherit === true;
|
|
4727
|
+
}
|
|
4728
|
+
function shouldInheritId(inherit) {
|
|
4729
|
+
return shouldInheritGroup(inherit === true) || inherit === "id";
|
|
4730
|
+
}
|
|
4625
4731
|
function resolveVariant(definition, variants, custom) {
|
|
4626
4732
|
if (typeof definition === "object") {
|
|
4627
4733
|
return definition;
|
|
@@ -4727,6 +4833,8 @@ const svgElementSet = new Set(svgElements);
|
|
|
4727
4833
|
function isSVGElement$1(as) {
|
|
4728
4834
|
return svgElementSet.has(as);
|
|
4729
4835
|
}
|
|
4836
|
+
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
4837
|
+
const isDef = (val) => typeof val !== "undefined";
|
|
4730
4838
|
const rotation = {
|
|
4731
4839
|
syntax: "<angle>",
|
|
4732
4840
|
initialValue: "0deg",
|
|
@@ -4986,7 +5094,7 @@ class EventFeature extends Feature {
|
|
|
4986
5094
|
this.handlers = {};
|
|
4987
5095
|
}
|
|
4988
5096
|
mount() {
|
|
4989
|
-
const element = this.state.
|
|
5097
|
+
const element = this.state.element;
|
|
4990
5098
|
if (!element)
|
|
4991
5099
|
return;
|
|
4992
5100
|
this.handlers.motionstart = (event) => {
|
|
@@ -5034,7 +5142,7 @@ class EventFeature extends Feature {
|
|
|
5034
5142
|
});
|
|
5035
5143
|
}
|
|
5036
5144
|
unmount() {
|
|
5037
|
-
const element = this.state.
|
|
5145
|
+
const element = this.state.element;
|
|
5038
5146
|
if (!element)
|
|
5039
5147
|
return;
|
|
5040
5148
|
Object.entries(this.handlers).forEach(([event, handler]) => {
|
|
@@ -5080,7 +5188,7 @@ class HoverGesture extends BaseGesture {
|
|
|
5080
5188
|
constructor(state2) {
|
|
5081
5189
|
super(state2);
|
|
5082
5190
|
this.subscribeEvents = () => {
|
|
5083
|
-
const element = this.state.
|
|
5191
|
+
const element = this.state.element;
|
|
5084
5192
|
const onEnter = mouseEvent(element, "hoverstart", () => {
|
|
5085
5193
|
this.state.setActive("hover", true);
|
|
5086
5194
|
});
|
|
@@ -5109,7 +5217,7 @@ class PressGesture extends BaseGesture {
|
|
|
5109
5217
|
constructor(state2) {
|
|
5110
5218
|
super(state2);
|
|
5111
5219
|
this.subscribeEvents = () => {
|
|
5112
|
-
const element = this.state.
|
|
5220
|
+
const element = this.state.element;
|
|
5113
5221
|
const onPointerUp = (event) => {
|
|
5114
5222
|
this.state.setActive("press", false);
|
|
5115
5223
|
dispatchPointerEvent(element, "pressend", event);
|
|
@@ -5142,7 +5250,7 @@ class InViewGesture extends BaseGesture {
|
|
|
5142
5250
|
super(state2);
|
|
5143
5251
|
this.subscribeEvents = () => {
|
|
5144
5252
|
var _a;
|
|
5145
|
-
const element = this.state.
|
|
5253
|
+
const element = this.state.element;
|
|
5146
5254
|
const { once, ...viewOptions } = ((_a = this.state.getOptions()) == null ? void 0 : _a.inViewOptions) || {};
|
|
5147
5255
|
return inView(element, (enterEntry) => {
|
|
5148
5256
|
this.state.setActive("inView", true);
|
|
@@ -5168,7 +5276,7 @@ function isSVGElement(element) {
|
|
|
5168
5276
|
}
|
|
5169
5277
|
class SVGFeature extends Feature {
|
|
5170
5278
|
mount() {
|
|
5171
|
-
const instance = this.state.
|
|
5279
|
+
const instance = this.state.element;
|
|
5172
5280
|
if (!isSVGElement(instance)) {
|
|
5173
5281
|
return;
|
|
5174
5282
|
}
|
|
@@ -5189,6 +5297,1544 @@ class SVGFeature extends Feature {
|
|
|
5189
5297
|
unmount() {
|
|
5190
5298
|
}
|
|
5191
5299
|
}
|
|
5300
|
+
const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
5301
|
+
const numBorders = borders.length;
|
|
5302
|
+
const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
|
|
5303
|
+
const isPx = (value) => typeof value === "number" || px.test(value);
|
|
5304
|
+
function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
|
|
5305
|
+
if (shouldCrossfadeOpacity) {
|
|
5306
|
+
target.opacity = mixNumber$1(
|
|
5307
|
+
0,
|
|
5308
|
+
// TODO Reinstate this if only child
|
|
5309
|
+
lead.opacity !== void 0 ? lead.opacity : 1,
|
|
5310
|
+
easeCrossfadeIn(progress2)
|
|
5311
|
+
);
|
|
5312
|
+
target.opacityExit = mixNumber$1(follow.opacity !== void 0 ? follow.opacity : 1, 0, easeCrossfadeOut(progress2));
|
|
5313
|
+
} else if (isOnlyMember) {
|
|
5314
|
+
target.opacity = mixNumber$1(follow.opacity !== void 0 ? follow.opacity : 1, lead.opacity !== void 0 ? lead.opacity : 1, progress2);
|
|
5315
|
+
}
|
|
5316
|
+
for (let i = 0; i < numBorders; i++) {
|
|
5317
|
+
const borderLabel = `border${borders[i]}Radius`;
|
|
5318
|
+
let followRadius = getRadius(follow, borderLabel);
|
|
5319
|
+
let leadRadius = getRadius(lead, borderLabel);
|
|
5320
|
+
if (followRadius === void 0 && leadRadius === void 0)
|
|
5321
|
+
continue;
|
|
5322
|
+
followRadius || (followRadius = 0);
|
|
5323
|
+
leadRadius || (leadRadius = 0);
|
|
5324
|
+
const canMix = followRadius === 0 || leadRadius === 0 || isPx(followRadius) === isPx(leadRadius);
|
|
5325
|
+
if (canMix) {
|
|
5326
|
+
target[borderLabel] = Math.max(mixNumber$1(asNumber(followRadius), asNumber(leadRadius), progress2), 0);
|
|
5327
|
+
if (percent.test(leadRadius) || percent.test(followRadius)) {
|
|
5328
|
+
target[borderLabel] += "%";
|
|
5329
|
+
}
|
|
5330
|
+
} else {
|
|
5331
|
+
target[borderLabel] = leadRadius;
|
|
5332
|
+
}
|
|
5333
|
+
}
|
|
5334
|
+
if (follow.rotate || lead.rotate) {
|
|
5335
|
+
target.rotate = mixNumber$1(follow.rotate || 0, lead.rotate || 0, progress2);
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5338
|
+
function getRadius(values, radiusName) {
|
|
5339
|
+
return values[radiusName] !== void 0 ? values[radiusName] : values.borderRadius;
|
|
5340
|
+
}
|
|
5341
|
+
const easeCrossfadeIn = /* @__PURE__ */ compress(0, 0.5, circOut);
|
|
5342
|
+
const easeCrossfadeOut = /* @__PURE__ */ compress(0.5, 0.95, noop$1);
|
|
5343
|
+
function compress(min, max, easing) {
|
|
5344
|
+
return (p) => {
|
|
5345
|
+
if (p < min)
|
|
5346
|
+
return 0;
|
|
5347
|
+
if (p > max)
|
|
5348
|
+
return 1;
|
|
5349
|
+
return easing(progress(min, max, p));
|
|
5350
|
+
};
|
|
5351
|
+
}
|
|
5352
|
+
function copyAxisInto(axis, originAxis) {
|
|
5353
|
+
axis.min = originAxis.min;
|
|
5354
|
+
axis.max = originAxis.max;
|
|
5355
|
+
}
|
|
5356
|
+
function copyBoxInto(box, originBox) {
|
|
5357
|
+
copyAxisInto(box.x, originBox.x);
|
|
5358
|
+
copyAxisInto(box.y, originBox.y);
|
|
5359
|
+
}
|
|
5360
|
+
function copyAxisDeltaInto(delta, originDelta) {
|
|
5361
|
+
delta.translate = originDelta.translate;
|
|
5362
|
+
delta.scale = originDelta.scale;
|
|
5363
|
+
delta.originPoint = originDelta.originPoint;
|
|
5364
|
+
delta.origin = originDelta.origin;
|
|
5365
|
+
}
|
|
5366
|
+
const SCALE_PRECISION = 1e-4;
|
|
5367
|
+
const SCALE_MIN = 1 - SCALE_PRECISION;
|
|
5368
|
+
const SCALE_MAX = 1 + SCALE_PRECISION;
|
|
5369
|
+
const TRANSLATE_PRECISION = 0.01;
|
|
5370
|
+
const TRANSLATE_MIN = 0 - TRANSLATE_PRECISION;
|
|
5371
|
+
const TRANSLATE_MAX = 0 + TRANSLATE_PRECISION;
|
|
5372
|
+
function calcLength(axis) {
|
|
5373
|
+
return axis.max - axis.min;
|
|
5374
|
+
}
|
|
5375
|
+
function isNear(value, target, maxDistance) {
|
|
5376
|
+
return Math.abs(value - target) <= maxDistance;
|
|
5377
|
+
}
|
|
5378
|
+
function calcAxisDelta(delta, source, target, origin = 0.5) {
|
|
5379
|
+
delta.origin = origin;
|
|
5380
|
+
delta.originPoint = mixNumber$1(source.min, source.max, delta.origin);
|
|
5381
|
+
delta.scale = calcLength(target) / calcLength(source);
|
|
5382
|
+
delta.translate = mixNumber$1(target.min, target.max, delta.origin) - delta.originPoint;
|
|
5383
|
+
if (delta.scale >= SCALE_MIN && delta.scale <= SCALE_MAX || isNaN(delta.scale)) {
|
|
5384
|
+
delta.scale = 1;
|
|
5385
|
+
}
|
|
5386
|
+
if (delta.translate >= TRANSLATE_MIN && delta.translate <= TRANSLATE_MAX || isNaN(delta.translate)) {
|
|
5387
|
+
delta.translate = 0;
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
function calcBoxDelta(delta, source, target, origin) {
|
|
5391
|
+
calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : void 0);
|
|
5392
|
+
calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : void 0);
|
|
5393
|
+
}
|
|
5394
|
+
function calcRelativeAxis(target, relative, parent) {
|
|
5395
|
+
target.min = parent.min + relative.min;
|
|
5396
|
+
target.max = target.min + calcLength(relative);
|
|
5397
|
+
}
|
|
5398
|
+
function calcRelativeBox(target, relative, parent) {
|
|
5399
|
+
calcRelativeAxis(target.x, relative.x, parent.x);
|
|
5400
|
+
calcRelativeAxis(target.y, relative.y, parent.y);
|
|
5401
|
+
}
|
|
5402
|
+
function calcRelativeAxisPosition(target, layout, parent) {
|
|
5403
|
+
target.min = layout.min - parent.min;
|
|
5404
|
+
target.max = target.min + calcLength(layout);
|
|
5405
|
+
}
|
|
5406
|
+
function calcRelativePosition(target, layout, parent) {
|
|
5407
|
+
calcRelativeAxisPosition(target.x, layout.x, parent.x);
|
|
5408
|
+
calcRelativeAxisPosition(target.y, layout.y, parent.y);
|
|
5409
|
+
}
|
|
5410
|
+
function removePointDelta(point2, translate, scale2, originPoint, boxScale) {
|
|
5411
|
+
point2 -= translate;
|
|
5412
|
+
point2 = scalePoint(point2, 1 / scale2, originPoint);
|
|
5413
|
+
if (boxScale !== void 0) {
|
|
5414
|
+
point2 = scalePoint(point2, 1 / boxScale, originPoint);
|
|
5415
|
+
}
|
|
5416
|
+
return point2;
|
|
5417
|
+
}
|
|
5418
|
+
function removeAxisDelta(axis, translate = 0, scale2 = 1, origin = 0.5, boxScale, originAxis = axis, sourceAxis = axis) {
|
|
5419
|
+
if (percent.test(translate)) {
|
|
5420
|
+
translate = parseFloat(translate);
|
|
5421
|
+
const relativeProgress = mixNumber$1(sourceAxis.min, sourceAxis.max, translate / 100);
|
|
5422
|
+
translate = relativeProgress - sourceAxis.min;
|
|
5423
|
+
}
|
|
5424
|
+
if (typeof translate !== "number")
|
|
5425
|
+
return;
|
|
5426
|
+
let originPoint = mixNumber$1(originAxis.min, originAxis.max, origin);
|
|
5427
|
+
if (axis === originAxis)
|
|
5428
|
+
originPoint -= translate;
|
|
5429
|
+
axis.min = removePointDelta(axis.min, translate, scale2, originPoint, boxScale);
|
|
5430
|
+
axis.max = removePointDelta(axis.max, translate, scale2, originPoint, boxScale);
|
|
5431
|
+
}
|
|
5432
|
+
function removeAxisTransforms(axis, transforms2, [key, scaleKey, originKey], origin, sourceAxis) {
|
|
5433
|
+
removeAxisDelta(axis, transforms2[key], transforms2[scaleKey], transforms2[originKey], transforms2.scale, origin, sourceAxis);
|
|
5434
|
+
}
|
|
5435
|
+
const xKeys = ["x", "scaleX", "originX"];
|
|
5436
|
+
const yKeys = ["y", "scaleY", "originY"];
|
|
5437
|
+
function removeBoxTransforms(box, transforms2, originBox, sourceBox) {
|
|
5438
|
+
removeAxisTransforms(box.x, transforms2, xKeys, originBox ? originBox.x : void 0, sourceBox ? sourceBox.x : void 0);
|
|
5439
|
+
removeAxisTransforms(box.y, transforms2, yKeys, originBox ? originBox.y : void 0, sourceBox ? sourceBox.y : void 0);
|
|
5440
|
+
}
|
|
5441
|
+
function isAxisDeltaZero(delta) {
|
|
5442
|
+
return delta.translate === 0 && delta.scale === 1;
|
|
5443
|
+
}
|
|
5444
|
+
function isDeltaZero(delta) {
|
|
5445
|
+
return isAxisDeltaZero(delta.x) && isAxisDeltaZero(delta.y);
|
|
5446
|
+
}
|
|
5447
|
+
function axisEquals(a, b) {
|
|
5448
|
+
return a.min === b.min && a.max === b.max;
|
|
5449
|
+
}
|
|
5450
|
+
function boxEquals(a, b) {
|
|
5451
|
+
return axisEquals(a.x, b.x) && axisEquals(a.y, b.y);
|
|
5452
|
+
}
|
|
5453
|
+
function axisEqualsRounded(a, b) {
|
|
5454
|
+
return Math.round(a.min) === Math.round(b.min) && Math.round(a.max) === Math.round(b.max);
|
|
5455
|
+
}
|
|
5456
|
+
function boxEqualsRounded(a, b) {
|
|
5457
|
+
return axisEqualsRounded(a.x, b.x) && axisEqualsRounded(a.y, b.y);
|
|
5458
|
+
}
|
|
5459
|
+
function aspectRatio(box) {
|
|
5460
|
+
return calcLength(box.x) / calcLength(box.y);
|
|
5461
|
+
}
|
|
5462
|
+
function axisDeltaEquals(a, b) {
|
|
5463
|
+
return a.translate === b.translate && a.scale === b.scale && a.originPoint === b.originPoint;
|
|
5464
|
+
}
|
|
5465
|
+
class NodeStack {
|
|
5466
|
+
constructor() {
|
|
5467
|
+
this.members = [];
|
|
5468
|
+
}
|
|
5469
|
+
add(node) {
|
|
5470
|
+
addUniqueItem$1(this.members, node);
|
|
5471
|
+
node.scheduleRender();
|
|
5472
|
+
}
|
|
5473
|
+
remove(node) {
|
|
5474
|
+
removeItem$1(this.members, node);
|
|
5475
|
+
if (node === this.prevLead) {
|
|
5476
|
+
this.prevLead = void 0;
|
|
5477
|
+
}
|
|
5478
|
+
if (node === this.lead) {
|
|
5479
|
+
const prevLead = this.members[this.members.length - 1];
|
|
5480
|
+
if (prevLead) {
|
|
5481
|
+
this.promote(prevLead);
|
|
5482
|
+
}
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
relegate(node) {
|
|
5486
|
+
const indexOfNode = this.members.findIndex((member) => node === member);
|
|
5487
|
+
if (indexOfNode === 0)
|
|
5488
|
+
return false;
|
|
5489
|
+
let prevLead;
|
|
5490
|
+
for (let i = indexOfNode; i >= 0; i--) {
|
|
5491
|
+
const member = this.members[i];
|
|
5492
|
+
if (member.isPresent !== false) {
|
|
5493
|
+
prevLead = member;
|
|
5494
|
+
break;
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
if (prevLead) {
|
|
5498
|
+
this.promote(prevLead);
|
|
5499
|
+
return true;
|
|
5500
|
+
} else {
|
|
5501
|
+
return false;
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5504
|
+
promote(node, preserveFollowOpacity) {
|
|
5505
|
+
const prevLead = this.lead;
|
|
5506
|
+
if (node === prevLead)
|
|
5507
|
+
return;
|
|
5508
|
+
this.prevLead = prevLead;
|
|
5509
|
+
this.lead = node;
|
|
5510
|
+
node.show();
|
|
5511
|
+
if (prevLead) {
|
|
5512
|
+
prevLead.instance && prevLead.scheduleRender();
|
|
5513
|
+
node.scheduleRender();
|
|
5514
|
+
node.resumeFrom = prevLead;
|
|
5515
|
+
if (preserveFollowOpacity) {
|
|
5516
|
+
node.resumeFrom.preserveOpacity = true;
|
|
5517
|
+
}
|
|
5518
|
+
if (prevLead.snapshot) {
|
|
5519
|
+
node.snapshot = prevLead.snapshot;
|
|
5520
|
+
node.snapshot.latestValues = prevLead.animationValues || prevLead.latestValues;
|
|
5521
|
+
}
|
|
5522
|
+
if (node.root && node.root.isUpdating) {
|
|
5523
|
+
node.isLayoutDirty = true;
|
|
5524
|
+
}
|
|
5525
|
+
const { crossfade } = node.options;
|
|
5526
|
+
if (crossfade === false) {
|
|
5527
|
+
prevLead.hide();
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
exitAnimationComplete() {
|
|
5532
|
+
this.members.forEach((node) => {
|
|
5533
|
+
const { options, resumingFrom } = node;
|
|
5534
|
+
options.onExitComplete && options.onExitComplete();
|
|
5535
|
+
if (resumingFrom) {
|
|
5536
|
+
resumingFrom.options.onExitComplete && resumingFrom.options.onExitComplete();
|
|
5537
|
+
}
|
|
5538
|
+
});
|
|
5539
|
+
}
|
|
5540
|
+
scheduleRender() {
|
|
5541
|
+
this.members.forEach((node) => {
|
|
5542
|
+
node.instance && node.scheduleRender(false);
|
|
5543
|
+
});
|
|
5544
|
+
}
|
|
5545
|
+
/**
|
|
5546
|
+
* Clear any leads that have been removed this render to prevent them from being
|
|
5547
|
+
* used in future animations and to prevent memory leaks
|
|
5548
|
+
*/
|
|
5549
|
+
removeLeadSnapshot() {
|
|
5550
|
+
if (this.lead && this.lead.snapshot) {
|
|
5551
|
+
this.lead.snapshot = void 0;
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
5556
|
+
let transform2 = "";
|
|
5557
|
+
const xTranslate = delta.x.translate / treeScale.x;
|
|
5558
|
+
const yTranslate = delta.y.translate / treeScale.y;
|
|
5559
|
+
const zTranslate = (latestTransform === null || latestTransform === void 0 ? void 0 : latestTransform.z) || 0;
|
|
5560
|
+
if (xTranslate || yTranslate || zTranslate) {
|
|
5561
|
+
transform2 = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
|
|
5562
|
+
}
|
|
5563
|
+
if (treeScale.x !== 1 || treeScale.y !== 1) {
|
|
5564
|
+
transform2 += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
|
|
5565
|
+
}
|
|
5566
|
+
if (latestTransform) {
|
|
5567
|
+
const { transformPerspective, rotate, rotateX, rotateY, skewX, skewY } = latestTransform;
|
|
5568
|
+
if (transformPerspective)
|
|
5569
|
+
transform2 = `perspective(${transformPerspective}px) ${transform2}`;
|
|
5570
|
+
if (rotate)
|
|
5571
|
+
transform2 += `rotate(${rotate}deg) `;
|
|
5572
|
+
if (rotateX)
|
|
5573
|
+
transform2 += `rotateX(${rotateX}deg) `;
|
|
5574
|
+
if (rotateY)
|
|
5575
|
+
transform2 += `rotateY(${rotateY}deg) `;
|
|
5576
|
+
if (skewX)
|
|
5577
|
+
transform2 += `skewX(${skewX}deg) `;
|
|
5578
|
+
if (skewY)
|
|
5579
|
+
transform2 += `skewY(${skewY}deg) `;
|
|
5580
|
+
}
|
|
5581
|
+
const elementScaleX = delta.x.scale * treeScale.x;
|
|
5582
|
+
const elementScaleY = delta.y.scale * treeScale.y;
|
|
5583
|
+
if (elementScaleX !== 1 || elementScaleY !== 1) {
|
|
5584
|
+
transform2 += `scale(${elementScaleX}, ${elementScaleY})`;
|
|
5585
|
+
}
|
|
5586
|
+
return transform2 || "none";
|
|
5587
|
+
}
|
|
5588
|
+
function eachAxis(callback) {
|
|
5589
|
+
return [callback("x"), callback("y")];
|
|
5590
|
+
}
|
|
5591
|
+
const compareByDepth$1 = (a, b) => a.depth - b.depth;
|
|
5592
|
+
class FlatTree {
|
|
5593
|
+
constructor() {
|
|
5594
|
+
this.children = [];
|
|
5595
|
+
this.isDirty = false;
|
|
5596
|
+
}
|
|
5597
|
+
add(child) {
|
|
5598
|
+
addUniqueItem$1(this.children, child);
|
|
5599
|
+
this.isDirty = true;
|
|
5600
|
+
}
|
|
5601
|
+
remove(child) {
|
|
5602
|
+
removeItem$1(this.children, child);
|
|
5603
|
+
this.isDirty = true;
|
|
5604
|
+
}
|
|
5605
|
+
forEach(callback) {
|
|
5606
|
+
this.isDirty && this.children.sort(compareByDepth$1);
|
|
5607
|
+
this.isDirty = false;
|
|
5608
|
+
this.children.forEach(callback);
|
|
5609
|
+
}
|
|
5610
|
+
}
|
|
5611
|
+
function resolveMotionValue(value) {
|
|
5612
|
+
const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
|
|
5613
|
+
return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
|
|
5614
|
+
}
|
|
5615
|
+
const globalProjectionState = {
|
|
5616
|
+
/**
|
|
5617
|
+
* Global flag as to whether the tree has animated since the last time
|
|
5618
|
+
* we resized the window
|
|
5619
|
+
*/
|
|
5620
|
+
hasAnimatedSinceResize: true,
|
|
5621
|
+
/**
|
|
5622
|
+
* We set this to true once, on the first update. Any nodes added to the tree beyond that
|
|
5623
|
+
* update will be given a `data-projection-id` attribute.
|
|
5624
|
+
*/
|
|
5625
|
+
hasEverUpdated: false
|
|
5626
|
+
};
|
|
5627
|
+
const { schedule: microtask, cancel: cancelMicrotask } = createRenderBatcher(queueMicrotask, false);
|
|
5628
|
+
const metrics = {
|
|
5629
|
+
type: "projectionFrame",
|
|
5630
|
+
totalNodes: 0,
|
|
5631
|
+
resolvedTargetDeltas: 0,
|
|
5632
|
+
recalculatedProjection: 0
|
|
5633
|
+
};
|
|
5634
|
+
const isDebug = typeof window !== "undefined" && window.MotionDebug !== void 0;
|
|
5635
|
+
const transformAxes = ["", "X", "Y", "Z"];
|
|
5636
|
+
const hiddenVisibility = { visibility: "hidden" };
|
|
5637
|
+
const animationTarget = 1e3;
|
|
5638
|
+
let id = 0;
|
|
5639
|
+
function resetDistortingTransform(key, visualElement, values, sharedAnimationValues) {
|
|
5640
|
+
const { latestValues } = visualElement;
|
|
5641
|
+
if (latestValues[key]) {
|
|
5642
|
+
values[key] = latestValues[key];
|
|
5643
|
+
visualElement.setStaticValue(key, 0);
|
|
5644
|
+
if (sharedAnimationValues) {
|
|
5645
|
+
sharedAnimationValues[key] = 0;
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
5650
|
+
projectionNode.hasCheckedOptimisedAppear = true;
|
|
5651
|
+
if (projectionNode.root === projectionNode)
|
|
5652
|
+
return;
|
|
5653
|
+
const { visualElement } = projectionNode.options;
|
|
5654
|
+
if (!visualElement)
|
|
5655
|
+
return;
|
|
5656
|
+
const appearId = getOptimisedAppearId(visualElement);
|
|
5657
|
+
if (window.MotionHasOptimisedAnimation(appearId, "transform")) {
|
|
5658
|
+
const { layout, layoutId } = projectionNode.options;
|
|
5659
|
+
window.MotionCancelOptimisedAnimation(appearId, "transform", frame, !(layout || layoutId));
|
|
5660
|
+
}
|
|
5661
|
+
const { parent } = projectionNode;
|
|
5662
|
+
if (parent && !parent.hasCheckedOptimisedAppear) {
|
|
5663
|
+
cancelTreeOptimisedTransformAnimations(parent);
|
|
5664
|
+
}
|
|
5665
|
+
}
|
|
5666
|
+
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform }) {
|
|
5667
|
+
return class ProjectionNode {
|
|
5668
|
+
constructor(latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
|
|
5669
|
+
this.id = id++;
|
|
5670
|
+
this.animationId = 0;
|
|
5671
|
+
this.children = /* @__PURE__ */ new Set();
|
|
5672
|
+
this.options = {};
|
|
5673
|
+
this.isTreeAnimating = false;
|
|
5674
|
+
this.isAnimationBlocked = false;
|
|
5675
|
+
this.isLayoutDirty = false;
|
|
5676
|
+
this.isProjectionDirty = false;
|
|
5677
|
+
this.isSharedProjectionDirty = false;
|
|
5678
|
+
this.isTransformDirty = false;
|
|
5679
|
+
this.updateManuallyBlocked = false;
|
|
5680
|
+
this.updateBlockedByResize = false;
|
|
5681
|
+
this.isUpdating = false;
|
|
5682
|
+
this.isSVG = false;
|
|
5683
|
+
this.needsReset = false;
|
|
5684
|
+
this.shouldResetTransform = false;
|
|
5685
|
+
this.hasCheckedOptimisedAppear = false;
|
|
5686
|
+
this.treeScale = { x: 1, y: 1 };
|
|
5687
|
+
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
5688
|
+
this.hasTreeAnimated = false;
|
|
5689
|
+
this.updateScheduled = false;
|
|
5690
|
+
this.scheduleUpdate = () => this.update();
|
|
5691
|
+
this.projectionUpdateScheduled = false;
|
|
5692
|
+
this.checkUpdateFailed = () => {
|
|
5693
|
+
if (this.isUpdating) {
|
|
5694
|
+
this.isUpdating = false;
|
|
5695
|
+
this.clearAllSnapshots();
|
|
5696
|
+
}
|
|
5697
|
+
};
|
|
5698
|
+
this.updateProjection = () => {
|
|
5699
|
+
this.projectionUpdateScheduled = false;
|
|
5700
|
+
if (isDebug) {
|
|
5701
|
+
metrics.totalNodes = metrics.resolvedTargetDeltas = metrics.recalculatedProjection = 0;
|
|
5702
|
+
}
|
|
5703
|
+
this.nodes.forEach(propagateDirtyNodes);
|
|
5704
|
+
this.nodes.forEach(resolveTargetDelta);
|
|
5705
|
+
this.nodes.forEach(calcProjection);
|
|
5706
|
+
this.nodes.forEach(cleanDirtyNodes);
|
|
5707
|
+
if (isDebug) {
|
|
5708
|
+
window.MotionDebug.record(metrics);
|
|
5709
|
+
}
|
|
5710
|
+
};
|
|
5711
|
+
this.resolvedRelativeTargetAt = 0;
|
|
5712
|
+
this.hasProjected = false;
|
|
5713
|
+
this.isVisible = true;
|
|
5714
|
+
this.animationProgress = 0;
|
|
5715
|
+
this.sharedNodes = /* @__PURE__ */ new Map();
|
|
5716
|
+
this.latestValues = latestValues;
|
|
5717
|
+
this.root = parent ? parent.root || parent : this;
|
|
5718
|
+
this.path = parent ? [...parent.path, parent] : [];
|
|
5719
|
+
this.parent = parent;
|
|
5720
|
+
this.depth = parent ? parent.depth + 1 : 0;
|
|
5721
|
+
for (let i = 0; i < this.path.length; i++) {
|
|
5722
|
+
this.path[i].shouldResetTransform = true;
|
|
5723
|
+
}
|
|
5724
|
+
if (this.root === this)
|
|
5725
|
+
this.nodes = new FlatTree();
|
|
5726
|
+
}
|
|
5727
|
+
addEventListener(name, handler) {
|
|
5728
|
+
if (!this.eventHandlers.has(name)) {
|
|
5729
|
+
this.eventHandlers.set(name, new SubscriptionManager());
|
|
5730
|
+
}
|
|
5731
|
+
return this.eventHandlers.get(name).add(handler);
|
|
5732
|
+
}
|
|
5733
|
+
notifyListeners(name, ...args) {
|
|
5734
|
+
const subscriptionManager = this.eventHandlers.get(name);
|
|
5735
|
+
subscriptionManager && subscriptionManager.notify(...args);
|
|
5736
|
+
}
|
|
5737
|
+
hasListeners(name) {
|
|
5738
|
+
return this.eventHandlers.has(name);
|
|
5739
|
+
}
|
|
5740
|
+
/**
|
|
5741
|
+
* Lifecycles
|
|
5742
|
+
*/
|
|
5743
|
+
mount(instance, isLayoutDirty = this.root.hasTreeAnimated) {
|
|
5744
|
+
if (this.instance)
|
|
5745
|
+
return;
|
|
5746
|
+
this.isSVG = isSVGElement$2(instance);
|
|
5747
|
+
this.instance = instance;
|
|
5748
|
+
const { layoutId, layout, visualElement } = this.options;
|
|
5749
|
+
if (visualElement && !visualElement.current) {
|
|
5750
|
+
visualElement.mount(instance);
|
|
5751
|
+
}
|
|
5752
|
+
this.root.nodes.add(this);
|
|
5753
|
+
this.parent && this.parent.children.add(this);
|
|
5754
|
+
if (isLayoutDirty && (layout || layoutId)) {
|
|
5755
|
+
this.isLayoutDirty = true;
|
|
5756
|
+
}
|
|
5757
|
+
if (attachResizeListener) {
|
|
5758
|
+
let cancelDelay;
|
|
5759
|
+
const resizeUnblockUpdate = () => this.root.updateBlockedByResize = false;
|
|
5760
|
+
attachResizeListener(instance, () => {
|
|
5761
|
+
this.root.updateBlockedByResize = true;
|
|
5762
|
+
cancelDelay && cancelDelay();
|
|
5763
|
+
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
5764
|
+
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
5765
|
+
globalProjectionState.hasAnimatedSinceResize = false;
|
|
5766
|
+
this.nodes.forEach(finishAnimation);
|
|
5767
|
+
}
|
|
5768
|
+
});
|
|
5769
|
+
}
|
|
5770
|
+
if (layoutId) {
|
|
5771
|
+
this.root.registerSharedNode(layoutId, this);
|
|
5772
|
+
}
|
|
5773
|
+
if (this.options.animate !== false && visualElement && (layoutId || layout)) {
|
|
5774
|
+
this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeTargetChanged, layout: newLayout }) => {
|
|
5775
|
+
if (this.isTreeAnimationBlocked()) {
|
|
5776
|
+
this.target = void 0;
|
|
5777
|
+
this.relativeTarget = void 0;
|
|
5778
|
+
return;
|
|
5779
|
+
}
|
|
5780
|
+
const layoutTransition = this.options.transition || visualElement.getDefaultTransition() || defaultLayoutTransition;
|
|
5781
|
+
const { onLayoutAnimationStart, onLayoutAnimationComplete } = visualElement.getProps();
|
|
5782
|
+
const targetChanged = !this.targetLayout || !boxEqualsRounded(this.targetLayout, newLayout) || hasRelativeTargetChanged;
|
|
5783
|
+
const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeTargetChanged;
|
|
5784
|
+
if (this.options.layoutRoot || this.resumeFrom && this.resumeFrom.instance || hasOnlyRelativeTargetChanged || hasLayoutChanged && (targetChanged || !this.currentAnimation)) {
|
|
5785
|
+
if (this.resumeFrom) {
|
|
5786
|
+
this.resumingFrom = this.resumeFrom;
|
|
5787
|
+
this.resumingFrom.resumingFrom = void 0;
|
|
5788
|
+
}
|
|
5789
|
+
this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
|
|
5790
|
+
const animationOptions = {
|
|
5791
|
+
...getValueTransition(layoutTransition, "layout"),
|
|
5792
|
+
onPlay: onLayoutAnimationStart,
|
|
5793
|
+
onComplete: onLayoutAnimationComplete
|
|
5794
|
+
};
|
|
5795
|
+
if (visualElement.shouldReduceMotion || this.options.layoutRoot) {
|
|
5796
|
+
animationOptions.delay = 0;
|
|
5797
|
+
animationOptions.type = false;
|
|
5798
|
+
}
|
|
5799
|
+
this.startAnimation(animationOptions);
|
|
5800
|
+
} else {
|
|
5801
|
+
if (!hasLayoutChanged) {
|
|
5802
|
+
finishAnimation(this);
|
|
5803
|
+
}
|
|
5804
|
+
if (this.isLead() && this.options.onExitComplete) {
|
|
5805
|
+
this.options.onExitComplete();
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
this.targetLayout = newLayout;
|
|
5809
|
+
});
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
unmount() {
|
|
5813
|
+
this.options.layoutId && this.willUpdate();
|
|
5814
|
+
this.root.nodes.remove(this);
|
|
5815
|
+
const stack = this.getStack();
|
|
5816
|
+
stack && stack.remove(this);
|
|
5817
|
+
this.parent && this.parent.children.delete(this);
|
|
5818
|
+
this.instance = void 0;
|
|
5819
|
+
cancelFrame(this.updateProjection);
|
|
5820
|
+
}
|
|
5821
|
+
// only on the root
|
|
5822
|
+
blockUpdate() {
|
|
5823
|
+
this.updateManuallyBlocked = true;
|
|
5824
|
+
}
|
|
5825
|
+
unblockUpdate() {
|
|
5826
|
+
this.updateManuallyBlocked = false;
|
|
5827
|
+
}
|
|
5828
|
+
isUpdateBlocked() {
|
|
5829
|
+
return this.updateManuallyBlocked || this.updateBlockedByResize;
|
|
5830
|
+
}
|
|
5831
|
+
isTreeAnimationBlocked() {
|
|
5832
|
+
return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || false;
|
|
5833
|
+
}
|
|
5834
|
+
// Note: currently only running on root node
|
|
5835
|
+
startUpdate() {
|
|
5836
|
+
if (this.isUpdateBlocked())
|
|
5837
|
+
return;
|
|
5838
|
+
this.isUpdating = true;
|
|
5839
|
+
this.nodes && this.nodes.forEach(resetSkewAndRotation);
|
|
5840
|
+
this.animationId++;
|
|
5841
|
+
}
|
|
5842
|
+
getTransformTemplate() {
|
|
5843
|
+
const { visualElement } = this.options;
|
|
5844
|
+
return visualElement && visualElement.getProps().transformTemplate;
|
|
5845
|
+
}
|
|
5846
|
+
willUpdate(shouldNotifyListeners = true) {
|
|
5847
|
+
this.root.hasTreeAnimated = true;
|
|
5848
|
+
if (this.root.isUpdateBlocked()) {
|
|
5849
|
+
this.options.onExitComplete && this.options.onExitComplete();
|
|
5850
|
+
return;
|
|
5851
|
+
}
|
|
5852
|
+
if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear) {
|
|
5853
|
+
cancelTreeOptimisedTransformAnimations(this);
|
|
5854
|
+
}
|
|
5855
|
+
!this.root.isUpdating && this.root.startUpdate();
|
|
5856
|
+
if (this.isLayoutDirty)
|
|
5857
|
+
return;
|
|
5858
|
+
this.isLayoutDirty = true;
|
|
5859
|
+
for (let i = 0; i < this.path.length; i++) {
|
|
5860
|
+
const node = this.path[i];
|
|
5861
|
+
node.shouldResetTransform = true;
|
|
5862
|
+
node.updateScroll("snapshot");
|
|
5863
|
+
if (node.options.layoutRoot) {
|
|
5864
|
+
node.willUpdate(false);
|
|
5865
|
+
}
|
|
5866
|
+
}
|
|
5867
|
+
const { layoutId, layout } = this.options;
|
|
5868
|
+
if (layoutId === void 0 && !layout)
|
|
5869
|
+
return;
|
|
5870
|
+
const transformTemplate = this.getTransformTemplate();
|
|
5871
|
+
this.prevTransformTemplateValue = transformTemplate ? transformTemplate(this.latestValues, "") : void 0;
|
|
5872
|
+
this.updateSnapshot();
|
|
5873
|
+
shouldNotifyListeners && this.notifyListeners("willUpdate");
|
|
5874
|
+
}
|
|
5875
|
+
update() {
|
|
5876
|
+
this.updateScheduled = false;
|
|
5877
|
+
const updateWasBlocked = this.isUpdateBlocked();
|
|
5878
|
+
if (updateWasBlocked) {
|
|
5879
|
+
this.unblockUpdate();
|
|
5880
|
+
this.clearAllSnapshots();
|
|
5881
|
+
this.nodes.forEach(clearMeasurements);
|
|
5882
|
+
return;
|
|
5883
|
+
}
|
|
5884
|
+
if (!this.isUpdating) {
|
|
5885
|
+
this.nodes.forEach(clearIsLayoutDirty);
|
|
5886
|
+
}
|
|
5887
|
+
this.isUpdating = false;
|
|
5888
|
+
this.nodes.forEach(resetTransformStyle);
|
|
5889
|
+
this.nodes.forEach(updateLayout);
|
|
5890
|
+
this.nodes.forEach(notifyLayoutUpdate);
|
|
5891
|
+
this.clearAllSnapshots();
|
|
5892
|
+
const now2 = time.now();
|
|
5893
|
+
frameData.delta = clamp(0, 1e3 / 60, now2 - frameData.timestamp);
|
|
5894
|
+
frameData.timestamp = now2;
|
|
5895
|
+
frameData.isProcessing = true;
|
|
5896
|
+
frameSteps.update.process(frameData);
|
|
5897
|
+
frameSteps.preRender.process(frameData);
|
|
5898
|
+
frameSteps.render.process(frameData);
|
|
5899
|
+
frameData.isProcessing = false;
|
|
5900
|
+
}
|
|
5901
|
+
didUpdate() {
|
|
5902
|
+
if (!this.updateScheduled) {
|
|
5903
|
+
this.updateScheduled = true;
|
|
5904
|
+
microtask.read(this.scheduleUpdate);
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
clearAllSnapshots() {
|
|
5908
|
+
this.nodes.forEach(clearSnapshot);
|
|
5909
|
+
this.sharedNodes.forEach(removeLeadSnapshots);
|
|
5910
|
+
}
|
|
5911
|
+
scheduleUpdateProjection() {
|
|
5912
|
+
if (!this.projectionUpdateScheduled) {
|
|
5913
|
+
this.projectionUpdateScheduled = true;
|
|
5914
|
+
frame.preRender(this.updateProjection, false, true);
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
scheduleCheckAfterUnmount() {
|
|
5918
|
+
frame.postRender(() => {
|
|
5919
|
+
if (this.isLayoutDirty) {
|
|
5920
|
+
this.root.didUpdate();
|
|
5921
|
+
} else {
|
|
5922
|
+
this.root.checkUpdateFailed();
|
|
5923
|
+
}
|
|
5924
|
+
});
|
|
5925
|
+
}
|
|
5926
|
+
/**
|
|
5927
|
+
* Update measurements
|
|
5928
|
+
*/
|
|
5929
|
+
updateSnapshot() {
|
|
5930
|
+
if (this.snapshot || !this.instance)
|
|
5931
|
+
return;
|
|
5932
|
+
this.snapshot = this.measure();
|
|
5933
|
+
}
|
|
5934
|
+
updateLayout() {
|
|
5935
|
+
if (!this.instance)
|
|
5936
|
+
return;
|
|
5937
|
+
this.updateScroll();
|
|
5938
|
+
if (!(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty) {
|
|
5939
|
+
return;
|
|
5940
|
+
}
|
|
5941
|
+
if (this.resumeFrom && !this.resumeFrom.instance) {
|
|
5942
|
+
for (let i = 0; i < this.path.length; i++) {
|
|
5943
|
+
const node = this.path[i];
|
|
5944
|
+
node.updateScroll();
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5947
|
+
const prevLayout = this.layout;
|
|
5948
|
+
this.layout = this.measure(false);
|
|
5949
|
+
this.layoutCorrected = createBox();
|
|
5950
|
+
this.isLayoutDirty = false;
|
|
5951
|
+
this.projectionDelta = void 0;
|
|
5952
|
+
this.notifyListeners("measure", this.layout.layoutBox);
|
|
5953
|
+
const { visualElement } = this.options;
|
|
5954
|
+
visualElement && visualElement.notify("LayoutMeasure", this.layout.layoutBox, prevLayout ? prevLayout.layoutBox : void 0);
|
|
5955
|
+
}
|
|
5956
|
+
updateScroll(phase = "measure") {
|
|
5957
|
+
let needsMeasurement = Boolean(this.options.layoutScroll && this.instance);
|
|
5958
|
+
if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === phase) {
|
|
5959
|
+
needsMeasurement = false;
|
|
5960
|
+
}
|
|
5961
|
+
if (needsMeasurement) {
|
|
5962
|
+
const isRoot = checkIsScrollRoot(this.instance);
|
|
5963
|
+
this.scroll = {
|
|
5964
|
+
animationId: this.root.animationId,
|
|
5965
|
+
phase,
|
|
5966
|
+
isRoot,
|
|
5967
|
+
offset: measureScroll(this.instance),
|
|
5968
|
+
wasRoot: this.scroll ? this.scroll.isRoot : isRoot
|
|
5969
|
+
};
|
|
5970
|
+
}
|
|
5971
|
+
}
|
|
5972
|
+
resetTransform() {
|
|
5973
|
+
if (!resetTransform)
|
|
5974
|
+
return;
|
|
5975
|
+
const isResetRequested = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout;
|
|
5976
|
+
const hasProjection = this.projectionDelta && !isDeltaZero(this.projectionDelta);
|
|
5977
|
+
const transformTemplate = this.getTransformTemplate();
|
|
5978
|
+
const transformTemplateValue = transformTemplate ? transformTemplate(this.latestValues, "") : void 0;
|
|
5979
|
+
const transformTemplateHasChanged = transformTemplateValue !== this.prevTransformTemplateValue;
|
|
5980
|
+
if (isResetRequested && (hasProjection || hasTransform(this.latestValues) || transformTemplateHasChanged)) {
|
|
5981
|
+
resetTransform(this.instance, transformTemplateValue);
|
|
5982
|
+
this.shouldResetTransform = false;
|
|
5983
|
+
this.scheduleRender();
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
measure(removeTransform = true) {
|
|
5987
|
+
const pageBox = this.measurePageBox();
|
|
5988
|
+
let layoutBox = this.removeElementScroll(pageBox);
|
|
5989
|
+
if (removeTransform) {
|
|
5990
|
+
layoutBox = this.removeTransform(layoutBox);
|
|
5991
|
+
}
|
|
5992
|
+
roundBox(layoutBox);
|
|
5993
|
+
return {
|
|
5994
|
+
animationId: this.root.animationId,
|
|
5995
|
+
measuredBox: pageBox,
|
|
5996
|
+
layoutBox,
|
|
5997
|
+
latestValues: {},
|
|
5998
|
+
source: this.id
|
|
5999
|
+
};
|
|
6000
|
+
}
|
|
6001
|
+
measurePageBox() {
|
|
6002
|
+
var _a;
|
|
6003
|
+
const { visualElement } = this.options;
|
|
6004
|
+
if (!visualElement)
|
|
6005
|
+
return createBox();
|
|
6006
|
+
const box = visualElement.measureViewportBox();
|
|
6007
|
+
const wasInScrollRoot = ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) || this.path.some(checkNodeWasScrollRoot);
|
|
6008
|
+
if (!wasInScrollRoot) {
|
|
6009
|
+
const { scroll: scroll2 } = this.root;
|
|
6010
|
+
if (scroll2) {
|
|
6011
|
+
translateAxis(box.x, scroll2.offset.x);
|
|
6012
|
+
translateAxis(box.y, scroll2.offset.y);
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
return box;
|
|
6016
|
+
}
|
|
6017
|
+
removeElementScroll(box) {
|
|
6018
|
+
var _a;
|
|
6019
|
+
const boxWithoutScroll = createBox();
|
|
6020
|
+
copyBoxInto(boxWithoutScroll, box);
|
|
6021
|
+
if ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) {
|
|
6022
|
+
return boxWithoutScroll;
|
|
6023
|
+
}
|
|
6024
|
+
for (let i = 0; i < this.path.length; i++) {
|
|
6025
|
+
const node = this.path[i];
|
|
6026
|
+
const { scroll: scroll2, options } = node;
|
|
6027
|
+
if (node !== this.root && scroll2 && options.layoutScroll) {
|
|
6028
|
+
if (scroll2.wasRoot) {
|
|
6029
|
+
copyBoxInto(boxWithoutScroll, box);
|
|
6030
|
+
}
|
|
6031
|
+
translateAxis(boxWithoutScroll.x, scroll2.offset.x);
|
|
6032
|
+
translateAxis(boxWithoutScroll.y, scroll2.offset.y);
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
return boxWithoutScroll;
|
|
6036
|
+
}
|
|
6037
|
+
applyTransform(box, transformOnly = false) {
|
|
6038
|
+
const withTransforms = createBox();
|
|
6039
|
+
copyBoxInto(withTransforms, box);
|
|
6040
|
+
for (let i = 0; i < this.path.length; i++) {
|
|
6041
|
+
const node = this.path[i];
|
|
6042
|
+
if (!transformOnly && node.options.layoutScroll && node.scroll && node !== node.root) {
|
|
6043
|
+
transformBox(withTransforms, {
|
|
6044
|
+
x: -node.scroll.offset.x,
|
|
6045
|
+
y: -node.scroll.offset.y
|
|
6046
|
+
});
|
|
6047
|
+
}
|
|
6048
|
+
if (!hasTransform(node.latestValues))
|
|
6049
|
+
continue;
|
|
6050
|
+
transformBox(withTransforms, node.latestValues);
|
|
6051
|
+
}
|
|
6052
|
+
if (hasTransform(this.latestValues)) {
|
|
6053
|
+
transformBox(withTransforms, this.latestValues);
|
|
6054
|
+
}
|
|
6055
|
+
return withTransforms;
|
|
6056
|
+
}
|
|
6057
|
+
removeTransform(box) {
|
|
6058
|
+
const boxWithoutTransform = createBox();
|
|
6059
|
+
copyBoxInto(boxWithoutTransform, box);
|
|
6060
|
+
for (let i = 0; i < this.path.length; i++) {
|
|
6061
|
+
const node = this.path[i];
|
|
6062
|
+
if (!node.instance)
|
|
6063
|
+
continue;
|
|
6064
|
+
if (!hasTransform(node.latestValues))
|
|
6065
|
+
continue;
|
|
6066
|
+
hasScale(node.latestValues) && node.updateSnapshot();
|
|
6067
|
+
const sourceBox = createBox();
|
|
6068
|
+
const nodeBox = node.measurePageBox();
|
|
6069
|
+
copyBoxInto(sourceBox, nodeBox);
|
|
6070
|
+
removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot ? node.snapshot.layoutBox : void 0, sourceBox);
|
|
6071
|
+
}
|
|
6072
|
+
if (hasTransform(this.latestValues)) {
|
|
6073
|
+
removeBoxTransforms(boxWithoutTransform, this.latestValues);
|
|
6074
|
+
}
|
|
6075
|
+
return boxWithoutTransform;
|
|
6076
|
+
}
|
|
6077
|
+
setTargetDelta(delta) {
|
|
6078
|
+
this.targetDelta = delta;
|
|
6079
|
+
this.root.scheduleUpdateProjection();
|
|
6080
|
+
this.isProjectionDirty = true;
|
|
6081
|
+
}
|
|
6082
|
+
setOptions(options) {
|
|
6083
|
+
this.options = {
|
|
6084
|
+
...this.options,
|
|
6085
|
+
...options,
|
|
6086
|
+
crossfade: options.crossfade !== void 0 ? options.crossfade : true
|
|
6087
|
+
};
|
|
6088
|
+
}
|
|
6089
|
+
clearMeasurements() {
|
|
6090
|
+
this.scroll = void 0;
|
|
6091
|
+
this.layout = void 0;
|
|
6092
|
+
this.snapshot = void 0;
|
|
6093
|
+
this.prevTransformTemplateValue = void 0;
|
|
6094
|
+
this.targetDelta = void 0;
|
|
6095
|
+
this.target = void 0;
|
|
6096
|
+
this.isLayoutDirty = false;
|
|
6097
|
+
}
|
|
6098
|
+
forceRelativeParentToResolveTarget() {
|
|
6099
|
+
if (!this.relativeParent)
|
|
6100
|
+
return;
|
|
6101
|
+
if (this.relativeParent.resolvedRelativeTargetAt !== frameData.timestamp) {
|
|
6102
|
+
this.relativeParent.resolveTargetDelta(true);
|
|
6103
|
+
}
|
|
6104
|
+
}
|
|
6105
|
+
resolveTargetDelta(forceRecalculation = false) {
|
|
6106
|
+
var _a;
|
|
6107
|
+
const lead = this.getLead();
|
|
6108
|
+
this.isProjectionDirty || (this.isProjectionDirty = lead.isProjectionDirty);
|
|
6109
|
+
this.isTransformDirty || (this.isTransformDirty = lead.isTransformDirty);
|
|
6110
|
+
this.isSharedProjectionDirty || (this.isSharedProjectionDirty = lead.isSharedProjectionDirty);
|
|
6111
|
+
const isShared = Boolean(this.resumingFrom) || this !== lead;
|
|
6112
|
+
const canSkip = !(forceRecalculation || isShared && this.isSharedProjectionDirty || this.isProjectionDirty || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty) || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize);
|
|
6113
|
+
if (canSkip)
|
|
6114
|
+
return;
|
|
6115
|
+
const { layout, layoutId } = this.options;
|
|
6116
|
+
if (!this.layout || !(layout || layoutId))
|
|
6117
|
+
return;
|
|
6118
|
+
this.resolvedRelativeTargetAt = frameData.timestamp;
|
|
6119
|
+
if (!this.targetDelta && !this.relativeTarget) {
|
|
6120
|
+
const relativeParent = this.getClosestProjectingParent();
|
|
6121
|
+
if (relativeParent && relativeParent.layout && this.animationProgress !== 1) {
|
|
6122
|
+
this.relativeParent = relativeParent;
|
|
6123
|
+
this.forceRelativeParentToResolveTarget();
|
|
6124
|
+
this.relativeTarget = createBox();
|
|
6125
|
+
this.relativeTargetOrigin = createBox();
|
|
6126
|
+
calcRelativePosition(this.relativeTargetOrigin, this.layout.layoutBox, relativeParent.layout.layoutBox);
|
|
6127
|
+
copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
|
|
6128
|
+
} else {
|
|
6129
|
+
this.relativeParent = this.relativeTarget = void 0;
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
if (!this.relativeTarget && !this.targetDelta)
|
|
6133
|
+
return;
|
|
6134
|
+
if (!this.target) {
|
|
6135
|
+
this.target = createBox();
|
|
6136
|
+
this.targetWithTransforms = createBox();
|
|
6137
|
+
}
|
|
6138
|
+
if (this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target) {
|
|
6139
|
+
this.forceRelativeParentToResolveTarget();
|
|
6140
|
+
calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
|
|
6141
|
+
} else if (this.targetDelta) {
|
|
6142
|
+
if (Boolean(this.resumingFrom)) {
|
|
6143
|
+
this.target = this.applyTransform(this.layout.layoutBox);
|
|
6144
|
+
} else {
|
|
6145
|
+
copyBoxInto(this.target, this.layout.layoutBox);
|
|
6146
|
+
}
|
|
6147
|
+
applyBoxDelta(this.target, this.targetDelta);
|
|
6148
|
+
} else {
|
|
6149
|
+
copyBoxInto(this.target, this.layout.layoutBox);
|
|
6150
|
+
}
|
|
6151
|
+
if (this.attemptToResolveRelativeTarget) {
|
|
6152
|
+
this.attemptToResolveRelativeTarget = false;
|
|
6153
|
+
const relativeParent = this.getClosestProjectingParent();
|
|
6154
|
+
if (relativeParent && Boolean(relativeParent.resumingFrom) === Boolean(this.resumingFrom) && !relativeParent.options.layoutScroll && relativeParent.target && this.animationProgress !== 1) {
|
|
6155
|
+
this.relativeParent = relativeParent;
|
|
6156
|
+
this.forceRelativeParentToResolveTarget();
|
|
6157
|
+
this.relativeTarget = createBox();
|
|
6158
|
+
this.relativeTargetOrigin = createBox();
|
|
6159
|
+
calcRelativePosition(this.relativeTargetOrigin, this.target, relativeParent.target);
|
|
6160
|
+
copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
|
|
6161
|
+
} else {
|
|
6162
|
+
this.relativeParent = this.relativeTarget = void 0;
|
|
6163
|
+
}
|
|
6164
|
+
}
|
|
6165
|
+
if (isDebug) {
|
|
6166
|
+
metrics.resolvedTargetDeltas++;
|
|
6167
|
+
}
|
|
6168
|
+
}
|
|
6169
|
+
getClosestProjectingParent() {
|
|
6170
|
+
if (!this.parent || hasScale(this.parent.latestValues) || has2DTranslate(this.parent.latestValues)) {
|
|
6171
|
+
return void 0;
|
|
6172
|
+
}
|
|
6173
|
+
if (this.parent.isProjecting()) {
|
|
6174
|
+
return this.parent;
|
|
6175
|
+
} else {
|
|
6176
|
+
return this.parent.getClosestProjectingParent();
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6179
|
+
isProjecting() {
|
|
6180
|
+
return Boolean((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout);
|
|
6181
|
+
}
|
|
6182
|
+
calcProjection() {
|
|
6183
|
+
var _a;
|
|
6184
|
+
const lead = this.getLead();
|
|
6185
|
+
const isShared = Boolean(this.resumingFrom) || this !== lead;
|
|
6186
|
+
let canSkip = true;
|
|
6187
|
+
if (this.isProjectionDirty || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty)) {
|
|
6188
|
+
canSkip = false;
|
|
6189
|
+
}
|
|
6190
|
+
if (isShared && (this.isSharedProjectionDirty || this.isTransformDirty)) {
|
|
6191
|
+
canSkip = false;
|
|
6192
|
+
}
|
|
6193
|
+
if (this.resolvedRelativeTargetAt === frameData.timestamp) {
|
|
6194
|
+
canSkip = false;
|
|
6195
|
+
}
|
|
6196
|
+
if (canSkip)
|
|
6197
|
+
return;
|
|
6198
|
+
const { layout, layoutId } = this.options;
|
|
6199
|
+
this.isTreeAnimating = Boolean(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation);
|
|
6200
|
+
if (!this.isTreeAnimating) {
|
|
6201
|
+
this.targetDelta = this.relativeTarget = void 0;
|
|
6202
|
+
}
|
|
6203
|
+
if (!this.layout || !(layout || layoutId))
|
|
6204
|
+
return;
|
|
6205
|
+
copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
|
|
6206
|
+
const prevTreeScaleX = this.treeScale.x;
|
|
6207
|
+
const prevTreeScaleY = this.treeScale.y;
|
|
6208
|
+
applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared);
|
|
6209
|
+
if (lead.layout && !lead.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1)) {
|
|
6210
|
+
lead.target = lead.layout.layoutBox;
|
|
6211
|
+
lead.targetWithTransforms = createBox();
|
|
6212
|
+
}
|
|
6213
|
+
const { target } = lead;
|
|
6214
|
+
if (!target) {
|
|
6215
|
+
if (this.prevProjectionDelta) {
|
|
6216
|
+
this.createProjectionDeltas();
|
|
6217
|
+
this.scheduleRender();
|
|
6218
|
+
}
|
|
6219
|
+
return;
|
|
6220
|
+
}
|
|
6221
|
+
if (!this.projectionDelta || !this.prevProjectionDelta) {
|
|
6222
|
+
this.createProjectionDeltas();
|
|
6223
|
+
} else {
|
|
6224
|
+
copyAxisDeltaInto(this.prevProjectionDelta.x, this.projectionDelta.x);
|
|
6225
|
+
copyAxisDeltaInto(this.prevProjectionDelta.y, this.projectionDelta.y);
|
|
6226
|
+
}
|
|
6227
|
+
calcBoxDelta(this.projectionDelta, this.layoutCorrected, target, this.latestValues);
|
|
6228
|
+
if (this.treeScale.x !== prevTreeScaleX || this.treeScale.y !== prevTreeScaleY || !axisDeltaEquals(this.projectionDelta.x, this.prevProjectionDelta.x) || !axisDeltaEquals(this.projectionDelta.y, this.prevProjectionDelta.y)) {
|
|
6229
|
+
this.hasProjected = true;
|
|
6230
|
+
this.scheduleRender();
|
|
6231
|
+
this.notifyListeners("projectionUpdate", target);
|
|
6232
|
+
}
|
|
6233
|
+
if (isDebug) {
|
|
6234
|
+
metrics.recalculatedProjection++;
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
hide() {
|
|
6238
|
+
this.isVisible = false;
|
|
6239
|
+
}
|
|
6240
|
+
show() {
|
|
6241
|
+
this.isVisible = true;
|
|
6242
|
+
}
|
|
6243
|
+
scheduleRender(notifyAll2 = true) {
|
|
6244
|
+
var _a;
|
|
6245
|
+
(_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.scheduleRender();
|
|
6246
|
+
if (notifyAll2) {
|
|
6247
|
+
const stack = this.getStack();
|
|
6248
|
+
stack && stack.scheduleRender();
|
|
6249
|
+
}
|
|
6250
|
+
if (this.resumingFrom && !this.resumingFrom.instance) {
|
|
6251
|
+
this.resumingFrom = void 0;
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
createProjectionDeltas() {
|
|
6255
|
+
this.prevProjectionDelta = createDelta();
|
|
6256
|
+
this.projectionDelta = createDelta();
|
|
6257
|
+
this.projectionDeltaWithTransform = createDelta();
|
|
6258
|
+
}
|
|
6259
|
+
setAnimationOrigin(delta, hasOnlyRelativeTargetChanged = false) {
|
|
6260
|
+
const snapshot = this.snapshot;
|
|
6261
|
+
const snapshotLatestValues = snapshot ? snapshot.latestValues : {};
|
|
6262
|
+
const mixedValues = { ...this.latestValues };
|
|
6263
|
+
const targetDelta = createDelta();
|
|
6264
|
+
if (!this.relativeParent || !this.relativeParent.options.layoutRoot) {
|
|
6265
|
+
this.relativeTarget = this.relativeTargetOrigin = void 0;
|
|
6266
|
+
}
|
|
6267
|
+
this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
|
|
6268
|
+
const relativeLayout = createBox();
|
|
6269
|
+
const snapshotSource = snapshot ? snapshot.source : void 0;
|
|
6270
|
+
const layoutSource = this.layout ? this.layout.source : void 0;
|
|
6271
|
+
const isSharedLayoutAnimation = snapshotSource !== layoutSource;
|
|
6272
|
+
const stack = this.getStack();
|
|
6273
|
+
const isOnlyMember = !stack || stack.members.length <= 1;
|
|
6274
|
+
const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation && !isOnlyMember && this.options.crossfade === true && !this.path.some(hasOpacityCrossfade));
|
|
6275
|
+
this.animationProgress = 0;
|
|
6276
|
+
let prevRelativeTarget;
|
|
6277
|
+
this.mixTargetDelta = (latest) => {
|
|
6278
|
+
const progress2 = latest / 1e3;
|
|
6279
|
+
mixAxisDelta(targetDelta.x, delta.x, progress2);
|
|
6280
|
+
mixAxisDelta(targetDelta.y, delta.y, progress2);
|
|
6281
|
+
this.setTargetDelta(targetDelta);
|
|
6282
|
+
if (this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout) {
|
|
6283
|
+
calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
|
|
6284
|
+
mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress2);
|
|
6285
|
+
if (prevRelativeTarget && boxEquals(this.relativeTarget, prevRelativeTarget)) {
|
|
6286
|
+
this.isProjectionDirty = false;
|
|
6287
|
+
}
|
|
6288
|
+
if (!prevRelativeTarget)
|
|
6289
|
+
prevRelativeTarget = createBox();
|
|
6290
|
+
copyBoxInto(prevRelativeTarget, this.relativeTarget);
|
|
6291
|
+
}
|
|
6292
|
+
if (isSharedLayoutAnimation) {
|
|
6293
|
+
this.animationValues = mixedValues;
|
|
6294
|
+
mixValues(mixedValues, snapshotLatestValues, this.latestValues, progress2, shouldCrossfadeOpacity, isOnlyMember);
|
|
6295
|
+
}
|
|
6296
|
+
this.root.scheduleUpdateProjection();
|
|
6297
|
+
this.scheduleRender();
|
|
6298
|
+
this.animationProgress = progress2;
|
|
6299
|
+
};
|
|
6300
|
+
this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
|
|
6301
|
+
}
|
|
6302
|
+
startAnimation(options) {
|
|
6303
|
+
this.notifyListeners("animationStart");
|
|
6304
|
+
this.currentAnimation && this.currentAnimation.stop();
|
|
6305
|
+
if (this.resumingFrom && this.resumingFrom.currentAnimation) {
|
|
6306
|
+
this.resumingFrom.currentAnimation.stop();
|
|
6307
|
+
}
|
|
6308
|
+
if (this.pendingAnimation) {
|
|
6309
|
+
cancelFrame(this.pendingAnimation);
|
|
6310
|
+
this.pendingAnimation = void 0;
|
|
6311
|
+
}
|
|
6312
|
+
this.pendingAnimation = frame.update(() => {
|
|
6313
|
+
globalProjectionState.hasAnimatedSinceResize = true;
|
|
6314
|
+
this.currentAnimation = animateSingleValue(0, animationTarget, {
|
|
6315
|
+
...options,
|
|
6316
|
+
onUpdate: (latest) => {
|
|
6317
|
+
this.mixTargetDelta(latest);
|
|
6318
|
+
options.onUpdate && options.onUpdate(latest);
|
|
6319
|
+
},
|
|
6320
|
+
onComplete: () => {
|
|
6321
|
+
options.onComplete && options.onComplete();
|
|
6322
|
+
this.completeAnimation();
|
|
6323
|
+
}
|
|
6324
|
+
});
|
|
6325
|
+
if (this.resumingFrom) {
|
|
6326
|
+
this.resumingFrom.currentAnimation = this.currentAnimation;
|
|
6327
|
+
}
|
|
6328
|
+
this.pendingAnimation = void 0;
|
|
6329
|
+
});
|
|
6330
|
+
}
|
|
6331
|
+
completeAnimation() {
|
|
6332
|
+
if (this.resumingFrom) {
|
|
6333
|
+
this.resumingFrom.currentAnimation = void 0;
|
|
6334
|
+
this.resumingFrom.preserveOpacity = void 0;
|
|
6335
|
+
}
|
|
6336
|
+
const stack = this.getStack();
|
|
6337
|
+
stack && stack.exitAnimationComplete();
|
|
6338
|
+
this.resumingFrom = this.currentAnimation = this.animationValues = void 0;
|
|
6339
|
+
this.notifyListeners("animationComplete");
|
|
6340
|
+
}
|
|
6341
|
+
finishAnimation() {
|
|
6342
|
+
if (this.currentAnimation) {
|
|
6343
|
+
this.mixTargetDelta && this.mixTargetDelta(animationTarget);
|
|
6344
|
+
this.currentAnimation.stop();
|
|
6345
|
+
}
|
|
6346
|
+
this.completeAnimation();
|
|
6347
|
+
}
|
|
6348
|
+
applyTransformsToTarget() {
|
|
6349
|
+
const lead = this.getLead();
|
|
6350
|
+
let { targetWithTransforms, target, layout, latestValues } = lead;
|
|
6351
|
+
if (!targetWithTransforms || !target || !layout)
|
|
6352
|
+
return;
|
|
6353
|
+
if (this !== lead && this.layout && layout && shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
|
|
6354
|
+
target = this.target || createBox();
|
|
6355
|
+
const xLength = calcLength(this.layout.layoutBox.x);
|
|
6356
|
+
target.x.min = lead.target.x.min;
|
|
6357
|
+
target.x.max = target.x.min + xLength;
|
|
6358
|
+
const yLength = calcLength(this.layout.layoutBox.y);
|
|
6359
|
+
target.y.min = lead.target.y.min;
|
|
6360
|
+
target.y.max = target.y.min + yLength;
|
|
6361
|
+
}
|
|
6362
|
+
copyBoxInto(targetWithTransforms, target);
|
|
6363
|
+
transformBox(targetWithTransforms, latestValues);
|
|
6364
|
+
calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
|
|
6365
|
+
}
|
|
6366
|
+
registerSharedNode(layoutId, node) {
|
|
6367
|
+
if (!this.sharedNodes.has(layoutId)) {
|
|
6368
|
+
this.sharedNodes.set(layoutId, new NodeStack());
|
|
6369
|
+
}
|
|
6370
|
+
const stack = this.sharedNodes.get(layoutId);
|
|
6371
|
+
stack.add(node);
|
|
6372
|
+
const config = node.options.initialPromotionConfig;
|
|
6373
|
+
node.promote({
|
|
6374
|
+
transition: config ? config.transition : void 0,
|
|
6375
|
+
preserveFollowOpacity: config && config.shouldPreserveFollowOpacity ? config.shouldPreserveFollowOpacity(node) : void 0
|
|
6376
|
+
});
|
|
6377
|
+
}
|
|
6378
|
+
isLead() {
|
|
6379
|
+
const stack = this.getStack();
|
|
6380
|
+
return stack ? stack.lead === this : true;
|
|
6381
|
+
}
|
|
6382
|
+
getLead() {
|
|
6383
|
+
var _a;
|
|
6384
|
+
const { layoutId } = this.options;
|
|
6385
|
+
return layoutId ? ((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.lead) || this : this;
|
|
6386
|
+
}
|
|
6387
|
+
getPrevLead() {
|
|
6388
|
+
var _a;
|
|
6389
|
+
const { layoutId } = this.options;
|
|
6390
|
+
return layoutId ? (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.prevLead : void 0;
|
|
6391
|
+
}
|
|
6392
|
+
getStack() {
|
|
6393
|
+
const { layoutId } = this.options;
|
|
6394
|
+
if (layoutId)
|
|
6395
|
+
return this.root.sharedNodes.get(layoutId);
|
|
6396
|
+
}
|
|
6397
|
+
promote({ needsReset, transition, preserveFollowOpacity } = {}) {
|
|
6398
|
+
const stack = this.getStack();
|
|
6399
|
+
if (stack)
|
|
6400
|
+
stack.promote(this, preserveFollowOpacity);
|
|
6401
|
+
if (needsReset) {
|
|
6402
|
+
this.projectionDelta = void 0;
|
|
6403
|
+
this.needsReset = true;
|
|
6404
|
+
}
|
|
6405
|
+
if (transition)
|
|
6406
|
+
this.setOptions({ transition });
|
|
6407
|
+
}
|
|
6408
|
+
relegate() {
|
|
6409
|
+
const stack = this.getStack();
|
|
6410
|
+
if (stack) {
|
|
6411
|
+
return stack.relegate(this);
|
|
6412
|
+
} else {
|
|
6413
|
+
return false;
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
resetSkewAndRotation() {
|
|
6417
|
+
const { visualElement } = this.options;
|
|
6418
|
+
if (!visualElement)
|
|
6419
|
+
return;
|
|
6420
|
+
let hasDistortingTransform = false;
|
|
6421
|
+
const { latestValues } = visualElement;
|
|
6422
|
+
if (latestValues.z || latestValues.rotate || latestValues.rotateX || latestValues.rotateY || latestValues.rotateZ || latestValues.skewX || latestValues.skewY) {
|
|
6423
|
+
hasDistortingTransform = true;
|
|
6424
|
+
}
|
|
6425
|
+
if (!hasDistortingTransform)
|
|
6426
|
+
return;
|
|
6427
|
+
const resetValues = {};
|
|
6428
|
+
if (latestValues.z) {
|
|
6429
|
+
resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
|
|
6430
|
+
}
|
|
6431
|
+
for (let i = 0; i < transformAxes.length; i++) {
|
|
6432
|
+
resetDistortingTransform(`rotate${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
|
|
6433
|
+
resetDistortingTransform(`skew${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
|
|
6434
|
+
}
|
|
6435
|
+
visualElement.render();
|
|
6436
|
+
for (const key in resetValues) {
|
|
6437
|
+
visualElement.setStaticValue(key, resetValues[key]);
|
|
6438
|
+
if (this.animationValues) {
|
|
6439
|
+
this.animationValues[key] = resetValues[key];
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
visualElement.scheduleRender();
|
|
6443
|
+
}
|
|
6444
|
+
getProjectionStyles(styleProp) {
|
|
6445
|
+
var _a, _b;
|
|
6446
|
+
if (!this.instance || this.isSVG)
|
|
6447
|
+
return void 0;
|
|
6448
|
+
if (!this.isVisible) {
|
|
6449
|
+
return hiddenVisibility;
|
|
6450
|
+
}
|
|
6451
|
+
const styles = {
|
|
6452
|
+
visibility: ""
|
|
6453
|
+
};
|
|
6454
|
+
const transformTemplate = this.getTransformTemplate();
|
|
6455
|
+
if (this.needsReset) {
|
|
6456
|
+
this.needsReset = false;
|
|
6457
|
+
styles.opacity = "";
|
|
6458
|
+
styles.pointerEvents = resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
|
|
6459
|
+
styles.transform = transformTemplate ? transformTemplate(this.latestValues, "") : "none";
|
|
6460
|
+
return styles;
|
|
6461
|
+
}
|
|
6462
|
+
const lead = this.getLead();
|
|
6463
|
+
if (!this.projectionDelta || !this.layout || !lead.target) {
|
|
6464
|
+
const emptyStyles = {};
|
|
6465
|
+
if (this.options.layoutId) {
|
|
6466
|
+
emptyStyles.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1;
|
|
6467
|
+
emptyStyles.pointerEvents = resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
|
|
6468
|
+
}
|
|
6469
|
+
if (this.hasProjected && !hasTransform(this.latestValues)) {
|
|
6470
|
+
emptyStyles.transform = transformTemplate ? transformTemplate({}, "") : "none";
|
|
6471
|
+
this.hasProjected = false;
|
|
6472
|
+
}
|
|
6473
|
+
return emptyStyles;
|
|
6474
|
+
}
|
|
6475
|
+
const valuesToRender = lead.animationValues || lead.latestValues;
|
|
6476
|
+
this.applyTransformsToTarget();
|
|
6477
|
+
styles.transform = buildProjectionTransform(this.projectionDeltaWithTransform, this.treeScale, valuesToRender);
|
|
6478
|
+
if (transformTemplate) {
|
|
6479
|
+
styles.transform = transformTemplate(valuesToRender, styles.transform);
|
|
6480
|
+
}
|
|
6481
|
+
const { x, y } = this.projectionDelta;
|
|
6482
|
+
styles.transformOrigin = `${x.origin * 100}% ${y.origin * 100}% 0`;
|
|
6483
|
+
if (lead.animationValues) {
|
|
6484
|
+
styles.opacity = lead === this ? (_b = (_a = valuesToRender.opacity) !== null && _a !== void 0 ? _a : this.latestValues.opacity) !== null && _b !== void 0 ? _b : 1 : this.preserveOpacity ? this.latestValues.opacity : valuesToRender.opacityExit;
|
|
6485
|
+
} else {
|
|
6486
|
+
styles.opacity = lead === this ? valuesToRender.opacity !== void 0 ? valuesToRender.opacity : "" : valuesToRender.opacityExit !== void 0 ? valuesToRender.opacityExit : 0;
|
|
6487
|
+
}
|
|
6488
|
+
for (const key in scaleCorrectors) {
|
|
6489
|
+
if (valuesToRender[key] === void 0)
|
|
6490
|
+
continue;
|
|
6491
|
+
const { correct, applyTo } = scaleCorrectors[key];
|
|
6492
|
+
const corrected = styles.transform === "none" ? valuesToRender[key] : correct(valuesToRender[key], lead);
|
|
6493
|
+
if (applyTo) {
|
|
6494
|
+
const num = applyTo.length;
|
|
6495
|
+
for (let i = 0; i < num; i++) {
|
|
6496
|
+
styles[applyTo[i]] = corrected;
|
|
6497
|
+
}
|
|
6498
|
+
} else {
|
|
6499
|
+
styles[key] = corrected;
|
|
6500
|
+
}
|
|
6501
|
+
}
|
|
6502
|
+
if (this.options.layoutId) {
|
|
6503
|
+
styles.pointerEvents = lead === this ? resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "" : "none";
|
|
6504
|
+
}
|
|
6505
|
+
return styles;
|
|
6506
|
+
}
|
|
6507
|
+
clearSnapshot() {
|
|
6508
|
+
this.resumeFrom = this.snapshot = void 0;
|
|
6509
|
+
}
|
|
6510
|
+
// Only run on root
|
|
6511
|
+
resetTree() {
|
|
6512
|
+
this.root.nodes.forEach((node) => {
|
|
6513
|
+
var _a;
|
|
6514
|
+
return (_a = node.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop();
|
|
6515
|
+
});
|
|
6516
|
+
this.root.nodes.forEach(clearMeasurements);
|
|
6517
|
+
this.root.sharedNodes.clear();
|
|
6518
|
+
}
|
|
6519
|
+
};
|
|
6520
|
+
}
|
|
6521
|
+
function updateLayout(node) {
|
|
6522
|
+
node.updateLayout();
|
|
6523
|
+
}
|
|
6524
|
+
function notifyLayoutUpdate(node) {
|
|
6525
|
+
var _a;
|
|
6526
|
+
const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
|
|
6527
|
+
if (node.isLead() && node.layout && snapshot && node.hasListeners("didUpdate")) {
|
|
6528
|
+
const { layoutBox: layout, measuredBox: measuredLayout } = node.layout;
|
|
6529
|
+
const { animationType } = node.options;
|
|
6530
|
+
const isShared = snapshot.source !== node.layout.source;
|
|
6531
|
+
if (animationType === "size") {
|
|
6532
|
+
eachAxis((axis) => {
|
|
6533
|
+
const axisSnapshot = isShared ? snapshot.measuredBox[axis] : snapshot.layoutBox[axis];
|
|
6534
|
+
const length = calcLength(axisSnapshot);
|
|
6535
|
+
axisSnapshot.min = layout[axis].min;
|
|
6536
|
+
axisSnapshot.max = axisSnapshot.min + length;
|
|
6537
|
+
});
|
|
6538
|
+
} else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
|
|
6539
|
+
eachAxis((axis) => {
|
|
6540
|
+
const axisSnapshot = isShared ? snapshot.measuredBox[axis] : snapshot.layoutBox[axis];
|
|
6541
|
+
const length = calcLength(layout[axis]);
|
|
6542
|
+
axisSnapshot.max = axisSnapshot.min + length;
|
|
6543
|
+
if (node.relativeTarget && !node.currentAnimation) {
|
|
6544
|
+
node.isProjectionDirty = true;
|
|
6545
|
+
node.relativeTarget[axis].max = node.relativeTarget[axis].min + length;
|
|
6546
|
+
}
|
|
6547
|
+
});
|
|
6548
|
+
}
|
|
6549
|
+
const layoutDelta = createDelta();
|
|
6550
|
+
calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
|
|
6551
|
+
const visualDelta = createDelta();
|
|
6552
|
+
if (isShared) {
|
|
6553
|
+
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
|
|
6554
|
+
} else {
|
|
6555
|
+
calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
|
|
6556
|
+
}
|
|
6557
|
+
const hasLayoutChanged = !isDeltaZero(layoutDelta);
|
|
6558
|
+
let hasRelativeTargetChanged = false;
|
|
6559
|
+
if (!node.resumeFrom) {
|
|
6560
|
+
const relativeParent = node.getClosestProjectingParent();
|
|
6561
|
+
if (relativeParent && !relativeParent.resumeFrom) {
|
|
6562
|
+
const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
|
|
6563
|
+
if (parentSnapshot && parentLayout) {
|
|
6564
|
+
const relativeSnapshot = createBox();
|
|
6565
|
+
calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
|
|
6566
|
+
const relativeLayout = createBox();
|
|
6567
|
+
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
|
|
6568
|
+
if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
|
|
6569
|
+
hasRelativeTargetChanged = true;
|
|
6570
|
+
}
|
|
6571
|
+
if (relativeParent.options.layoutRoot) {
|
|
6572
|
+
node.relativeTarget = relativeLayout;
|
|
6573
|
+
node.relativeTargetOrigin = relativeSnapshot;
|
|
6574
|
+
node.relativeParent = relativeParent;
|
|
6575
|
+
}
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
node.notifyListeners("didUpdate", {
|
|
6580
|
+
layout,
|
|
6581
|
+
snapshot,
|
|
6582
|
+
delta: visualDelta,
|
|
6583
|
+
layoutDelta,
|
|
6584
|
+
hasLayoutChanged,
|
|
6585
|
+
hasRelativeTargetChanged
|
|
6586
|
+
});
|
|
6587
|
+
} else if (node.isLead()) {
|
|
6588
|
+
const { onExitComplete } = node.options;
|
|
6589
|
+
onExitComplete && onExitComplete();
|
|
6590
|
+
}
|
|
6591
|
+
node.options.transition = void 0;
|
|
6592
|
+
}
|
|
6593
|
+
function propagateDirtyNodes(node) {
|
|
6594
|
+
if (isDebug) {
|
|
6595
|
+
metrics.totalNodes++;
|
|
6596
|
+
}
|
|
6597
|
+
if (!node.parent)
|
|
6598
|
+
return;
|
|
6599
|
+
if (!node.isProjecting()) {
|
|
6600
|
+
node.isProjectionDirty = node.parent.isProjectionDirty;
|
|
6601
|
+
}
|
|
6602
|
+
node.isSharedProjectionDirty || (node.isSharedProjectionDirty = Boolean(node.isProjectionDirty || node.parent.isProjectionDirty || node.parent.isSharedProjectionDirty));
|
|
6603
|
+
node.isTransformDirty || (node.isTransformDirty = node.parent.isTransformDirty);
|
|
6604
|
+
}
|
|
6605
|
+
function cleanDirtyNodes(node) {
|
|
6606
|
+
node.isProjectionDirty = node.isSharedProjectionDirty = node.isTransformDirty = false;
|
|
6607
|
+
}
|
|
6608
|
+
function clearSnapshot(node) {
|
|
6609
|
+
node.clearSnapshot();
|
|
6610
|
+
}
|
|
6611
|
+
function clearMeasurements(node) {
|
|
6612
|
+
node.clearMeasurements();
|
|
6613
|
+
}
|
|
6614
|
+
function clearIsLayoutDirty(node) {
|
|
6615
|
+
node.isLayoutDirty = false;
|
|
6616
|
+
}
|
|
6617
|
+
function resetTransformStyle(node) {
|
|
6618
|
+
const { visualElement } = node.options;
|
|
6619
|
+
if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {
|
|
6620
|
+
visualElement.notify("BeforeLayoutMeasure");
|
|
6621
|
+
}
|
|
6622
|
+
node.resetTransform();
|
|
6623
|
+
}
|
|
6624
|
+
function finishAnimation(node) {
|
|
6625
|
+
node.finishAnimation();
|
|
6626
|
+
node.targetDelta = node.relativeTarget = node.target = void 0;
|
|
6627
|
+
node.isProjectionDirty = true;
|
|
6628
|
+
}
|
|
6629
|
+
function resolveTargetDelta(node) {
|
|
6630
|
+
node.resolveTargetDelta();
|
|
6631
|
+
}
|
|
6632
|
+
function calcProjection(node) {
|
|
6633
|
+
node.calcProjection();
|
|
6634
|
+
}
|
|
6635
|
+
function resetSkewAndRotation(node) {
|
|
6636
|
+
node.resetSkewAndRotation();
|
|
6637
|
+
}
|
|
6638
|
+
function removeLeadSnapshots(stack) {
|
|
6639
|
+
stack.removeLeadSnapshot();
|
|
6640
|
+
}
|
|
6641
|
+
function mixAxisDelta(output, delta, p) {
|
|
6642
|
+
output.translate = mixNumber$1(delta.translate, 0, p);
|
|
6643
|
+
output.scale = mixNumber$1(delta.scale, 1, p);
|
|
6644
|
+
output.origin = delta.origin;
|
|
6645
|
+
output.originPoint = delta.originPoint;
|
|
6646
|
+
}
|
|
6647
|
+
function mixAxis(output, from, to, p) {
|
|
6648
|
+
output.min = mixNumber$1(from.min, to.min, p);
|
|
6649
|
+
output.max = mixNumber$1(from.max, to.max, p);
|
|
6650
|
+
}
|
|
6651
|
+
function mixBox(output, from, to, p) {
|
|
6652
|
+
mixAxis(output.x, from.x, to.x, p);
|
|
6653
|
+
mixAxis(output.y, from.y, to.y, p);
|
|
6654
|
+
}
|
|
6655
|
+
function hasOpacityCrossfade(node) {
|
|
6656
|
+
return node.animationValues && node.animationValues.opacityExit !== void 0;
|
|
6657
|
+
}
|
|
6658
|
+
const defaultLayoutTransition = {
|
|
6659
|
+
duration: 0.45,
|
|
6660
|
+
ease: [0.4, 0, 0.1, 1]
|
|
6661
|
+
};
|
|
6662
|
+
const userAgentContains = (string) => typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(string);
|
|
6663
|
+
const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/") ? Math.round : noop$1;
|
|
6664
|
+
function roundAxis(axis) {
|
|
6665
|
+
axis.min = roundPoint(axis.min);
|
|
6666
|
+
axis.max = roundPoint(axis.max);
|
|
6667
|
+
}
|
|
6668
|
+
function roundBox(box) {
|
|
6669
|
+
roundAxis(box.x);
|
|
6670
|
+
roundAxis(box.y);
|
|
6671
|
+
}
|
|
6672
|
+
function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
6673
|
+
return animationType === "position" || animationType === "preserve-aspect" && !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2);
|
|
6674
|
+
}
|
|
6675
|
+
function checkNodeWasScrollRoot(node) {
|
|
6676
|
+
var _a;
|
|
6677
|
+
return node !== node.root && ((_a = node.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot);
|
|
6678
|
+
}
|
|
6679
|
+
function addDomEvent(target, eventName, handler, options = { passive: true }) {
|
|
6680
|
+
target.addEventListener(eventName, handler, options);
|
|
6681
|
+
return () => target.removeEventListener(eventName, handler);
|
|
6682
|
+
}
|
|
6683
|
+
const DocumentProjectionNode = createProjectionNode({
|
|
6684
|
+
attachResizeListener: (ref, notify2) => addDomEvent(ref, "resize", notify2),
|
|
6685
|
+
measureScroll: () => ({
|
|
6686
|
+
x: document.documentElement.scrollLeft || document.body.scrollLeft,
|
|
6687
|
+
y: document.documentElement.scrollTop || document.body.scrollTop
|
|
6688
|
+
}),
|
|
6689
|
+
checkIsScrollRoot: () => true
|
|
6690
|
+
});
|
|
6691
|
+
const rootProjectionNode = {
|
|
6692
|
+
current: void 0
|
|
6693
|
+
};
|
|
6694
|
+
const HTMLProjectionNode = createProjectionNode({
|
|
6695
|
+
measureScroll: (instance) => ({
|
|
6696
|
+
x: instance.scrollLeft,
|
|
6697
|
+
y: instance.scrollTop
|
|
6698
|
+
}),
|
|
6699
|
+
defaultParent: () => {
|
|
6700
|
+
if (!rootProjectionNode.current) {
|
|
6701
|
+
const documentNode = new DocumentProjectionNode({});
|
|
6702
|
+
documentNode.mount(window);
|
|
6703
|
+
documentNode.setOptions({ layoutScroll: true });
|
|
6704
|
+
rootProjectionNode.current = documentNode;
|
|
6705
|
+
}
|
|
6706
|
+
return rootProjectionNode.current;
|
|
6707
|
+
},
|
|
6708
|
+
resetTransform: (instance, value) => {
|
|
6709
|
+
instance.style.transform = value !== void 0 ? value : "none";
|
|
6710
|
+
},
|
|
6711
|
+
checkIsScrollRoot: (instance) => Boolean(window.getComputedStyle(instance).position === "fixed")
|
|
6712
|
+
});
|
|
6713
|
+
function getClosestProjectingNode(visualElement) {
|
|
6714
|
+
if (!visualElement)
|
|
6715
|
+
return void 0;
|
|
6716
|
+
return visualElement.options.allowProjection !== false ? visualElement.projection : getClosestProjectingNode(visualElement.parent);
|
|
6717
|
+
}
|
|
6718
|
+
function pixelsToPercent(pixels, axis) {
|
|
6719
|
+
if (axis.max === axis.min)
|
|
6720
|
+
return 0;
|
|
6721
|
+
return pixels / (axis.max - axis.min) * 100;
|
|
6722
|
+
}
|
|
6723
|
+
const correctBorderRadius = {
|
|
6724
|
+
correct: (latest, node) => {
|
|
6725
|
+
if (!node.target)
|
|
6726
|
+
return latest;
|
|
6727
|
+
if (typeof latest === "string") {
|
|
6728
|
+
if (px.test(latest)) {
|
|
6729
|
+
latest = parseFloat(latest);
|
|
6730
|
+
} else {
|
|
6731
|
+
return latest;
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
const x = pixelsToPercent(latest, node.target.x);
|
|
6735
|
+
const y = pixelsToPercent(latest, node.target.y);
|
|
6736
|
+
return `${x}% ${y}%`;
|
|
6737
|
+
}
|
|
6738
|
+
};
|
|
6739
|
+
const correctBoxShadow = {
|
|
6740
|
+
correct: (latest, { treeScale, projectionDelta }) => {
|
|
6741
|
+
const original = latest;
|
|
6742
|
+
const shadow = complex.parse(latest);
|
|
6743
|
+
if (shadow.length > 5)
|
|
6744
|
+
return original;
|
|
6745
|
+
const template = complex.createTransformer(latest);
|
|
6746
|
+
const offset = typeof shadow[0] !== "number" ? 1 : 0;
|
|
6747
|
+
const xScale = projectionDelta.x.scale * treeScale.x;
|
|
6748
|
+
const yScale = projectionDelta.y.scale * treeScale.y;
|
|
6749
|
+
shadow[0 + offset] /= xScale;
|
|
6750
|
+
shadow[1 + offset] /= yScale;
|
|
6751
|
+
const averageScale = mixNumber$1(xScale, yScale, 0.5);
|
|
6752
|
+
if (typeof shadow[2 + offset] === "number")
|
|
6753
|
+
shadow[2 + offset] /= averageScale;
|
|
6754
|
+
if (typeof shadow[3 + offset] === "number")
|
|
6755
|
+
shadow[3 + offset] /= averageScale;
|
|
6756
|
+
return template(shadow);
|
|
6757
|
+
}
|
|
6758
|
+
};
|
|
6759
|
+
const defaultScaleCorrector = {
|
|
6760
|
+
borderRadius: {
|
|
6761
|
+
...correctBorderRadius,
|
|
6762
|
+
applyTo: [
|
|
6763
|
+
"borderTopLeftRadius",
|
|
6764
|
+
"borderTopRightRadius",
|
|
6765
|
+
"borderBottomLeftRadius",
|
|
6766
|
+
"borderBottomRightRadius"
|
|
6767
|
+
]
|
|
6768
|
+
},
|
|
6769
|
+
borderTopLeftRadius: correctBorderRadius,
|
|
6770
|
+
borderTopRightRadius: correctBorderRadius,
|
|
6771
|
+
borderBottomLeftRadius: correctBorderRadius,
|
|
6772
|
+
borderBottomRightRadius: correctBorderRadius,
|
|
6773
|
+
boxShadow: correctBoxShadow
|
|
6774
|
+
};
|
|
6775
|
+
class LayoutFeature extends Feature {
|
|
6776
|
+
constructor(state2) {
|
|
6777
|
+
super(state2);
|
|
6778
|
+
const options = this.state.getOptions();
|
|
6779
|
+
const visualElement = this.state.visualElement;
|
|
6780
|
+
if (options.layout || options.layoutId) {
|
|
6781
|
+
addScaleCorrector(defaultScaleCorrector);
|
|
6782
|
+
this.layoutGroup = injectLayoutGroup({});
|
|
6783
|
+
vue.onBeforeMount(() => {
|
|
6784
|
+
visualElement.projection = new HTMLProjectionNode(
|
|
6785
|
+
visualElement.latestValues,
|
|
6786
|
+
options["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(visualElement.parent)
|
|
6787
|
+
);
|
|
6788
|
+
visualElement.projection.setOptions({
|
|
6789
|
+
layout: options.layout,
|
|
6790
|
+
layoutId: options.layoutId,
|
|
6791
|
+
// TODO: drag
|
|
6792
|
+
alwaysMeasureLayout: false,
|
|
6793
|
+
visualElement,
|
|
6794
|
+
animationType: typeof options.layout === "string" ? options.layout : "both",
|
|
6795
|
+
// initialPromotionConfig
|
|
6796
|
+
layoutRoot: options.layoutRoot,
|
|
6797
|
+
layoutScroll: options.layoutScroll
|
|
6798
|
+
});
|
|
6799
|
+
});
|
|
6800
|
+
vue.onBeforeUpdate(() => {
|
|
6801
|
+
var _a;
|
|
6802
|
+
(_a = visualElement.projection) == null ? void 0 : _a.willUpdate();
|
|
6803
|
+
});
|
|
6804
|
+
vue.onUpdated(() => {
|
|
6805
|
+
var _a;
|
|
6806
|
+
(_a = visualElement.projection) == null ? void 0 : _a.root.didUpdate();
|
|
6807
|
+
});
|
|
6808
|
+
vue.onBeforeUnmount(() => {
|
|
6809
|
+
var _a;
|
|
6810
|
+
if (visualElement.projection) {
|
|
6811
|
+
visualElement.projection.unmount();
|
|
6812
|
+
if ((_a = this.layoutGroup) == null ? void 0 : _a.group)
|
|
6813
|
+
this.layoutGroup.group.remove(visualElement.projection);
|
|
6814
|
+
}
|
|
6815
|
+
});
|
|
6816
|
+
}
|
|
6817
|
+
}
|
|
6818
|
+
update() {
|
|
6819
|
+
var _a;
|
|
6820
|
+
(_a = this.state.visualElement.projection) == null ? void 0 : _a.setOptions(this.state.getOptions());
|
|
6821
|
+
}
|
|
6822
|
+
mount() {
|
|
6823
|
+
var _a, _b;
|
|
6824
|
+
const options = this.state.getOptions();
|
|
6825
|
+
if (options.layout || options.layoutId) {
|
|
6826
|
+
const projection = this.state.visualElement.projection;
|
|
6827
|
+
if (projection) {
|
|
6828
|
+
(_b = (_a = this.layoutGroup) == null ? void 0 : _a.group) == null ? void 0 : _b.add(projection);
|
|
6829
|
+
}
|
|
6830
|
+
globalProjectionState.hasEverUpdated = true;
|
|
6831
|
+
projection == null ? void 0 : projection.mount(this.state.element);
|
|
6832
|
+
projection == null ? void 0 : projection.root.didUpdate();
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
unmount() {
|
|
6836
|
+
}
|
|
6837
|
+
}
|
|
5192
6838
|
class FeatureManager {
|
|
5193
6839
|
constructor(state2) {
|
|
5194
6840
|
this.features = [];
|
|
@@ -5197,7 +6843,8 @@ class FeatureManager {
|
|
|
5197
6843
|
new PressGesture(state2),
|
|
5198
6844
|
new InViewGesture(state2),
|
|
5199
6845
|
new SVGFeature(state2),
|
|
5200
|
-
new EventFeature(state2)
|
|
6846
|
+
new EventFeature(state2),
|
|
6847
|
+
new LayoutFeature(state2)
|
|
5201
6848
|
];
|
|
5202
6849
|
}
|
|
5203
6850
|
mount() {
|
|
@@ -5238,6 +6885,9 @@ function compareByDepth(a, b) {
|
|
|
5238
6885
|
function motionEvent(name, target, isExit) {
|
|
5239
6886
|
return new CustomEvent(name, { detail: { target, isExit } });
|
|
5240
6887
|
}
|
|
6888
|
+
function createVisualElement(Component, options) {
|
|
6889
|
+
return isSVGElement$1(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
|
|
6890
|
+
}
|
|
5241
6891
|
const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "exit", "drag"];
|
|
5242
6892
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
5243
6893
|
class MotionState {
|
|
@@ -5251,6 +6901,23 @@ class MotionState {
|
|
|
5251
6901
|
this.options = options;
|
|
5252
6902
|
this.parent = parent;
|
|
5253
6903
|
this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
|
|
6904
|
+
this.visualElement = createVisualElement(this.options.as, {
|
|
6905
|
+
presenceContext: null,
|
|
6906
|
+
parent: parent == null ? void 0 : parent.visualElement,
|
|
6907
|
+
props: {
|
|
6908
|
+
...this.options
|
|
6909
|
+
},
|
|
6910
|
+
visualState: {
|
|
6911
|
+
renderState: {
|
|
6912
|
+
transform: {},
|
|
6913
|
+
transformOrigin: {},
|
|
6914
|
+
style: {},
|
|
6915
|
+
vars: {},
|
|
6916
|
+
attrs: {}
|
|
6917
|
+
},
|
|
6918
|
+
latestValues: {}
|
|
6919
|
+
}
|
|
6920
|
+
});
|
|
5254
6921
|
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
5255
6922
|
this.featureManager = new FeatureManager(this);
|
|
5256
6923
|
this.initTarget(initialVariantSource);
|
|
@@ -5272,7 +6939,7 @@ class MotionState {
|
|
|
5272
6939
|
this.target = { ...this.baseTarget };
|
|
5273
6940
|
}
|
|
5274
6941
|
get initial() {
|
|
5275
|
-
return
|
|
6942
|
+
return isDef(this.options.initial) ? this.options.initial : this.context.initial;
|
|
5276
6943
|
}
|
|
5277
6944
|
mount(element) {
|
|
5278
6945
|
var _a;
|
|
@@ -5283,18 +6950,17 @@ class MotionState {
|
|
|
5283
6950
|
this.element = element;
|
|
5284
6951
|
mountedStates.set(element, this);
|
|
5285
6952
|
if (!visualElementStore.get(element)) {
|
|
5286
|
-
|
|
6953
|
+
this.visualElement.mount(element);
|
|
6954
|
+
visualElementStore.set(element, this.visualElement);
|
|
5287
6955
|
}
|
|
5288
|
-
|
|
5289
|
-
this.visualElement = visualElement;
|
|
5290
|
-
visualElement.update(this.options, (_a = this.parent) == null ? void 0 : _a.context);
|
|
6956
|
+
this.visualElement.update(this.options, (_a = this.parent) == null ? void 0 : _a.context);
|
|
5291
6957
|
if (typeof this.initial === "object") {
|
|
5292
6958
|
for (const key in this.initial) {
|
|
5293
|
-
visualElement.setStaticValue(key, this.initial[key]);
|
|
6959
|
+
this.visualElement.setStaticValue(key, this.initial[key]);
|
|
5294
6960
|
}
|
|
5295
6961
|
} else if (typeof this.initial === "string" && this.options.variants) {
|
|
5296
6962
|
for (const key in this.options.variants[this.initial]) {
|
|
5297
|
-
visualElement.setStaticValue(key, this.options.variants[this.initial][key]);
|
|
6963
|
+
this.visualElement.setStaticValue(key, this.options.variants[this.initial][key]);
|
|
5298
6964
|
}
|
|
5299
6965
|
}
|
|
5300
6966
|
this.featureManager.mount();
|
|
@@ -5327,7 +6993,7 @@ class MotionState {
|
|
|
5327
6993
|
if (!this.activeStates[name])
|
|
5328
6994
|
continue;
|
|
5329
6995
|
const variant = resolveVariant(
|
|
5330
|
-
|
|
6996
|
+
isDef(this.options[name]) ? this.options[name] : this.context[name],
|
|
5331
6997
|
this.options.variants,
|
|
5332
6998
|
this.options.custom
|
|
5333
6999
|
);
|
|
@@ -5373,12 +7039,12 @@ class MotionState {
|
|
|
5373
7039
|
const animations = animationFactories.map((factory) => factory()).filter(Boolean);
|
|
5374
7040
|
if (!animations.length)
|
|
5375
7041
|
return;
|
|
5376
|
-
const
|
|
5377
|
-
this.element.dispatchEvent(motionEvent("motionstart",
|
|
7042
|
+
const animationTarget2 = this.target;
|
|
7043
|
+
this.element.dispatchEvent(motionEvent("motionstart", animationTarget2));
|
|
5378
7044
|
const isExit = this.activeStates.exit;
|
|
5379
7045
|
Promise.all(animations).then(() => {
|
|
5380
7046
|
this.element.dispatchEvent(motionEvent("motioncomplete", {
|
|
5381
|
-
...
|
|
7047
|
+
...animationTarget2
|
|
5382
7048
|
}, isExit));
|
|
5383
7049
|
}).catch(noop);
|
|
5384
7050
|
}
|
|
@@ -5391,9 +7057,6 @@ class MotionState {
|
|
|
5391
7057
|
getOptions() {
|
|
5392
7058
|
return this.options;
|
|
5393
7059
|
}
|
|
5394
|
-
getElement() {
|
|
5395
|
-
return this.element;
|
|
5396
|
-
}
|
|
5397
7060
|
getTarget() {
|
|
5398
7061
|
return this.target;
|
|
5399
7062
|
}
|
|
@@ -5407,7 +7070,7 @@ function removeDoneCallback(element) {
|
|
|
5407
7070
|
doneCallbacks.delete(element);
|
|
5408
7071
|
}
|
|
5409
7072
|
const [injectAnimatePresence, provideAnimatePresence] = createContext("AnimatePresenceContext");
|
|
5410
|
-
const _sfc_main$
|
|
7073
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
5411
7074
|
...{
|
|
5412
7075
|
name: "Motion",
|
|
5413
7076
|
inheritAttrs: false
|
|
@@ -5435,20 +7098,30 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5435
7098
|
onPressStart: { type: Function },
|
|
5436
7099
|
onPressEnd: { type: Function },
|
|
5437
7100
|
onViewEnter: { type: Function },
|
|
5438
|
-
onViewLeave: { type: Function }
|
|
7101
|
+
onViewLeave: { type: Function },
|
|
7102
|
+
layout: { type: Boolean },
|
|
7103
|
+
layoutId: {},
|
|
7104
|
+
layoutScroll: { type: Boolean },
|
|
7105
|
+
layoutRoot: { type: Boolean },
|
|
7106
|
+
"data-framer-portal-id": {}
|
|
5439
7107
|
}, {
|
|
5440
7108
|
as: "div",
|
|
5441
7109
|
asChild: false,
|
|
5442
7110
|
initial: void 0,
|
|
5443
7111
|
animate: void 0,
|
|
5444
7112
|
hover: void 0,
|
|
5445
|
-
inView: void 0
|
|
7113
|
+
inView: void 0,
|
|
7114
|
+
layout: false,
|
|
7115
|
+
layoutId: void 0,
|
|
7116
|
+
layoutScroll: false,
|
|
7117
|
+
layoutRoot: false
|
|
5446
7118
|
}),
|
|
5447
7119
|
setup(__props) {
|
|
5448
7120
|
const props = __props;
|
|
5449
7121
|
const { initial: presenceInitial, safeUnmount } = injectAnimatePresence({ initial: vue.ref(void 0), safeUnmount: () => true });
|
|
5450
7122
|
const parentState = injectMotion(null);
|
|
5451
7123
|
const attrs = vue.useAttrs();
|
|
7124
|
+
const layoutGroup = injectLayoutGroup({});
|
|
5452
7125
|
const state2 = new MotionState(
|
|
5453
7126
|
{
|
|
5454
7127
|
...attrs,
|
|
@@ -5462,8 +7135,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5462
7135
|
state2.mount(instance == null ? void 0 : instance.vnode.el);
|
|
5463
7136
|
state2.update({
|
|
5464
7137
|
...attrs,
|
|
5465
|
-
...props
|
|
5466
|
-
style: { ...createStyles(state2.getTarget()), ...props.style }
|
|
7138
|
+
...props
|
|
5467
7139
|
});
|
|
5468
7140
|
});
|
|
5469
7141
|
vue.onUnmounted(() => {
|
|
@@ -5492,27 +7164,30 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5492
7164
|
Object.assign(attrsProps, attributes);
|
|
5493
7165
|
Object.assign(styleProps, style2, props.style);
|
|
5494
7166
|
} else {
|
|
5495
|
-
Object.assign(styleProps,
|
|
7167
|
+
Object.assign(styleProps, state2.getTarget(), props.style);
|
|
5496
7168
|
}
|
|
5497
7169
|
}
|
|
5498
7170
|
styleProps = createStyles(styleProps);
|
|
5499
|
-
attrsProps.style =
|
|
7171
|
+
attrsProps.style = styleProps;
|
|
5500
7172
|
return attrsProps;
|
|
5501
7173
|
}
|
|
5502
7174
|
return (_ctx, _cache) => {
|
|
7175
|
+
var _a, _b;
|
|
5503
7176
|
return vue.openBlock(), vue.createBlock(vue.unref(Primitive), vue.mergeProps({
|
|
5504
7177
|
as: _ctx.as,
|
|
5505
7178
|
"as-child": _ctx.asChild
|
|
5506
|
-
}, getProps()
|
|
7179
|
+
}, getProps(), {
|
|
7180
|
+
"data-layout-group-key": (_b = (_a = vue.unref(layoutGroup)) == null ? void 0 : _a.key) == null ? void 0 : _b.value
|
|
7181
|
+
}), {
|
|
5507
7182
|
default: vue.withCtx(() => [
|
|
5508
7183
|
vue.renderSlot(_ctx.$slots, "default")
|
|
5509
7184
|
]),
|
|
5510
7185
|
_: 3
|
|
5511
|
-
}, 16, ["as", "as-child"]);
|
|
7186
|
+
}, 16, ["as", "as-child", "data-layout-group-key"]);
|
|
5512
7187
|
};
|
|
5513
7188
|
}
|
|
5514
7189
|
});
|
|
5515
|
-
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
7190
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
5516
7191
|
...{
|
|
5517
7192
|
name: "AnimatePresence",
|
|
5518
7193
|
inheritAttrs: true
|
|
@@ -5577,6 +7252,72 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
5577
7252
|
};
|
|
5578
7253
|
}
|
|
5579
7254
|
});
|
|
7255
|
+
function notify(node) {
|
|
7256
|
+
return !node.isLayoutDirty && node.willUpdate(false);
|
|
7257
|
+
}
|
|
7258
|
+
function nodeGroup() {
|
|
7259
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
7260
|
+
const subscriptions = /* @__PURE__ */ new WeakMap();
|
|
7261
|
+
const dirtyAll = () => nodes.forEach(notify);
|
|
7262
|
+
return {
|
|
7263
|
+
add: (node) => {
|
|
7264
|
+
nodes.add(node);
|
|
7265
|
+
subscriptions.set(
|
|
7266
|
+
node,
|
|
7267
|
+
node.addEventListener("willUpdate", dirtyAll)
|
|
7268
|
+
);
|
|
7269
|
+
},
|
|
7270
|
+
remove: (node) => {
|
|
7271
|
+
nodes.delete(node);
|
|
7272
|
+
const unsubscribe = subscriptions.get(node);
|
|
7273
|
+
if (unsubscribe) {
|
|
7274
|
+
unsubscribe();
|
|
7275
|
+
subscriptions.delete(node);
|
|
7276
|
+
}
|
|
7277
|
+
dirtyAll();
|
|
7278
|
+
},
|
|
7279
|
+
dirty: dirtyAll
|
|
7280
|
+
};
|
|
7281
|
+
}
|
|
7282
|
+
function useForceUpdate() {
|
|
7283
|
+
const key = vue.ref(0);
|
|
7284
|
+
function forceUpdate() {
|
|
7285
|
+
key.value++;
|
|
7286
|
+
}
|
|
7287
|
+
return [forceUpdate, key];
|
|
7288
|
+
}
|
|
7289
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
7290
|
+
__name: "LayoutGroup",
|
|
7291
|
+
props: {
|
|
7292
|
+
id: {},
|
|
7293
|
+
inherit: { type: [Boolean, String] }
|
|
7294
|
+
},
|
|
7295
|
+
setup(__props) {
|
|
7296
|
+
const props = __props;
|
|
7297
|
+
const layoutGroup = injectLayoutGroup(null);
|
|
7298
|
+
const [forceRender, key] = useForceUpdate();
|
|
7299
|
+
function generateId() {
|
|
7300
|
+
const upstreamId = layoutGroup == null ? void 0 : layoutGroup.id;
|
|
7301
|
+
return shouldInheritId(props.inherit) && upstreamId ? props.id ? `${upstreamId}-${props.id}` : upstreamId : props.id;
|
|
7302
|
+
}
|
|
7303
|
+
function generateGroup() {
|
|
7304
|
+
return shouldInheritGroup(props.inherit) ? (layoutGroup == null ? void 0 : layoutGroup.group) || nodeGroup() : nodeGroup();
|
|
7305
|
+
}
|
|
7306
|
+
const memoizedContext = {
|
|
7307
|
+
id: generateId(),
|
|
7308
|
+
group: generateGroup(),
|
|
7309
|
+
forceRender,
|
|
7310
|
+
key
|
|
7311
|
+
};
|
|
7312
|
+
vue.watch(key, () => {
|
|
7313
|
+
memoizedContext.id = generateId();
|
|
7314
|
+
});
|
|
7315
|
+
provideLayoutGroup(memoizedContext);
|
|
7316
|
+
return (_ctx, _cache) => {
|
|
7317
|
+
return vue.renderSlot(_ctx.$slots, "default");
|
|
7318
|
+
};
|
|
7319
|
+
}
|
|
7320
|
+
});
|
|
5580
7321
|
function useCombineMotionValues(combineValues) {
|
|
5581
7322
|
const value = motionValue(combineValues());
|
|
5582
7323
|
const updateValue = () => value.set(combineValues());
|
|
@@ -5657,6 +7398,13 @@ function useMotionTemplate(fragments, ...values) {
|
|
|
5657
7398
|
subscribe(values.filter(isMotionValue));
|
|
5658
7399
|
return value;
|
|
5659
7400
|
}
|
|
7401
|
+
function useMotionValueEvent(value, event, callback) {
|
|
7402
|
+
const unlisten = value.on(event, callback);
|
|
7403
|
+
vue.onUnmounted(() => {
|
|
7404
|
+
unlisten();
|
|
7405
|
+
});
|
|
7406
|
+
return unlisten;
|
|
7407
|
+
}
|
|
5660
7408
|
function toNumber(v) {
|
|
5661
7409
|
if (typeof v === "number")
|
|
5662
7410
|
return v;
|
|
@@ -5757,10 +7505,25 @@ function useScroll({
|
|
|
5757
7505
|
);
|
|
5758
7506
|
return values;
|
|
5759
7507
|
}
|
|
7508
|
+
function useVelocity(value) {
|
|
7509
|
+
const velocity = motionValue(value.getVelocity());
|
|
7510
|
+
const updateVelocity = () => {
|
|
7511
|
+
const latest = value.getVelocity();
|
|
7512
|
+
velocity.set(latest);
|
|
7513
|
+
if (latest) {
|
|
7514
|
+
frame.update(updateVelocity);
|
|
7515
|
+
}
|
|
7516
|
+
};
|
|
7517
|
+
useMotionValueEvent(value, "change", () => {
|
|
7518
|
+
frame.update(updateVelocity, false, true);
|
|
7519
|
+
});
|
|
7520
|
+
return velocity;
|
|
7521
|
+
}
|
|
5760
7522
|
const components = {
|
|
5761
7523
|
motion: [
|
|
5762
7524
|
"Motion",
|
|
5763
|
-
"MotionPresence"
|
|
7525
|
+
"MotionPresence",
|
|
7526
|
+
"LayoutGroup"
|
|
5764
7527
|
]
|
|
5765
7528
|
};
|
|
5766
7529
|
const utilities = {
|
|
@@ -5770,7 +7533,12 @@ const utilities = {
|
|
|
5770
7533
|
"useMotionTemplate",
|
|
5771
7534
|
"useSpring",
|
|
5772
7535
|
"useScroll",
|
|
5773
|
-
"useMotionValue"
|
|
7536
|
+
"useMotionValue",
|
|
7537
|
+
"useVelocity",
|
|
7538
|
+
"useAnimate",
|
|
7539
|
+
"useInView",
|
|
7540
|
+
"useAnimationFrame",
|
|
7541
|
+
"useMotionValueEvent"
|
|
5774
7542
|
]
|
|
5775
7543
|
};
|
|
5776
7544
|
function useAnimate() {
|
|
@@ -5799,8 +7567,9 @@ function useAnimate() {
|
|
|
5799
7567
|
});
|
|
5800
7568
|
return [domProxy, animate2];
|
|
5801
7569
|
}
|
|
5802
|
-
exports.AnimatePresence = _sfc_main;
|
|
5803
|
-
exports.
|
|
7570
|
+
exports.AnimatePresence = _sfc_main$1;
|
|
7571
|
+
exports.LayoutGroup = _sfc_main;
|
|
7572
|
+
exports.Motion = _sfc_main$2;
|
|
5804
7573
|
exports.MotionValue = MotionValue;
|
|
5805
7574
|
exports.animate = animate;
|
|
5806
7575
|
exports.animateMini = animateMini;
|
|
@@ -5829,6 +7598,8 @@ exports.frameData = frameData;
|
|
|
5829
7598
|
exports.frameSteps = frameSteps;
|
|
5830
7599
|
exports.inView = inView;
|
|
5831
7600
|
exports.inertia = inertia;
|
|
7601
|
+
exports.injectLayoutGroup = injectLayoutGroup;
|
|
7602
|
+
exports.injectMotion = injectMotion;
|
|
5832
7603
|
exports.interpolate = interpolate;
|
|
5833
7604
|
exports.isMotionValue = isMotionValue;
|
|
5834
7605
|
exports.keyframes = keyframes;
|
|
@@ -5837,9 +7608,13 @@ exports.mix = mix;
|
|
|
5837
7608
|
exports.motionValue = motionValue;
|
|
5838
7609
|
exports.pipe = pipe;
|
|
5839
7610
|
exports.progress = progress;
|
|
7611
|
+
exports.provideLayoutGroup = provideLayoutGroup;
|
|
7612
|
+
exports.provideMotion = provideMotion;
|
|
5840
7613
|
exports.reverseEasing = reverseEasing;
|
|
5841
7614
|
exports.scroll = scroll;
|
|
5842
7615
|
exports.scrollInfo = scrollInfo;
|
|
7616
|
+
exports.shouldInheritGroup = shouldInheritGroup;
|
|
7617
|
+
exports.shouldInheritId = shouldInheritId;
|
|
5843
7618
|
exports.spring = spring;
|
|
5844
7619
|
exports.stagger = stagger;
|
|
5845
7620
|
exports.steps = steps;
|
|
@@ -5847,12 +7622,16 @@ exports.sync = sync;
|
|
|
5847
7622
|
exports.transform = transform;
|
|
5848
7623
|
exports.useAnimate = useAnimate;
|
|
5849
7624
|
exports.useAnimationFrame = useAnimationFrame;
|
|
7625
|
+
exports.useCombineMotionValues = useCombineMotionValues;
|
|
7626
|
+
exports.useComputed = useComputed;
|
|
5850
7627
|
exports.useInView = useInView;
|
|
5851
7628
|
exports.useMotionTemplate = useMotionTemplate;
|
|
5852
7629
|
exports.useMotionValue = motionValue;
|
|
7630
|
+
exports.useMotionValueEvent = useMotionValueEvent;
|
|
5853
7631
|
exports.useScroll = useScroll;
|
|
5854
7632
|
exports.useSpring = useSpring;
|
|
5855
7633
|
exports.useTime = useTime;
|
|
5856
7634
|
exports.useTransform = useTransform;
|
|
7635
|
+
exports.useVelocity = useVelocity;
|
|
5857
7636
|
exports.utilities = utilities;
|
|
5858
7637
|
exports.wrap = wrap;
|