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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const globalProjectionState = {
|
|
2
|
+
/**
|
|
3
|
+
* Global flag as to whether the tree has animated since the last time
|
|
4
|
+
* we resized the window
|
|
5
|
+
*/
|
|
6
|
+
hasAnimatedSinceResize: true,
|
|
7
|
+
/**
|
|
8
|
+
* We set this to true once, on the first update. Any nodes added to the tree beyond that
|
|
9
|
+
* update will be given a `data-projection-id` attribute.
|
|
10
|
+
*/
|
|
11
|
+
hasEverUpdated: false
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
globalProjectionState
|
|
15
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { addUniqueItem, removeItem } from "../../utils/array.mjs";
|
|
2
|
+
class NodeStack {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.members = [];
|
|
5
|
+
}
|
|
6
|
+
add(node) {
|
|
7
|
+
addUniqueItem(this.members, node);
|
|
8
|
+
node.scheduleRender();
|
|
9
|
+
}
|
|
10
|
+
remove(node) {
|
|
11
|
+
removeItem(this.members, node);
|
|
12
|
+
if (node === this.prevLead) {
|
|
13
|
+
this.prevLead = void 0;
|
|
14
|
+
}
|
|
15
|
+
if (node === this.lead) {
|
|
16
|
+
const prevLead = this.members[this.members.length - 1];
|
|
17
|
+
if (prevLead) {
|
|
18
|
+
this.promote(prevLead);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
relegate(node) {
|
|
23
|
+
const indexOfNode = this.members.findIndex((member) => node === member);
|
|
24
|
+
if (indexOfNode === 0)
|
|
25
|
+
return false;
|
|
26
|
+
let prevLead;
|
|
27
|
+
for (let i = indexOfNode; i >= 0; i--) {
|
|
28
|
+
const member = this.members[i];
|
|
29
|
+
if (member.isPresent !== false) {
|
|
30
|
+
prevLead = member;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (prevLead) {
|
|
35
|
+
this.promote(prevLead);
|
|
36
|
+
return true;
|
|
37
|
+
} else {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
promote(node, preserveFollowOpacity) {
|
|
42
|
+
const prevLead = this.lead;
|
|
43
|
+
if (node === prevLead)
|
|
44
|
+
return;
|
|
45
|
+
this.prevLead = prevLead;
|
|
46
|
+
this.lead = node;
|
|
47
|
+
node.show();
|
|
48
|
+
if (prevLead) {
|
|
49
|
+
prevLead.instance && prevLead.scheduleRender();
|
|
50
|
+
node.scheduleRender();
|
|
51
|
+
node.resumeFrom = prevLead;
|
|
52
|
+
if (preserveFollowOpacity) {
|
|
53
|
+
node.resumeFrom.preserveOpacity = true;
|
|
54
|
+
}
|
|
55
|
+
if (prevLead.snapshot) {
|
|
56
|
+
node.snapshot = prevLead.snapshot;
|
|
57
|
+
node.snapshot.latestValues = prevLead.animationValues || prevLead.latestValues;
|
|
58
|
+
}
|
|
59
|
+
if (node.root && node.root.isUpdating) {
|
|
60
|
+
node.isLayoutDirty = true;
|
|
61
|
+
}
|
|
62
|
+
const { crossfade } = node.options;
|
|
63
|
+
if (crossfade === false) {
|
|
64
|
+
prevLead.hide();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exitAnimationComplete() {
|
|
69
|
+
this.members.forEach((node) => {
|
|
70
|
+
const { options, resumingFrom } = node;
|
|
71
|
+
options.onExitComplete && options.onExitComplete();
|
|
72
|
+
if (resumingFrom) {
|
|
73
|
+
resumingFrom.options.onExitComplete && resumingFrom.options.onExitComplete();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
scheduleRender() {
|
|
78
|
+
this.members.forEach((node) => {
|
|
79
|
+
node.instance && node.scheduleRender(false);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Clear any leads that have been removed this render to prevent them from being
|
|
84
|
+
* used in future animations and to prevent memory leaks
|
|
85
|
+
*/
|
|
86
|
+
removeLeadSnapshot() {
|
|
87
|
+
if (this.lead && this.lead.snapshot) {
|
|
88
|
+
this.lead.snapshot = void 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
NodeStack
|
|
94
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { px } from "../../value/types/numbers/units.mjs";
|
|
2
|
+
function pixelsToPercent(pixels, axis) {
|
|
3
|
+
if (axis.max === axis.min)
|
|
4
|
+
return 0;
|
|
5
|
+
return pixels / (axis.max - axis.min) * 100;
|
|
6
|
+
}
|
|
7
|
+
const correctBorderRadius = {
|
|
8
|
+
correct: (latest, node) => {
|
|
9
|
+
if (!node.target)
|
|
10
|
+
return latest;
|
|
11
|
+
if (typeof latest === "string") {
|
|
12
|
+
if (px.test(latest)) {
|
|
13
|
+
latest = parseFloat(latest);
|
|
14
|
+
} else {
|
|
15
|
+
return latest;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const x = pixelsToPercent(latest, node.target.x);
|
|
19
|
+
const y = pixelsToPercent(latest, node.target.y);
|
|
20
|
+
return `${x}% ${y}%`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
correctBorderRadius,
|
|
25
|
+
pixelsToPercent
|
|
26
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { mixNumber } from "../../utils/mix/number.mjs";
|
|
2
|
+
import { complex } from "../../value/types/complex/index.mjs";
|
|
3
|
+
const correctBoxShadow = {
|
|
4
|
+
correct: (latest, { treeScale, projectionDelta }) => {
|
|
5
|
+
const original = latest;
|
|
6
|
+
const shadow = complex.parse(latest);
|
|
7
|
+
if (shadow.length > 5)
|
|
8
|
+
return original;
|
|
9
|
+
const template = complex.createTransformer(latest);
|
|
10
|
+
const offset = typeof shadow[0] !== "number" ? 1 : 0;
|
|
11
|
+
const xScale = projectionDelta.x.scale * treeScale.x;
|
|
12
|
+
const yScale = projectionDelta.y.scale * treeScale.y;
|
|
13
|
+
shadow[0 + offset] /= xScale;
|
|
14
|
+
shadow[1 + offset] /= yScale;
|
|
15
|
+
const averageScale = mixNumber(xScale, yScale, 0.5);
|
|
16
|
+
if (typeof shadow[2 + offset] === "number")
|
|
17
|
+
shadow[2 + offset] /= averageScale;
|
|
18
|
+
if (typeof shadow[3 + offset] === "number")
|
|
19
|
+
shadow[3 + offset] /= averageScale;
|
|
20
|
+
return template(shadow);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
correctBoxShadow
|
|
25
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
2
|
+
let transform = "";
|
|
3
|
+
const xTranslate = delta.x.translate / treeScale.x;
|
|
4
|
+
const yTranslate = delta.y.translate / treeScale.y;
|
|
5
|
+
const zTranslate = (latestTransform === null || latestTransform === void 0 ? void 0 : latestTransform.z) || 0;
|
|
6
|
+
if (xTranslate || yTranslate || zTranslate) {
|
|
7
|
+
transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
|
|
8
|
+
}
|
|
9
|
+
if (treeScale.x !== 1 || treeScale.y !== 1) {
|
|
10
|
+
transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
|
|
11
|
+
}
|
|
12
|
+
if (latestTransform) {
|
|
13
|
+
const { transformPerspective, rotate, rotateX, rotateY, skewX, skewY } = latestTransform;
|
|
14
|
+
if (transformPerspective)
|
|
15
|
+
transform = `perspective(${transformPerspective}px) ${transform}`;
|
|
16
|
+
if (rotate)
|
|
17
|
+
transform += `rotate(${rotate}deg) `;
|
|
18
|
+
if (rotateX)
|
|
19
|
+
transform += `rotateX(${rotateX}deg) `;
|
|
20
|
+
if (rotateY)
|
|
21
|
+
transform += `rotateY(${rotateY}deg) `;
|
|
22
|
+
if (skewX)
|
|
23
|
+
transform += `skewX(${skewX}deg) `;
|
|
24
|
+
if (skewY)
|
|
25
|
+
transform += `skewY(${skewY}deg) `;
|
|
26
|
+
}
|
|
27
|
+
const elementScaleX = delta.x.scale * treeScale.x;
|
|
28
|
+
const elementScaleY = delta.y.scale * treeScale.y;
|
|
29
|
+
if (elementScaleX !== 1 || elementScaleY !== 1) {
|
|
30
|
+
transform += `scale(${elementScaleX}, ${elementScaleY})`;
|
|
31
|
+
}
|
|
32
|
+
return transform || "none";
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
buildProjectionTransform
|
|
36
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function isIdentityScale(scale) {
|
|
2
|
+
return scale === void 0 || scale === 1;
|
|
3
|
+
}
|
|
4
|
+
function hasScale({ scale, scaleX, scaleY }) {
|
|
5
|
+
return !isIdentityScale(scale) || !isIdentityScale(scaleX) || !isIdentityScale(scaleY);
|
|
6
|
+
}
|
|
7
|
+
function hasTransform(values) {
|
|
8
|
+
return hasScale(values) || has2DTranslate(values) || values.z || values.rotate || values.rotateX || values.rotateY || values.skewX || values.skewY;
|
|
9
|
+
}
|
|
10
|
+
function has2DTranslate(values) {
|
|
11
|
+
return is2DTranslate(values.x) || is2DTranslate(values.y);
|
|
12
|
+
}
|
|
13
|
+
function is2DTranslate(value) {
|
|
14
|
+
return value && value !== "0%";
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
has2DTranslate,
|
|
18
|
+
hasScale,
|
|
19
|
+
hasTransform
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { addUniqueItem, removeItem } from "../../utils/array.mjs";
|
|
2
|
+
import { compareByDepth } from "./compare-by-depth.mjs";
|
|
3
|
+
class FlatTree {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.children = [];
|
|
6
|
+
this.isDirty = false;
|
|
7
|
+
}
|
|
8
|
+
add(child) {
|
|
9
|
+
addUniqueItem(this.children, child);
|
|
10
|
+
this.isDirty = true;
|
|
11
|
+
}
|
|
12
|
+
remove(child) {
|
|
13
|
+
removeItem(this.children, child);
|
|
14
|
+
this.isDirty = true;
|
|
15
|
+
}
|
|
16
|
+
forEach(callback) {
|
|
17
|
+
this.isDirty && this.children.sort(compareByDepth);
|
|
18
|
+
this.isDirty = false;
|
|
19
|
+
this.children.forEach(callback);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
FlatTree
|
|
24
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { isKeyframesTarget } from "../animation/utils/is-keyframes-target.mjs";
|
|
2
|
+
const isCustomValue = (v) => {
|
|
3
|
+
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
4
|
+
};
|
|
2
5
|
const resolveFinalValueInKeyframes = (v) => {
|
|
3
6
|
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
4
7
|
};
|
|
5
8
|
export {
|
|
9
|
+
isCustomValue,
|
|
6
10
|
resolveFinalValueInKeyframes
|
|
7
11
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isCustomValue } from "../../utils/resolve-value.mjs";
|
|
2
|
+
import { isMotionValue } from "./is-motion-value.mjs";
|
|
3
|
+
function resolveMotionValue(value) {
|
|
4
|
+
const unwrappedValue = isMotionValue(value) ? value.get() : value;
|
|
5
|
+
return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
resolveMotionValue
|
|
9
|
+
};
|
|
@@ -5,7 +5,7 @@ class EventFeature extends Feature {
|
|
|
5
5
|
this.handlers = {};
|
|
6
6
|
}
|
|
7
7
|
mount() {
|
|
8
|
-
const element = this.state.
|
|
8
|
+
const element = this.state.element;
|
|
9
9
|
if (!element)
|
|
10
10
|
return;
|
|
11
11
|
this.handlers.motionstart = (event) => {
|
|
@@ -53,7 +53,7 @@ class EventFeature extends Feature {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
unmount() {
|
|
56
|
-
const element = this.state.
|
|
56
|
+
const element = this.state.element;
|
|
57
57
|
if (!element)
|
|
58
58
|
return;
|
|
59
59
|
Object.entries(this.handlers).forEach(([event, handler]) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventFeature } from "./events.mjs";
|
|
2
2
|
import { SVGFeature } from "./svg.mjs";
|
|
3
|
+
import { LayoutFeature } from "./layout/layout.mjs";
|
|
3
4
|
import { HoverGesture } from "./gestures/hover.mjs";
|
|
4
5
|
import { PressGesture } from "./gestures/press.mjs";
|
|
5
6
|
import { InViewGesture } from "./gestures/in-view.mjs";
|
|
@@ -11,7 +12,8 @@ class FeatureManager {
|
|
|
11
12
|
new PressGesture(state),
|
|
12
13
|
new InViewGesture(state),
|
|
13
14
|
new SVGFeature(state),
|
|
14
|
-
new EventFeature(state)
|
|
15
|
+
new EventFeature(state),
|
|
16
|
+
new LayoutFeature(state)
|
|
15
17
|
];
|
|
16
18
|
}
|
|
17
19
|
mount() {
|
|
@@ -15,7 +15,7 @@ class HoverGesture extends BaseGesture {
|
|
|
15
15
|
constructor(state) {
|
|
16
16
|
super(state);
|
|
17
17
|
this.subscribeEvents = () => {
|
|
18
|
-
const element = this.state.
|
|
18
|
+
const element = this.state.element;
|
|
19
19
|
const onEnter = mouseEvent(element, "hoverstart", () => {
|
|
20
20
|
this.state.setActive("hover", true);
|
|
21
21
|
});
|
|
@@ -9,7 +9,7 @@ class InViewGesture extends BaseGesture {
|
|
|
9
9
|
super(state);
|
|
10
10
|
this.subscribeEvents = () => {
|
|
11
11
|
var _a;
|
|
12
|
-
const element = this.state.
|
|
12
|
+
const element = this.state.element;
|
|
13
13
|
const { once, ...viewOptions } = ((_a = this.state.getOptions()) == null ? void 0 : _a.inViewOptions) || {};
|
|
14
14
|
return inView(element, (enterEntry) => {
|
|
15
15
|
this.state.setActive("inView", true);
|
|
@@ -7,7 +7,7 @@ class PressGesture extends BaseGesture {
|
|
|
7
7
|
constructor(state) {
|
|
8
8
|
super(state);
|
|
9
9
|
this.subscribeEvents = () => {
|
|
10
|
-
const element = this.state.
|
|
10
|
+
const element = this.state.element;
|
|
11
11
|
const onPointerUp = (event) => {
|
|
12
12
|
this.state.setActive("press", false);
|
|
13
13
|
dispatchPointerEvent(element, "pressend", event);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { correctBorderRadius } from "../../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/scale-border-radius.mjs";
|
|
2
|
+
import { correctBoxShadow } from "../../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs";
|
|
3
|
+
const defaultScaleCorrector = {
|
|
4
|
+
borderRadius: {
|
|
5
|
+
...correctBorderRadius,
|
|
6
|
+
applyTo: [
|
|
7
|
+
"borderTopLeftRadius",
|
|
8
|
+
"borderTopRightRadius",
|
|
9
|
+
"borderBottomLeftRadius",
|
|
10
|
+
"borderBottomRightRadius"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
borderTopLeftRadius: correctBorderRadius,
|
|
14
|
+
borderTopRightRadius: correctBorderRadius,
|
|
15
|
+
borderBottomLeftRadius: correctBorderRadius,
|
|
16
|
+
borderBottomRightRadius: correctBorderRadius,
|
|
17
|
+
boxShadow: correctBoxShadow
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
defaultScaleCorrector
|
|
21
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Feature } from "../feature.mjs";
|
|
2
|
+
import { HTMLProjectionNode } from "../../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs";
|
|
3
|
+
import { getClosestProjectingNode } from "./utils.mjs";
|
|
4
|
+
import { onBeforeMount, onBeforeUpdate, onUpdated, onBeforeUnmount } from "vue";
|
|
5
|
+
import { addScaleCorrector } from "../../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/styles/scale-correction.mjs";
|
|
6
|
+
import { defaultScaleCorrector } from "./config.mjs";
|
|
7
|
+
import { globalProjectionState } from "../../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/projection/node/state.mjs";
|
|
8
|
+
import { injectLayoutGroup } from "../../components/context.mjs";
|
|
9
|
+
class LayoutFeature extends Feature {
|
|
10
|
+
constructor(state) {
|
|
11
|
+
super(state);
|
|
12
|
+
const options = this.state.getOptions();
|
|
13
|
+
const visualElement = this.state.visualElement;
|
|
14
|
+
if (options.layout || options.layoutId) {
|
|
15
|
+
addScaleCorrector(defaultScaleCorrector);
|
|
16
|
+
this.layoutGroup = injectLayoutGroup({});
|
|
17
|
+
onBeforeMount(() => {
|
|
18
|
+
visualElement.projection = new HTMLProjectionNode(
|
|
19
|
+
visualElement.latestValues,
|
|
20
|
+
options["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(visualElement.parent)
|
|
21
|
+
);
|
|
22
|
+
visualElement.projection.setOptions({
|
|
23
|
+
layout: options.layout,
|
|
24
|
+
layoutId: options.layoutId,
|
|
25
|
+
// TODO: drag
|
|
26
|
+
alwaysMeasureLayout: false,
|
|
27
|
+
visualElement,
|
|
28
|
+
animationType: typeof options.layout === "string" ? options.layout : "both",
|
|
29
|
+
// initialPromotionConfig
|
|
30
|
+
layoutRoot: options.layoutRoot,
|
|
31
|
+
layoutScroll: options.layoutScroll
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
onBeforeUpdate(() => {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = visualElement.projection) == null ? void 0 : _a.willUpdate();
|
|
37
|
+
});
|
|
38
|
+
onUpdated(() => {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = visualElement.projection) == null ? void 0 : _a.root.didUpdate();
|
|
41
|
+
});
|
|
42
|
+
onBeforeUnmount(() => {
|
|
43
|
+
var _a;
|
|
44
|
+
if (visualElement.projection) {
|
|
45
|
+
visualElement.projection.unmount();
|
|
46
|
+
if ((_a = this.layoutGroup) == null ? void 0 : _a.group)
|
|
47
|
+
this.layoutGroup.group.remove(visualElement.projection);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
update() {
|
|
53
|
+
var _a;
|
|
54
|
+
(_a = this.state.visualElement.projection) == null ? void 0 : _a.setOptions(this.state.getOptions());
|
|
55
|
+
}
|
|
56
|
+
mount() {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const options = this.state.getOptions();
|
|
59
|
+
if (options.layout || options.layoutId) {
|
|
60
|
+
const projection = this.state.visualElement.projection;
|
|
61
|
+
if (projection) {
|
|
62
|
+
(_b = (_a = this.layoutGroup) == null ? void 0 : _a.group) == null ? void 0 : _b.add(projection);
|
|
63
|
+
}
|
|
64
|
+
globalProjectionState.hasEverUpdated = true;
|
|
65
|
+
projection == null ? void 0 : projection.mount(this.state.element);
|
|
66
|
+
projection == null ? void 0 : projection.root.didUpdate();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
unmount() {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
LayoutFeature
|
|
74
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function getClosestProjectingNode(visualElement) {
|
|
2
|
+
if (!visualElement)
|
|
3
|
+
return void 0;
|
|
4
|
+
return visualElement.options.allowProjection !== false ? visualElement.projection : getClosestProjectingNode(visualElement.parent);
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
getClosestProjectingNode
|
|
8
|
+
};
|
package/dist/es/features/svg.mjs
CHANGED
package/dist/es/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { default as default2 } from "./components/Motion.vue.mjs";
|
|
2
2
|
import { default as default3 } from "./components/AnimatePresence.vue.mjs";
|
|
3
|
+
import { default as default4 } from "./components/LayoutGroup.vue.mjs";
|
|
4
|
+
import { injectLayoutGroup, injectMotion, provideLayoutGroup, provideMotion, shouldInheritGroup, shouldInheritId } from "./components/context.mjs";
|
|
3
5
|
import { components, utilities } from "./constants/index.mjs";
|
|
4
6
|
import { MotionValue, motionValue, motionValue as motionValue2 } from "./external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/value/index.mjs";
|
|
5
7
|
import { animate, createScopedAnimate } from "./external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/animation/animate/index.mjs";
|
|
@@ -31,11 +33,15 @@ import { progress } from "./external/.pnpm/framer-motion@11.11.11/external/frame
|
|
|
31
33
|
import { wrap } from "./external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/utils/wrap.mjs";
|
|
32
34
|
import { cancelSync, sync } from "./external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/frameloop/index-legacy.mjs";
|
|
33
35
|
import { cancelFrame, frame, frameData, frameSteps } from "./external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/frameloop/frame.mjs";
|
|
36
|
+
import { useComputed } from "./value/use-computed.mjs";
|
|
37
|
+
import { useCombineMotionValues } from "./value/use-combine-values.mjs";
|
|
34
38
|
import { useTransform } from "./value/use-transform.mjs";
|
|
35
39
|
import { useTime } from "./value/use-time.mjs";
|
|
36
40
|
import { useMotionTemplate } from "./value/use-motion-template.mjs";
|
|
41
|
+
import { useMotionValueEvent } from "./value/use-motion-value-event.mjs";
|
|
37
42
|
import { useSpring } from "./value/use-spring.mjs";
|
|
38
43
|
import { useScroll } from "./value/use-scroll.mjs";
|
|
44
|
+
import { useVelocity } from "./value/use-velocity.mjs";
|
|
39
45
|
import { useAnimate } from "./animation/use-animate.mjs";
|
|
40
46
|
import { createContext } from "./utils/createContext.mjs";
|
|
41
47
|
import { isMotionValue } from "./utils/motion-value.mjs";
|
|
@@ -43,6 +49,7 @@ import { useInView } from "./utils/use-in-view.mjs";
|
|
|
43
49
|
import { useAnimationFrame } from "./utils/use-animation-frame.mjs";
|
|
44
50
|
export {
|
|
45
51
|
default3 as AnimatePresence,
|
|
52
|
+
default4 as LayoutGroup,
|
|
46
53
|
default2 as Motion,
|
|
47
54
|
MotionValue,
|
|
48
55
|
animate,
|
|
@@ -72,6 +79,8 @@ export {
|
|
|
72
79
|
frameSteps,
|
|
73
80
|
inView,
|
|
74
81
|
inertia,
|
|
82
|
+
injectLayoutGroup,
|
|
83
|
+
injectMotion,
|
|
75
84
|
interpolate,
|
|
76
85
|
invariant,
|
|
77
86
|
isMotionValue,
|
|
@@ -81,9 +90,13 @@ export {
|
|
|
81
90
|
motionValue,
|
|
82
91
|
pipe,
|
|
83
92
|
progress,
|
|
93
|
+
provideLayoutGroup,
|
|
94
|
+
provideMotion,
|
|
84
95
|
reverseEasing,
|
|
85
96
|
scroll,
|
|
86
97
|
scrollInfo,
|
|
98
|
+
shouldInheritGroup,
|
|
99
|
+
shouldInheritId,
|
|
87
100
|
spring,
|
|
88
101
|
stagger,
|
|
89
102
|
steps,
|
|
@@ -91,13 +104,17 @@ export {
|
|
|
91
104
|
transform,
|
|
92
105
|
useAnimate,
|
|
93
106
|
useAnimationFrame,
|
|
107
|
+
useCombineMotionValues,
|
|
108
|
+
useComputed,
|
|
94
109
|
useInView,
|
|
95
110
|
useMotionTemplate,
|
|
96
111
|
motionValue2 as useMotionValue,
|
|
112
|
+
useMotionValueEvent,
|
|
97
113
|
useScroll,
|
|
98
114
|
useSpring,
|
|
99
115
|
useTime,
|
|
100
116
|
useTransform,
|
|
117
|
+
useVelocity,
|
|
101
118
|
utilities,
|
|
102
119
|
warning,
|
|
103
120
|
wrap
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isSVGElement } from "./utils.mjs";
|
|
2
|
+
import { HTMLVisualElement } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/render/html/HTMLVisualElement.mjs";
|
|
3
|
+
import { SVGVisualElement } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/render/svg/SVGVisualElement.mjs";
|
|
4
|
+
function createVisualElement(Component, options) {
|
|
5
|
+
return isSVGElement(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
createVisualElement
|
|
9
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { invariant } from "../external/.pnpm/hey-listen@1.0.8/external/hey-listen/dist/hey-listen.es.mjs";
|
|
2
2
|
import { visualElementStore } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/render/store.mjs";
|
|
3
|
-
import { createDOMVisualElement } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/animation/utils/create-visual-element.mjs";
|
|
4
|
-
import { isDef } from "@vueuse/core";
|
|
5
3
|
import { resolveVariant, getOptions, hasChanged, noop } from "./utils.mjs";
|
|
6
4
|
import { FeatureManager } from "../features/feature-manager.mjs";
|
|
7
5
|
import { style } from "./style.mjs";
|
|
8
6
|
import { transformResetValue } from "./transform.mjs";
|
|
9
7
|
import { scheduleAnimation, unscheduleAnimation } from "./schedule.mjs";
|
|
10
8
|
import { motionEvent } from "./event.mjs";
|
|
9
|
+
import { createVisualElement } from "./create-visual-element.mjs";
|
|
11
10
|
import { animate } from "../external/.pnpm/framer-motion@11.11.11/external/framer-motion/dist/es/animation/animate/index.mjs";
|
|
11
|
+
import { isDef } from "../external/.pnpm/@vueuse_shared@12.0.0_typescript@5.5.4/external/@vueuse/shared/index.mjs";
|
|
12
12
|
const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "exit", "drag"];
|
|
13
13
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
14
14
|
class MotionState {
|
|
@@ -22,6 +22,23 @@ class MotionState {
|
|
|
22
22
|
this.options = options;
|
|
23
23
|
this.parent = parent;
|
|
24
24
|
this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
|
|
25
|
+
this.visualElement = createVisualElement(this.options.as, {
|
|
26
|
+
presenceContext: null,
|
|
27
|
+
parent: parent == null ? void 0 : parent.visualElement,
|
|
28
|
+
props: {
|
|
29
|
+
...this.options
|
|
30
|
+
},
|
|
31
|
+
visualState: {
|
|
32
|
+
renderState: {
|
|
33
|
+
transform: {},
|
|
34
|
+
transformOrigin: {},
|
|
35
|
+
style: {},
|
|
36
|
+
vars: {},
|
|
37
|
+
attrs: {}
|
|
38
|
+
},
|
|
39
|
+
latestValues: {}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
25
42
|
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
26
43
|
this.featureManager = new FeatureManager(this);
|
|
27
44
|
this.initTarget(initialVariantSource);
|
|
@@ -54,18 +71,17 @@ class MotionState {
|
|
|
54
71
|
this.element = element;
|
|
55
72
|
mountedStates.set(element, this);
|
|
56
73
|
if (!visualElementStore.get(element)) {
|
|
57
|
-
|
|
74
|
+
this.visualElement.mount(element);
|
|
75
|
+
visualElementStore.set(element, this.visualElement);
|
|
58
76
|
}
|
|
59
|
-
|
|
60
|
-
this.visualElement = visualElement;
|
|
61
|
-
visualElement.update(this.options, (_a = this.parent) == null ? void 0 : _a.context);
|
|
77
|
+
this.visualElement.update(this.options, (_a = this.parent) == null ? void 0 : _a.context);
|
|
62
78
|
if (typeof this.initial === "object") {
|
|
63
79
|
for (const key in this.initial) {
|
|
64
|
-
visualElement.setStaticValue(key, this.initial[key]);
|
|
80
|
+
this.visualElement.setStaticValue(key, this.initial[key]);
|
|
65
81
|
}
|
|
66
82
|
} else if (typeof this.initial === "string" && this.options.variants) {
|
|
67
83
|
for (const key in this.options.variants[this.initial]) {
|
|
68
|
-
visualElement.setStaticValue(key, this.options.variants[this.initial][key]);
|
|
84
|
+
this.visualElement.setStaticValue(key, this.options.variants[this.initial][key]);
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
this.featureManager.mount();
|
|
@@ -162,9 +178,6 @@ class MotionState {
|
|
|
162
178
|
getOptions() {
|
|
163
179
|
return this.options;
|
|
164
180
|
}
|
|
165
|
-
getElement() {
|
|
166
|
-
return this.element;
|
|
167
|
-
}
|
|
168
181
|
getTarget() {
|
|
169
182
|
return this.target;
|
|
170
183
|
}
|
package/dist/es/state/style.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isTransform, transformAlias,
|
|
1
|
+
import { isCssVar, isNumber } from "./utils.mjs";
|
|
2
|
+
import { transformDefinitions, isTransform, transformAlias, buildTransformTemplate } from "./transform.mjs";
|
|
3
3
|
import { isMotionValue } from "../utils/motion-value.mjs";
|
|
4
4
|
const style = {
|
|
5
5
|
get: (element, name) => {
|