motion-v 0.5.2-beta.1 → 0.6.0
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 +205 -147
- package/dist/es/components/LayoutGroup.vue.mjs +1 -3
- package/dist/es/components/Motion.vue.mjs +35 -30
- package/dist/es/components/{AnimatePresence.vue.mjs → animate-presence/AnimatePresence.vue.mjs} +37 -14
- package/dist/es/components/{use-pop-layout.mjs → animate-presence/use-pop-layout.mjs} +1 -1
- package/dist/es/components/group.mjs +5 -2
- package/dist/es/components/presence.mjs +0 -2
- package/dist/es/components/utils.mjs +7 -0
- package/dist/es/constants/index.mjs +2 -1
- package/dist/es/features/layout/layout.mjs +17 -8
- package/dist/es/features/layout/projection.mjs +17 -1
- package/dist/es/index.mjs +4 -4
- package/dist/es/state/animate-variants-children.mjs +5 -3
- package/dist/es/state/motion-state.mjs +49 -22
- package/dist/es/state/schedule.mjs +2 -26
- package/dist/es/state/utils.mjs +0 -9
- package/dist/src/components/{AnimatePresence.d.ts → animate-presence/AnimatePresence.d.ts} +1 -1
- package/dist/src/components/animate-presence/index.d.ts +2 -0
- package/dist/src/components/{type.d.ts → animate-presence/types.d.ts} +2 -0
- package/dist/src/components/{use-pop-layout.d.ts → animate-presence/use-pop-layout.d.ts} +2 -2
- package/dist/src/components/animate-presence/use-presence.d.ts +2 -0
- package/dist/src/components/context.d.ts +1 -0
- package/dist/src/components/group.d.ts +1 -0
- package/dist/src/components/hooks/use-motion-elm.d.ts +13 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/presence.d.ts +3 -5
- package/dist/src/components/utils.d.ts +7 -0
- package/dist/src/index.d.ts +1 -3
- package/dist/src/state/animate-variants-children.d.ts +1 -1
- package/dist/src/state/event.d.ts +1 -1
- package/dist/src/state/motion-state.d.ts +10 -7
- package/dist/src/types/state.d.ts +6 -2
- package/package.json +3 -2
- /package/dist/es/components/{AnimatePresence.vue2.mjs → animate-presence/AnimatePresence.vue2.mjs} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -18,11 +18,11 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function addUniqueItem
|
|
21
|
+
function addUniqueItem(arr, item) {
|
|
22
22
|
if (arr.indexOf(item) === -1)
|
|
23
23
|
arr.push(item);
|
|
24
24
|
}
|
|
25
|
-
function removeItem
|
|
25
|
+
function removeItem(arr, item) {
|
|
26
26
|
const index = arr.indexOf(item);
|
|
27
27
|
if (index > -1)
|
|
28
28
|
arr.splice(index, 1);
|
|
@@ -32,8 +32,8 @@ class SubscriptionManager {
|
|
|
32
32
|
this.subscriptions = [];
|
|
33
33
|
}
|
|
34
34
|
add(handler) {
|
|
35
|
-
addUniqueItem
|
|
36
|
-
return () => removeItem
|
|
35
|
+
addUniqueItem(this.subscriptions, handler);
|
|
36
|
+
return () => removeItem(this.subscriptions, handler);
|
|
37
37
|
}
|
|
38
38
|
notify(a, b, c) {
|
|
39
39
|
const numSubscriptions = this.subscriptions.length;
|
|
@@ -876,7 +876,7 @@ function eraseKeyframes(sequence, startTime, endTime) {
|
|
|
876
876
|
for (let i = 0; i < sequence.length; i++) {
|
|
877
877
|
const keyframe = sequence[i];
|
|
878
878
|
if (keyframe.at > startTime && keyframe.at < endTime) {
|
|
879
|
-
removeItem
|
|
879
|
+
removeItem(sequence, keyframe);
|
|
880
880
|
i--;
|
|
881
881
|
}
|
|
882
882
|
}
|
|
@@ -4836,13 +4836,6 @@ function shallowCompare(next, prev) {
|
|
|
4836
4836
|
}
|
|
4837
4837
|
return true;
|
|
4838
4838
|
}
|
|
4839
|
-
function addUniqueItem(array, item) {
|
|
4840
|
-
!array.includes(item) && array.push(item);
|
|
4841
|
-
}
|
|
4842
|
-
function removeItem(array, item) {
|
|
4843
|
-
const index = array.indexOf(item);
|
|
4844
|
-
index !== -1 && array.splice(index, 1);
|
|
4845
|
-
}
|
|
4846
4839
|
function getOptions(options, key) {
|
|
4847
4840
|
return options[key] ? { ...options, ...options[key] } : { ...options };
|
|
4848
4841
|
}
|
|
@@ -5644,7 +5637,6 @@ function measurePageBox(element, rootProjectionNode2, transformPagePoint) {
|
|
|
5644
5637
|
return viewportBox;
|
|
5645
5638
|
}
|
|
5646
5639
|
const doneCallbacks = /* @__PURE__ */ new WeakMap();
|
|
5647
|
-
vue.ref(/* @__PURE__ */ new WeakMap());
|
|
5648
5640
|
function removeDoneCallback(element) {
|
|
5649
5641
|
const prevDoneCallback = doneCallbacks.get(element);
|
|
5650
5642
|
if (prevDoneCallback) {
|
|
@@ -6202,8 +6194,7 @@ class LayoutFeature extends Feature {
|
|
|
6202
6194
|
addScaleCorrector(defaultScaleCorrector);
|
|
6203
6195
|
}
|
|
6204
6196
|
beforeUpdate() {
|
|
6205
|
-
|
|
6206
|
-
(_a = this.state.visualElement.projection) == null ? void 0 : _a.willUpdate();
|
|
6197
|
+
this.state.willUpdate("beforeUpdate");
|
|
6207
6198
|
}
|
|
6208
6199
|
update() {
|
|
6209
6200
|
var _a;
|
|
@@ -6225,15 +6216,25 @@ class LayoutFeature extends Feature {
|
|
|
6225
6216
|
}
|
|
6226
6217
|
}
|
|
6227
6218
|
beforeUnmount() {
|
|
6219
|
+
const projection = this.state.visualElement.projection;
|
|
6220
|
+
if (projection) {
|
|
6221
|
+
this.state.willUpdate("beforeUnmount");
|
|
6222
|
+
if (this.state.options.layoutId) {
|
|
6223
|
+
projection.isPresent = false;
|
|
6224
|
+
projection.relegate();
|
|
6225
|
+
} else if (this.state.options.layout) {
|
|
6226
|
+
this.state.isSafeToRemove = true;
|
|
6227
|
+
}
|
|
6228
|
+
}
|
|
6228
6229
|
}
|
|
6229
6230
|
unmount() {
|
|
6231
|
+
var _a, _b;
|
|
6232
|
+
const layoutGroup = this.state.options.layoutGroup;
|
|
6230
6233
|
const projection = this.state.visualElement.projection;
|
|
6231
|
-
if (projection)
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
if (layoutGroup == null ? void 0 : layoutGroup.group)
|
|
6236
|
-
layoutGroup.group.remove(projection);
|
|
6234
|
+
if ((layoutGroup == null ? void 0 : layoutGroup.group) && projection)
|
|
6235
|
+
layoutGroup.group.remove(projection);
|
|
6236
|
+
if (this.state.options.layoutId || this.state.options.layout) {
|
|
6237
|
+
(_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
|
|
6237
6238
|
}
|
|
6238
6239
|
}
|
|
6239
6240
|
}
|
|
@@ -6466,11 +6467,11 @@ class NodeStack {
|
|
|
6466
6467
|
this.members = [];
|
|
6467
6468
|
}
|
|
6468
6469
|
add(node) {
|
|
6469
|
-
addUniqueItem
|
|
6470
|
+
addUniqueItem(this.members, node);
|
|
6470
6471
|
node.scheduleRender();
|
|
6471
6472
|
}
|
|
6472
6473
|
remove(node) {
|
|
6473
|
-
removeItem
|
|
6474
|
+
removeItem(this.members, node);
|
|
6474
6475
|
if (node === this.prevLead) {
|
|
6475
6476
|
this.prevLead = void 0;
|
|
6476
6477
|
}
|
|
@@ -6587,22 +6588,22 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
6587
6588
|
function eachAxis(callback) {
|
|
6588
6589
|
return [callback("x"), callback("y")];
|
|
6589
6590
|
}
|
|
6590
|
-
const compareByDepth
|
|
6591
|
+
const compareByDepth = (a, b) => a.depth - b.depth;
|
|
6591
6592
|
class FlatTree {
|
|
6592
6593
|
constructor() {
|
|
6593
6594
|
this.children = [];
|
|
6594
6595
|
this.isDirty = false;
|
|
6595
6596
|
}
|
|
6596
6597
|
add(child) {
|
|
6597
|
-
addUniqueItem
|
|
6598
|
+
addUniqueItem(this.children, child);
|
|
6598
6599
|
this.isDirty = true;
|
|
6599
6600
|
}
|
|
6600
6601
|
remove(child) {
|
|
6601
|
-
removeItem
|
|
6602
|
+
removeItem(this.children, child);
|
|
6602
6603
|
this.isDirty = true;
|
|
6603
6604
|
}
|
|
6604
6605
|
forEach(callback) {
|
|
6605
|
-
this.isDirty && this.children.sort(compareByDepth
|
|
6606
|
+
this.isDirty && this.children.sort(compareByDepth);
|
|
6606
6607
|
this.isDirty = false;
|
|
6607
6608
|
this.children.forEach(callback);
|
|
6608
6609
|
}
|
|
@@ -7713,6 +7714,7 @@ class ProjectionFeature extends Feature {
|
|
|
7713
7714
|
this.state.visualElement.latestValues,
|
|
7714
7715
|
options["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(this.state.visualElement.parent)
|
|
7715
7716
|
);
|
|
7717
|
+
this.state.visualElement.projection.isPresent = true;
|
|
7716
7718
|
this.state.visualElement.projection.setOptions({
|
|
7717
7719
|
layout: options.layout,
|
|
7718
7720
|
layoutId: options.layoutId,
|
|
@@ -7723,7 +7725,21 @@ class ProjectionFeature extends Feature {
|
|
|
7723
7725
|
// initialPromotionConfig
|
|
7724
7726
|
layoutRoot: options.layoutRoot,
|
|
7725
7727
|
layoutScroll: options.layoutScroll,
|
|
7726
|
-
crossfade: options.crossfade
|
|
7728
|
+
crossfade: options.crossfade,
|
|
7729
|
+
onExitComplete: () => {
|
|
7730
|
+
var _a;
|
|
7731
|
+
if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
|
|
7732
|
+
const done = doneCallbacks.get(this.state.element);
|
|
7733
|
+
this.state.isSafeToRemove = true;
|
|
7734
|
+
if (done) {
|
|
7735
|
+
done({
|
|
7736
|
+
detail: {
|
|
7737
|
+
isExit: true
|
|
7738
|
+
}
|
|
7739
|
+
}, true);
|
|
7740
|
+
}
|
|
7741
|
+
}
|
|
7742
|
+
}
|
|
7727
7743
|
});
|
|
7728
7744
|
}
|
|
7729
7745
|
beforeMount() {
|
|
@@ -7788,30 +7804,8 @@ class FeatureManager {
|
|
|
7788
7804
|
this.features.forEach((feature) => feature.beforeUnmount());
|
|
7789
7805
|
}
|
|
7790
7806
|
}
|
|
7791
|
-
let scheduled;
|
|
7792
|
-
const fireNext = (iterator) => iterator.next();
|
|
7793
|
-
const fireAnimateUpdates = (state2) => state2.animateUpdates();
|
|
7794
|
-
function processScheduledAnimations() {
|
|
7795
|
-
if (!scheduled)
|
|
7796
|
-
return;
|
|
7797
|
-
const generators2 = scheduled.sort(compareByDepth).map(fireAnimateUpdates);
|
|
7798
|
-
generators2.forEach(fireNext);
|
|
7799
|
-
generators2.forEach(fireNext);
|
|
7800
|
-
scheduled = void 0;
|
|
7801
|
-
}
|
|
7802
7807
|
function scheduleAnimation(state2) {
|
|
7803
|
-
|
|
7804
|
-
scheduled = [state2];
|
|
7805
|
-
requestAnimationFrame(processScheduledAnimations);
|
|
7806
|
-
} else {
|
|
7807
|
-
addUniqueItem(scheduled, state2);
|
|
7808
|
-
}
|
|
7809
|
-
}
|
|
7810
|
-
function unscheduleAnimation(state2) {
|
|
7811
|
-
scheduled && removeItem(scheduled, state2);
|
|
7812
|
-
}
|
|
7813
|
-
function compareByDepth(a, b) {
|
|
7814
|
-
return a.depth - b.depth;
|
|
7808
|
+
state2.animateUpdates();
|
|
7815
7809
|
}
|
|
7816
7810
|
function motionEvent(name, target, isExit) {
|
|
7817
7811
|
return new CustomEvent(name, { detail: { target, isExit } });
|
|
@@ -7819,7 +7813,7 @@ function motionEvent(name, target, isExit) {
|
|
|
7819
7813
|
function createVisualElement(Component, options) {
|
|
7820
7814
|
return isSVGElement$1(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
|
|
7821
7815
|
}
|
|
7822
|
-
function animateVariantsChildren(state2, activeState) {
|
|
7816
|
+
function animateVariantsChildren(state2, activeState, isFirstAnimate = false) {
|
|
7823
7817
|
const variantChildren = state2.visualElement.variantChildren;
|
|
7824
7818
|
if (!(variantChildren == null ? void 0 : variantChildren.size)) {
|
|
7825
7819
|
return {
|
|
@@ -7830,11 +7824,13 @@ function animateVariantsChildren(state2, activeState) {
|
|
|
7830
7824
|
const animationFactories = [];
|
|
7831
7825
|
Array.from(variantChildren).forEach((child, index) => {
|
|
7832
7826
|
var _a;
|
|
7833
|
-
const prevTarget = child.state.target;
|
|
7827
|
+
const prevTarget = isFirstAnimate ? child.state.baseTarget : child.state.target;
|
|
7834
7828
|
const childState = child.state;
|
|
7835
7829
|
childState.target = {};
|
|
7836
7830
|
for (const name in activeState) {
|
|
7837
|
-
|
|
7831
|
+
if (name === "initial" && !isFirstAnimate) {
|
|
7832
|
+
continue;
|
|
7833
|
+
}
|
|
7838
7834
|
const { definition, transition } = activeState[name];
|
|
7839
7835
|
const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
|
|
7840
7836
|
const maxStaggerDuration = (variantChildren.size - 1) * staggerChildren;
|
|
@@ -7885,20 +7881,25 @@ function animateVariantsChildren(state2, activeState) {
|
|
|
7885
7881
|
};
|
|
7886
7882
|
}
|
|
7887
7883
|
const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
|
|
7888
|
-
const mountedStates = /* @__PURE__ */ new
|
|
7884
|
+
const mountedStates = /* @__PURE__ */ new Map();
|
|
7889
7885
|
let id = 0;
|
|
7890
7886
|
class MotionState {
|
|
7891
7887
|
constructor(options, parent) {
|
|
7888
|
+
var _a;
|
|
7892
7889
|
this.element = null;
|
|
7890
|
+
this.isSafeToRemove = false;
|
|
7893
7891
|
this.isFirstAnimate = true;
|
|
7892
|
+
this.children = /* @__PURE__ */ new Set();
|
|
7894
7893
|
this.activeStates = {
|
|
7895
|
-
initial: true,
|
|
7894
|
+
// initial: true,
|
|
7896
7895
|
animate: true
|
|
7897
7896
|
};
|
|
7898
7897
|
this._context = null;
|
|
7899
7898
|
this.id = `motion-state-${id++}`;
|
|
7899
|
+
mountedStates.set(this.id, this);
|
|
7900
7900
|
this.options = options;
|
|
7901
7901
|
this.parent = parent;
|
|
7902
|
+
(_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
|
|
7902
7903
|
this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
|
|
7903
7904
|
this.visualElement = createVisualElement(this.options.as, {
|
|
7904
7905
|
presenceContext: null,
|
|
@@ -7922,8 +7923,8 @@ class MotionState {
|
|
|
7922
7923
|
reducedMotionConfig: options.motionConfig.reduceMotion
|
|
7923
7924
|
});
|
|
7924
7925
|
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
7925
|
-
this.featureManager = new FeatureManager(this);
|
|
7926
7926
|
this.initTarget(initialVariantSource);
|
|
7927
|
+
this.featureManager = new FeatureManager(this);
|
|
7927
7928
|
}
|
|
7928
7929
|
get context() {
|
|
7929
7930
|
if (!this._context) {
|
|
@@ -7939,7 +7940,7 @@ class MotionState {
|
|
|
7939
7940
|
}
|
|
7940
7941
|
initTarget(initialVariantSource) {
|
|
7941
7942
|
this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
|
|
7942
|
-
this.target = {
|
|
7943
|
+
this.target = {};
|
|
7943
7944
|
}
|
|
7944
7945
|
get initial() {
|
|
7945
7946
|
return isDef(this.options.initial) ? this.options.initial : this.context.initial;
|
|
@@ -7958,7 +7959,7 @@ class MotionState {
|
|
|
7958
7959
|
beforeMount() {
|
|
7959
7960
|
this.featureManager.beforeMount();
|
|
7960
7961
|
}
|
|
7961
|
-
mount(element, options) {
|
|
7962
|
+
mount(element, options, notAnimate = false) {
|
|
7962
7963
|
heyListen.invariant(
|
|
7963
7964
|
Boolean(element),
|
|
7964
7965
|
"Animation state must be mounted with valid Element"
|
|
@@ -7982,38 +7983,57 @@ class MotionState {
|
|
|
7982
7983
|
}
|
|
7983
7984
|
}
|
|
7984
7985
|
this.featureManager.mount();
|
|
7985
|
-
|
|
7986
|
+
if (!notAnimate) {
|
|
7987
|
+
this.animateUpdates(true);
|
|
7988
|
+
}
|
|
7986
7989
|
}
|
|
7987
7990
|
beforeUnmount() {
|
|
7988
7991
|
this.featureManager.beforeUnmount();
|
|
7989
7992
|
}
|
|
7990
|
-
unmount() {
|
|
7991
|
-
var _a;
|
|
7993
|
+
unmount(unMountChildren = false) {
|
|
7994
|
+
var _a, _b;
|
|
7992
7995
|
mountedStates.delete(this.element);
|
|
7993
|
-
|
|
7994
|
-
(_a = visualElementStore.get(this.element)) == null ? void 0 : _a.unmount();
|
|
7996
|
+
mountedStates.delete(this.id);
|
|
7995
7997
|
this.featureManager.unmount();
|
|
7998
|
+
(_a = this.visualElement) == null ? void 0 : _a.unmount();
|
|
7999
|
+
if (unMountChildren) {
|
|
8000
|
+
const unmountChild = (child) => {
|
|
8001
|
+
var _a2;
|
|
8002
|
+
child.unmount(true);
|
|
8003
|
+
(_a2 = child.children) == null ? void 0 : _a2.forEach(unmountChild);
|
|
8004
|
+
};
|
|
8005
|
+
(_b = this.children) == null ? void 0 : _b.forEach(unmountChild);
|
|
8006
|
+
}
|
|
7996
8007
|
}
|
|
7997
8008
|
beforeUpdate() {
|
|
7998
8009
|
this.featureManager.beforeUpdate();
|
|
7999
8010
|
}
|
|
8000
|
-
update(options) {
|
|
8011
|
+
update(options, notAnimate = false) {
|
|
8012
|
+
const prevAnimate = JSON.stringify(this.options.animate);
|
|
8001
8013
|
this.options = options;
|
|
8014
|
+
let hasAnimateChange = false;
|
|
8015
|
+
if (prevAnimate !== JSON.stringify(options.animate)) {
|
|
8016
|
+
hasAnimateChange = true;
|
|
8017
|
+
}
|
|
8002
8018
|
this.updateOptions();
|
|
8003
8019
|
this.featureManager.update();
|
|
8004
|
-
|
|
8020
|
+
if (hasAnimateChange && !notAnimate) {
|
|
8021
|
+
scheduleAnimation(this);
|
|
8022
|
+
}
|
|
8005
8023
|
}
|
|
8006
|
-
setActive(name, isActive) {
|
|
8024
|
+
setActive(name, isActive, isAnimate = true) {
|
|
8007
8025
|
var _a;
|
|
8008
8026
|
if (!this.element || this.activeStates[name] === isActive)
|
|
8009
8027
|
return;
|
|
8010
8028
|
this.activeStates[name] = isActive;
|
|
8011
8029
|
(_a = this.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
|
|
8012
|
-
child.state.setActive(name, isActive);
|
|
8030
|
+
child.state.setActive(name, isActive, false);
|
|
8013
8031
|
});
|
|
8014
|
-
|
|
8032
|
+
if (isAnimate) {
|
|
8033
|
+
scheduleAnimation(this);
|
|
8034
|
+
}
|
|
8015
8035
|
}
|
|
8016
|
-
|
|
8036
|
+
animateUpdates(isInitial = false) {
|
|
8017
8037
|
const prevTarget = this.target;
|
|
8018
8038
|
this.target = {};
|
|
8019
8039
|
const activeState = {};
|
|
@@ -8021,13 +8041,13 @@ class MotionState {
|
|
|
8021
8041
|
let transition;
|
|
8022
8042
|
for (const name of STATE_TYPES) {
|
|
8023
8043
|
if (name === "initial") {
|
|
8024
|
-
if (!
|
|
8044
|
+
if (!isInitial) {
|
|
8025
8045
|
continue;
|
|
8026
8046
|
}
|
|
8027
|
-
this.isFirstAnimate = false;
|
|
8028
8047
|
}
|
|
8029
|
-
if (!this.activeStates[name])
|
|
8048
|
+
if (!this.activeStates[name] && name !== "initial") {
|
|
8030
8049
|
continue;
|
|
8050
|
+
}
|
|
8031
8051
|
const definition = isDef(this.options[name]) ? this.options[name] : this.context[name];
|
|
8032
8052
|
const variant = resolveVariant(
|
|
8033
8053
|
definition,
|
|
@@ -8083,11 +8103,10 @@ class MotionState {
|
|
|
8083
8103
|
let getChildAnimations = () => Promise.resolve();
|
|
8084
8104
|
let childAnimations = [];
|
|
8085
8105
|
if (Object.keys(activeState).length) {
|
|
8086
|
-
const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState);
|
|
8106
|
+
const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState, isInitial);
|
|
8087
8107
|
getChildAnimations = getAnimations;
|
|
8088
8108
|
childAnimations = animations2;
|
|
8089
8109
|
}
|
|
8090
|
-
yield;
|
|
8091
8110
|
let animations;
|
|
8092
8111
|
const getAnimation = () => {
|
|
8093
8112
|
animations = animationFactories.map((factory) => factory()).filter(Boolean);
|
|
@@ -8125,12 +8144,22 @@ class MotionState {
|
|
|
8125
8144
|
getOptions() {
|
|
8126
8145
|
return this.options;
|
|
8127
8146
|
}
|
|
8147
|
+
willUpdate(label) {
|
|
8148
|
+
var _a;
|
|
8149
|
+
(_a = this.visualElement.projection) == null ? void 0 : _a.willUpdate();
|
|
8150
|
+
}
|
|
8128
8151
|
}
|
|
8129
8152
|
function getMotionElement(el) {
|
|
8130
8153
|
if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
|
|
8131
8154
|
return getMotionElement(el.nextSibling);
|
|
8132
8155
|
return el;
|
|
8133
8156
|
}
|
|
8157
|
+
function checkMotionIsHidden(instance) {
|
|
8158
|
+
var _a;
|
|
8159
|
+
const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
|
|
8160
|
+
const hasTransition = instance.$.vnode.transition;
|
|
8161
|
+
return hasTransition && isHidden;
|
|
8162
|
+
}
|
|
8134
8163
|
const defaultConfig = {
|
|
8135
8164
|
reduceMotion: "never",
|
|
8136
8165
|
transition: void 0,
|
|
@@ -8160,6 +8189,8 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8160
8189
|
transition: {},
|
|
8161
8190
|
layoutGroup: {},
|
|
8162
8191
|
motionConfig: {},
|
|
8192
|
+
onAnimationComplete: { type: Function },
|
|
8193
|
+
onUpdate: { type: Function },
|
|
8163
8194
|
layout: { type: [Boolean, String] },
|
|
8164
8195
|
layoutId: {},
|
|
8165
8196
|
layoutScroll: { type: Boolean },
|
|
@@ -8213,22 +8244,33 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8213
8244
|
dragElastic: 0.2,
|
|
8214
8245
|
dragMomentum: true,
|
|
8215
8246
|
whileDrag: void 0,
|
|
8216
|
-
crossfade:
|
|
8247
|
+
crossfade: true
|
|
8217
8248
|
}),
|
|
8218
8249
|
setup(__props) {
|
|
8219
8250
|
const props = __props;
|
|
8220
|
-
const
|
|
8251
|
+
const animatePresenceContext = injectAnimatePresence({});
|
|
8221
8252
|
const parentState = injectMotion(null);
|
|
8222
8253
|
const attrs = vue.useAttrs();
|
|
8223
8254
|
const layoutGroup = injectLayoutGroup({});
|
|
8224
8255
|
const config = useMotionConfig();
|
|
8225
|
-
|
|
8226
|
-
|
|
8256
|
+
function getLayoutId() {
|
|
8257
|
+
if (layoutGroup.id && props.layoutId)
|
|
8258
|
+
return `${layoutGroup.id}-${props.layoutId}`;
|
|
8259
|
+
return props.layoutId || void 0;
|
|
8260
|
+
}
|
|
8261
|
+
function getMotionProps() {
|
|
8262
|
+
return {
|
|
8227
8263
|
...attrs,
|
|
8228
8264
|
...props,
|
|
8265
|
+
layoutId: getLayoutId(),
|
|
8266
|
+
transition: props.transition ?? config.value.transition,
|
|
8229
8267
|
layoutGroup,
|
|
8230
|
-
motionConfig: config.value
|
|
8231
|
-
|
|
8268
|
+
motionConfig: config.value,
|
|
8269
|
+
initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
|
|
8270
|
+
};
|
|
8271
|
+
}
|
|
8272
|
+
const state2 = new MotionState(
|
|
8273
|
+
getMotionProps(),
|
|
8232
8274
|
parentState
|
|
8233
8275
|
);
|
|
8234
8276
|
provideMotion(state2);
|
|
@@ -8237,29 +8279,20 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8237
8279
|
state2.beforeMount();
|
|
8238
8280
|
});
|
|
8239
8281
|
vue.onMounted(() => {
|
|
8240
|
-
state2.mount(getMotionElement(instance.$el),
|
|
8241
|
-
...attrs,
|
|
8242
|
-
...props,
|
|
8243
|
-
transition: props.transition ?? config.value.transition,
|
|
8244
|
-
layoutGroup,
|
|
8245
|
-
motionConfig: config.value,
|
|
8246
|
-
initial: presenceInitial.value === false ? presenceInitial.value : props.initial === true ? void 0 : props.initial
|
|
8247
|
-
});
|
|
8282
|
+
state2.mount(getMotionElement(instance.$el), getMotionProps(), checkMotionIsHidden(instance));
|
|
8248
8283
|
});
|
|
8249
8284
|
vue.onBeforeUnmount(() => state2.beforeUnmount());
|
|
8250
8285
|
vue.onUnmounted(() => {
|
|
8251
|
-
|
|
8286
|
+
const el = getMotionElement(instance.$el);
|
|
8287
|
+
if (!(el == null ? void 0 : el.isConnected)) {
|
|
8252
8288
|
state2.unmount();
|
|
8289
|
+
}
|
|
8290
|
+
});
|
|
8291
|
+
vue.onBeforeUpdate(() => {
|
|
8292
|
+
state2.beforeUpdate();
|
|
8253
8293
|
});
|
|
8254
|
-
vue.onBeforeUpdate(() => state2.beforeUpdate());
|
|
8255
8294
|
vue.onUpdated(() => {
|
|
8256
|
-
state2.update(
|
|
8257
|
-
...attrs,
|
|
8258
|
-
...props,
|
|
8259
|
-
transition: props.transition ?? config.value.transition,
|
|
8260
|
-
motionConfig: config.value,
|
|
8261
|
-
initial: presenceInitial.value === false ? presenceInitial.value : props.initial === true ? void 0 : props.initial
|
|
8262
|
-
});
|
|
8295
|
+
state2.update(getMotionProps());
|
|
8263
8296
|
});
|
|
8264
8297
|
function getProps() {
|
|
8265
8298
|
const isSVG = state2.visualElement.type === "svg";
|
|
@@ -8278,7 +8311,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8278
8311
|
Object.assign(styleProps, style2);
|
|
8279
8312
|
}
|
|
8280
8313
|
if (!state2.isMounted()) {
|
|
8281
|
-
Object.assign(styleProps, state2.
|
|
8314
|
+
Object.assign(styleProps, state2.baseTarget);
|
|
8282
8315
|
}
|
|
8283
8316
|
if (props.drag && props.dragListener !== false) {
|
|
8284
8317
|
Object.assign(styleProps, {
|
|
@@ -8296,15 +8329,16 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8296
8329
|
return attrsProps;
|
|
8297
8330
|
}
|
|
8298
8331
|
return (_ctx, _cache) => {
|
|
8299
|
-
return vue.openBlock(), vue.createBlock(vue.unref(Primitive), vue.mergeProps({
|
|
8332
|
+
return vue.openBlock(), vue.createBlock(vue.unref(Primitive), vue.mergeProps(getProps(), {
|
|
8300
8333
|
as: _ctx.as,
|
|
8301
|
-
"as-child": _ctx.asChild
|
|
8302
|
-
|
|
8334
|
+
"as-child": _ctx.asChild,
|
|
8335
|
+
"data-motion-id": vue.unref(state2).id
|
|
8336
|
+
}), {
|
|
8303
8337
|
default: vue.withCtx(() => [
|
|
8304
8338
|
vue.renderSlot(_ctx.$slots, "default")
|
|
8305
8339
|
]),
|
|
8306
8340
|
_: 3
|
|
8307
|
-
}, 16, ["as", "as-child"]);
|
|
8341
|
+
}, 16, ["as", "as-child", "data-motion-id"]);
|
|
8308
8342
|
};
|
|
8309
8343
|
}
|
|
8310
8344
|
});
|
|
@@ -8366,19 +8400,28 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8366
8400
|
mode: { default: "sync" },
|
|
8367
8401
|
initial: { type: Boolean, default: true },
|
|
8368
8402
|
multiple: { type: Boolean, default: false },
|
|
8369
|
-
as: {}
|
|
8403
|
+
as: {},
|
|
8404
|
+
custom: {},
|
|
8405
|
+
onExitComplete: {}
|
|
8370
8406
|
},
|
|
8371
8407
|
setup(__props) {
|
|
8372
8408
|
const props = __props;
|
|
8373
|
-
const
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8409
|
+
const presenceContext = {
|
|
8410
|
+
initial: props.initial,
|
|
8411
|
+
custom: props.custom
|
|
8412
|
+
};
|
|
8413
|
+
provideAnimatePresence(presenceContext);
|
|
8414
|
+
vue.onMounted(() => {
|
|
8415
|
+
presenceContext.initial = void 0;
|
|
8379
8416
|
});
|
|
8380
8417
|
function enter(el) {
|
|
8381
8418
|
const state2 = mountedStates.get(el);
|
|
8419
|
+
const motionStateId = el.dataset.motionId;
|
|
8420
|
+
const motionState = mountedStates.get(motionStateId);
|
|
8421
|
+
if (motionState) {
|
|
8422
|
+
const baseStyle = createStyles(motionState.baseTarget);
|
|
8423
|
+
Object.assign(el.style, baseStyle);
|
|
8424
|
+
}
|
|
8382
8425
|
if (!state2) {
|
|
8383
8426
|
return;
|
|
8384
8427
|
}
|
|
@@ -8386,22 +8429,35 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8386
8429
|
state2.setActive("exit", false);
|
|
8387
8430
|
}
|
|
8388
8431
|
const { addPopStyle, removePopStyle } = usePopLayout(props);
|
|
8432
|
+
const exitDom = /* @__PURE__ */ new Map();
|
|
8433
|
+
vue.onUnmounted(() => {
|
|
8434
|
+
exitDom.clear();
|
|
8435
|
+
});
|
|
8389
8436
|
function exit(el, done) {
|
|
8390
8437
|
const state2 = mountedStates.get(el);
|
|
8391
8438
|
if (!state2) {
|
|
8392
8439
|
return done();
|
|
8393
8440
|
}
|
|
8441
|
+
exitDom.set(el, true);
|
|
8394
8442
|
removeDoneCallback(el);
|
|
8395
8443
|
addPopStyle(state2);
|
|
8396
8444
|
function doneCallback(e) {
|
|
8397
8445
|
var _a, _b;
|
|
8398
|
-
removePopStyle(state2);
|
|
8399
8446
|
if ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.isExit) {
|
|
8447
|
+
const projection = state2.visualElement.projection;
|
|
8448
|
+
if ((projection == null ? void 0 : projection.animationProgress) > 0 && !state2.isSafeToRemove) {
|
|
8449
|
+
return;
|
|
8450
|
+
}
|
|
8451
|
+
state2.willUpdate("done");
|
|
8452
|
+
removePopStyle(state2);
|
|
8400
8453
|
removeDoneCallback(el);
|
|
8401
|
-
|
|
8454
|
+
exitDom.delete(el);
|
|
8455
|
+
if (exitDom.size === 0) {
|
|
8456
|
+
(_b = props.onExitComplete) == null ? void 0 : _b.call(props);
|
|
8457
|
+
}
|
|
8402
8458
|
done();
|
|
8403
|
-
if (!el.isConnected) {
|
|
8404
|
-
state2.unmount();
|
|
8459
|
+
if (!(el == null ? void 0 : el.isConnected)) {
|
|
8460
|
+
state2.unmount(true);
|
|
8405
8461
|
}
|
|
8406
8462
|
}
|
|
8407
8463
|
}
|
|
@@ -8425,6 +8481,31 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8425
8481
|
};
|
|
8426
8482
|
}
|
|
8427
8483
|
});
|
|
8484
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
8485
|
+
...{
|
|
8486
|
+
name: "MotionConfig",
|
|
8487
|
+
inheritAttrs: false
|
|
8488
|
+
},
|
|
8489
|
+
__name: "MotionConfig",
|
|
8490
|
+
props: {
|
|
8491
|
+
transition: {},
|
|
8492
|
+
reduceMotion: { default: defaultConfig.reduceMotion },
|
|
8493
|
+
nonce: {}
|
|
8494
|
+
},
|
|
8495
|
+
setup(__props) {
|
|
8496
|
+
const props = __props;
|
|
8497
|
+
const parentConfig = useMotionConfig();
|
|
8498
|
+
const config = vue.computed(() => ({
|
|
8499
|
+
transition: props.transition ?? parentConfig.value.transition,
|
|
8500
|
+
reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
|
|
8501
|
+
nonce: props.nonce ?? parentConfig.value.nonce
|
|
8502
|
+
}));
|
|
8503
|
+
provideMotionConfig(config);
|
|
8504
|
+
return (_ctx, _cache) => {
|
|
8505
|
+
return vue.renderSlot(_ctx.$slots, "default");
|
|
8506
|
+
};
|
|
8507
|
+
}
|
|
8508
|
+
});
|
|
8428
8509
|
function useForceUpdate() {
|
|
8429
8510
|
const key = vue.ref(0);
|
|
8430
8511
|
function forceUpdate() {
|
|
@@ -8454,9 +8535,12 @@ function nodeGroup() {
|
|
|
8454
8535
|
unsubscribe();
|
|
8455
8536
|
subscriptions.delete(node);
|
|
8456
8537
|
}
|
|
8457
|
-
dirtyAll();
|
|
8458
8538
|
},
|
|
8459
|
-
dirty: dirtyAll
|
|
8539
|
+
dirty: dirtyAll,
|
|
8540
|
+
didUpdate: () => {
|
|
8541
|
+
var _a;
|
|
8542
|
+
(_a = nodes[0]) == null ? void 0 : _a.didUpdate();
|
|
8543
|
+
}
|
|
8460
8544
|
};
|
|
8461
8545
|
}
|
|
8462
8546
|
function useLayoutGroupProvider(props) {
|
|
@@ -8488,7 +8572,7 @@ function getGroup(props, parentGroup) {
|
|
|
8488
8572
|
const shouldInherit = props.inherit === true || props.inherit === "group";
|
|
8489
8573
|
return shouldInherit ? (parentGroup == null ? void 0 : parentGroup.group) || nodeGroup() : nodeGroup();
|
|
8490
8574
|
}
|
|
8491
|
-
const _sfc_main
|
|
8575
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
8492
8576
|
__name: "LayoutGroup",
|
|
8493
8577
|
props: {
|
|
8494
8578
|
id: {},
|
|
@@ -8497,8 +8581,6 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8497
8581
|
setup(__props) {
|
|
8498
8582
|
const props = __props;
|
|
8499
8583
|
const { forceRender, key, group } = useLayoutGroupProvider(props);
|
|
8500
|
-
vue.onUpdated(() => {
|
|
8501
|
-
});
|
|
8502
8584
|
vue.onBeforeUpdate(() => {
|
|
8503
8585
|
group.dirty();
|
|
8504
8586
|
});
|
|
@@ -8510,31 +8592,6 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8510
8592
|
};
|
|
8511
8593
|
}
|
|
8512
8594
|
});
|
|
8513
|
-
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
8514
|
-
...{
|
|
8515
|
-
name: "MotionConfig",
|
|
8516
|
-
inheritAttrs: false
|
|
8517
|
-
},
|
|
8518
|
-
__name: "MotionConfig",
|
|
8519
|
-
props: {
|
|
8520
|
-
transition: {},
|
|
8521
|
-
reduceMotion: { default: defaultConfig.reduceMotion },
|
|
8522
|
-
nonce: {}
|
|
8523
|
-
},
|
|
8524
|
-
setup(__props) {
|
|
8525
|
-
const props = __props;
|
|
8526
|
-
const parentConfig = useMotionConfig();
|
|
8527
|
-
const config = vue.computed(() => ({
|
|
8528
|
-
transition: props.transition ?? parentConfig.value.transition,
|
|
8529
|
-
reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
|
|
8530
|
-
nonce: props.nonce ?? parentConfig.value.nonce
|
|
8531
|
-
}));
|
|
8532
|
-
provideMotionConfig(config);
|
|
8533
|
-
return (_ctx, _cache) => {
|
|
8534
|
-
return vue.renderSlot(_ctx.$slots, "default");
|
|
8535
|
-
};
|
|
8536
|
-
}
|
|
8537
|
-
});
|
|
8538
8595
|
function useCombineMotionValues(combineValues) {
|
|
8539
8596
|
const value = motionValue(combineValues());
|
|
8540
8597
|
const updateValue = () => value.set(combineValues());
|
|
@@ -8739,7 +8796,8 @@ const components = {
|
|
|
8739
8796
|
motion: [
|
|
8740
8797
|
"Motion",
|
|
8741
8798
|
"AnimatePresence",
|
|
8742
|
-
"LayoutGroup"
|
|
8799
|
+
"LayoutGroup",
|
|
8800
|
+
"MotionConfig"
|
|
8743
8801
|
]
|
|
8744
8802
|
};
|
|
8745
8803
|
const utilities = {
|
|
@@ -8789,9 +8847,9 @@ Object.defineProperty(exports, "isDragActive", {
|
|
|
8789
8847
|
get: () => motionDom.isDragActive
|
|
8790
8848
|
});
|
|
8791
8849
|
exports.AnimatePresence = _sfc_main$2;
|
|
8792
|
-
exports.LayoutGroup = _sfc_main
|
|
8850
|
+
exports.LayoutGroup = _sfc_main;
|
|
8793
8851
|
exports.Motion = _sfc_main$3;
|
|
8794
|
-
exports.MotionConfig = _sfc_main;
|
|
8852
|
+
exports.MotionConfig = _sfc_main$1;
|
|
8795
8853
|
exports.MotionValue = MotionValue;
|
|
8796
8854
|
exports.animate = animate;
|
|
8797
8855
|
exports.animateMini = animateMini;
|