motion-v 0.6.1 → 0.7.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 +213 -165
- package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +19 -8
- package/dist/es/components/animate-presence/utils.mjs +10 -0
- package/dist/es/components/{Motion.vue.mjs → motion/Motion.vue.mjs} +7 -7
- package/dist/es/components/motion/NameSpace.mjs +47 -0
- package/dist/es/constants/index.mjs +3 -1
- package/dist/es/features/gestures/drag/use-drag-controls.mjs +43 -0
- package/dist/es/features/gestures/in-view/index.mjs +25 -5
- package/dist/es/features/layout/projection.mjs +7 -30
- package/dist/es/index.mjs +8 -4
- package/dist/es/state/motion-state.mjs +69 -53
- package/dist/es/state/transform.mjs +1 -0
- package/dist/src/components/LayoutGroup.d.ts +10 -1
- package/dist/src/components/animate-presence/AnimatePresence.d.ts +27 -2
- package/dist/src/components/animate-presence/utils.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/{Motion.d.ts → motion/Motion.d.ts} +2 -2
- package/dist/src/components/motion/NameSpace.d.ts +11 -0
- package/dist/src/components/{Primitive.d.ts → motion/Primitive.d.ts} +5 -5
- package/dist/src/components/{Slot.d.ts → motion/Slot.d.ts} +1 -1
- package/dist/src/components/motion/index.d.ts +2 -0
- package/dist/src/components/motion-config/MotionConfig.d.ts +23 -2
- package/dist/src/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
- package/dist/src/features/gestures/in-view/index.d.ts +2 -0
- package/dist/src/features/layout/projection.d.ts +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/shared/test.d.ts +1 -0
- package/dist/src/state/animate-variants-children.d.ts +2 -2
- package/dist/src/state/motion-state.d.ts +4 -1
- package/dist/src/state/utils.d.ts +3 -3
- package/dist/src/types/framer-motion.d.ts +17 -0
- package/dist/src/types/state.d.ts +6 -14
- package/dist/src/utils/use-dom-ref.d.ts +1 -2
- package/dist/src/utils/use-in-view.d.ts +1 -1
- package/package.json +1 -2
- package/dist/es/external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs +0 -6
- package/dist/es/state/animate-variants-children.mjs +0 -74
- package/dist/src/utils/events.d.ts +0 -2
- /package/dist/es/components/{Motion.vue2.mjs → motion/Motion.vue2.mjs} +0 -0
- /package/dist/es/components/{Primitive.mjs → motion/Primitive.mjs} +0 -0
- /package/dist/es/components/{Slot.mjs → motion/Slot.mjs} +0 -0
- /package/dist/es/components/{renderSlotFragments.mjs → motion/renderSlotFragments.mjs} +0 -0
- /package/dist/es/components/{utils.mjs → motion/utils.mjs} +0 -0
- /package/dist/src/components/{renderSlotFragments.d.ts → motion/renderSlotFragments.d.ts} +0 -0
- /package/dist/src/components/{utils.d.ts → motion/utils.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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");
|
|
4
5
|
const heyListen = require("hey-listen");
|
|
5
6
|
const noop = (any) => any;
|
|
6
7
|
let warning = noop;
|
|
@@ -5081,8 +5082,6 @@ const svgElementSet = new Set(svgElements);
|
|
|
5081
5082
|
function isSVGElement$1(as) {
|
|
5082
5083
|
return svgElementSet.has(as);
|
|
5083
5084
|
}
|
|
5084
|
-
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
5085
|
-
const isDef = (val) => typeof val !== "undefined";
|
|
5086
5085
|
const rotation = {
|
|
5087
5086
|
syntax: "<angle>",
|
|
5088
5087
|
initialValue: "0deg",
|
|
@@ -5433,20 +5432,40 @@ class InViewGesture extends Feature {
|
|
|
5433
5432
|
constructor(state2) {
|
|
5434
5433
|
super(state2);
|
|
5435
5434
|
}
|
|
5436
|
-
|
|
5435
|
+
startObserver() {
|
|
5437
5436
|
const element = this.state.element;
|
|
5438
5437
|
if (!element)
|
|
5439
5438
|
return;
|
|
5439
|
+
this.unmount();
|
|
5440
|
+
const { once, ...viewOptions } = this.state.getOptions().inViewOptions || {};
|
|
5440
5441
|
this.unmount = inView(
|
|
5441
5442
|
element,
|
|
5442
5443
|
(entry) => {
|
|
5443
5444
|
handleHoverEvent(this.state, entry, "Enter");
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5445
|
+
if (!once) {
|
|
5446
|
+
return (endEvent) => {
|
|
5447
|
+
handleHoverEvent(this.state, entry, "Leave");
|
|
5448
|
+
};
|
|
5449
|
+
}
|
|
5450
|
+
},
|
|
5451
|
+
viewOptions
|
|
5448
5452
|
);
|
|
5449
5453
|
}
|
|
5454
|
+
mount() {
|
|
5455
|
+
this.startObserver();
|
|
5456
|
+
}
|
|
5457
|
+
update() {
|
|
5458
|
+
const { props, prevProps } = this.state.visualElement;
|
|
5459
|
+
const hasOptionsChanged = ["amount", "margin", "root"].some(
|
|
5460
|
+
hasViewportOptionChanged(props, prevProps)
|
|
5461
|
+
);
|
|
5462
|
+
if (hasOptionsChanged) {
|
|
5463
|
+
this.startObserver();
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
function hasViewportOptionChanged({ inViewOptions = {} }, { inViewOptions: prevViewport = {} } = {}) {
|
|
5468
|
+
return (name) => inViewOptions[name] !== prevViewport[name];
|
|
5450
5469
|
}
|
|
5451
5470
|
function isPrimaryPointer(event) {
|
|
5452
5471
|
if (event.pointerType === "mouse") {
|
|
@@ -7897,43 +7916,17 @@ class ProjectionFeature extends Feature {
|
|
|
7897
7916
|
options["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(this.state.visualElement.parent)
|
|
7898
7917
|
);
|
|
7899
7918
|
this.state.visualElement.projection.isPresent = true;
|
|
7900
|
-
this.
|
|
7901
|
-
layout: options.layout,
|
|
7902
|
-
layoutId: options.layoutId,
|
|
7903
|
-
// TODO: drag
|
|
7904
|
-
alwaysMeasureLayout: false,
|
|
7905
|
-
visualElement: this.state.visualElement,
|
|
7906
|
-
animationType: typeof options.layout === "string" ? options.layout : "both",
|
|
7907
|
-
// initialPromotionConfig
|
|
7908
|
-
layoutRoot: options.layoutRoot,
|
|
7909
|
-
layoutScroll: options.layoutScroll,
|
|
7910
|
-
crossfade: options.crossfade,
|
|
7911
|
-
onExitComplete: () => {
|
|
7912
|
-
var _a;
|
|
7913
|
-
if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
|
|
7914
|
-
const done = doneCallbacks.get(this.state.element);
|
|
7915
|
-
this.state.isSafeToRemove = true;
|
|
7916
|
-
if (done) {
|
|
7917
|
-
done({
|
|
7918
|
-
detail: {
|
|
7919
|
-
isExit: true
|
|
7920
|
-
}
|
|
7921
|
-
}, true);
|
|
7922
|
-
}
|
|
7923
|
-
}
|
|
7924
|
-
}
|
|
7925
|
-
});
|
|
7919
|
+
this.setOptions();
|
|
7926
7920
|
}
|
|
7927
7921
|
beforeMount() {
|
|
7928
7922
|
this.initProjection();
|
|
7929
7923
|
}
|
|
7930
|
-
|
|
7924
|
+
setOptions() {
|
|
7931
7925
|
const options = this.state.options;
|
|
7932
7926
|
this.state.visualElement.projection.setOptions({
|
|
7933
7927
|
layout: options.layout,
|
|
7934
7928
|
layoutId: options.layoutId,
|
|
7935
|
-
|
|
7936
|
-
alwaysMeasureLayout: false,
|
|
7929
|
+
alwaysMeasureLayout: Boolean(options.drag) || options.dragConstraints && isHTMLElement(options.dragConstraints),
|
|
7937
7930
|
visualElement: this.state.visualElement,
|
|
7938
7931
|
animationType: typeof options.layout === "string" ? options.layout : "both",
|
|
7939
7932
|
// initialPromotionConfig
|
|
@@ -7942,6 +7935,9 @@ class ProjectionFeature extends Feature {
|
|
|
7942
7935
|
crossfade: options.crossfade
|
|
7943
7936
|
});
|
|
7944
7937
|
}
|
|
7938
|
+
update() {
|
|
7939
|
+
this.setOptions();
|
|
7940
|
+
}
|
|
7945
7941
|
mount() {
|
|
7946
7942
|
var _a;
|
|
7947
7943
|
(_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
|
|
@@ -7992,73 +7988,6 @@ function motionEvent(name, target, isExit) {
|
|
|
7992
7988
|
function createVisualElement(Component, options) {
|
|
7993
7989
|
return isSVGElement$1(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
|
|
7994
7990
|
}
|
|
7995
|
-
function animateVariantsChildren(state2, activeState, isFirstAnimate = false) {
|
|
7996
|
-
const variantChildren = state2.visualElement.variantChildren;
|
|
7997
|
-
if (!(variantChildren == null ? void 0 : variantChildren.size)) {
|
|
7998
|
-
return {
|
|
7999
|
-
animations: [],
|
|
8000
|
-
getAnimations: () => Promise.resolve()
|
|
8001
|
-
};
|
|
8002
|
-
}
|
|
8003
|
-
const animationFactories = [];
|
|
8004
|
-
Array.from(variantChildren).forEach((child, index) => {
|
|
8005
|
-
var _a;
|
|
8006
|
-
const prevTarget = isFirstAnimate ? child.state.baseTarget : child.state.target;
|
|
8007
|
-
const childState = child.state;
|
|
8008
|
-
childState.target = {};
|
|
8009
|
-
for (const name in activeState) {
|
|
8010
|
-
if (name === "initial" && !isFirstAnimate) {
|
|
8011
|
-
continue;
|
|
8012
|
-
}
|
|
8013
|
-
const { definition, transition } = activeState[name];
|
|
8014
|
-
const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
|
|
8015
|
-
const maxStaggerDuration = (variantChildren.size - 1) * staggerChildren;
|
|
8016
|
-
const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
8017
|
-
const variant = resolveVariant(
|
|
8018
|
-
definition,
|
|
8019
|
-
child.props.variants,
|
|
8020
|
-
child.props.custom
|
|
8021
|
-
);
|
|
8022
|
-
const animationOptions = {};
|
|
8023
|
-
const allTarget = { ...prevTarget, ...variant };
|
|
8024
|
-
for (const key in allTarget) {
|
|
8025
|
-
if (key === "transition")
|
|
8026
|
-
continue;
|
|
8027
|
-
childState.target[key] = allTarget[key];
|
|
8028
|
-
if (childState.target[key] === void 0) {
|
|
8029
|
-
childState.target[key] = childState.baseTarget[key];
|
|
8030
|
-
}
|
|
8031
|
-
if (hasChanged(prevTarget[key], childState.target[key])) {
|
|
8032
|
-
(_a = childState.baseTarget)[key] ?? (_a[key] = style.get(child.current, key));
|
|
8033
|
-
animationOptions[key] = getOptions(
|
|
8034
|
-
Object.assign({}, transition, allTarget.transition, child.props.transition),
|
|
8035
|
-
key
|
|
8036
|
-
);
|
|
8037
|
-
const keyValue = childState.target[key] === "none" ? transformResetValue[key] : childState.target[key];
|
|
8038
|
-
animationFactories.push(
|
|
8039
|
-
() => {
|
|
8040
|
-
var _a2;
|
|
8041
|
-
return animate(
|
|
8042
|
-
child.current,
|
|
8043
|
-
{
|
|
8044
|
-
[key]: keyValue
|
|
8045
|
-
},
|
|
8046
|
-
{
|
|
8047
|
-
...animationOptions[key] || {},
|
|
8048
|
-
delay: (((_a2 = animationOptions[key]) == null ? void 0 : _a2.delay) || 0) + delayChildren + generateStaggerDuration(index)
|
|
8049
|
-
}
|
|
8050
|
-
);
|
|
8051
|
-
}
|
|
8052
|
-
);
|
|
8053
|
-
}
|
|
8054
|
-
}
|
|
8055
|
-
}
|
|
8056
|
-
});
|
|
8057
|
-
return {
|
|
8058
|
-
animations: animationFactories,
|
|
8059
|
-
getAnimations: () => Promise.all(animationFactories.map((factory) => factory()))
|
|
8060
|
-
};
|
|
8061
|
-
}
|
|
8062
7991
|
const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
|
|
8063
7992
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
8064
7993
|
let id = 0;
|
|
@@ -8070,7 +7999,7 @@ class MotionState {
|
|
|
8070
7999
|
this.isVShow = false;
|
|
8071
8000
|
this.children = /* @__PURE__ */ new Set();
|
|
8072
8001
|
this.activeStates = {
|
|
8073
|
-
|
|
8002
|
+
initial: true,
|
|
8074
8003
|
animate: true
|
|
8075
8004
|
};
|
|
8076
8005
|
this._context = null;
|
|
@@ -8104,6 +8033,7 @@ class MotionState {
|
|
|
8104
8033
|
this.initTarget(initialVariantSource);
|
|
8105
8034
|
this.featureManager = new FeatureManager(this);
|
|
8106
8035
|
}
|
|
8036
|
+
// Get animation context, falling back to parent context
|
|
8107
8037
|
get context() {
|
|
8108
8038
|
if (!this._context) {
|
|
8109
8039
|
const handler = {
|
|
@@ -8116,13 +8046,16 @@ class MotionState {
|
|
|
8116
8046
|
}
|
|
8117
8047
|
return this._context;
|
|
8118
8048
|
}
|
|
8049
|
+
// Initialize animation target values
|
|
8119
8050
|
initTarget(initialVariantSource) {
|
|
8120
8051
|
this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
|
|
8121
8052
|
this.target = {};
|
|
8122
8053
|
}
|
|
8054
|
+
// Get initial animation state
|
|
8123
8055
|
get initial() {
|
|
8124
|
-
return isDef(this.options.initial) ? this.options.initial : this.context.initial;
|
|
8056
|
+
return core.isDef(this.options.initial) ? this.options.initial : this.context.initial;
|
|
8125
8057
|
}
|
|
8058
|
+
// Update visual element with new options
|
|
8126
8059
|
updateOptions() {
|
|
8127
8060
|
this.visualElement.update({
|
|
8128
8061
|
...this.options,
|
|
@@ -8137,6 +8070,7 @@ class MotionState {
|
|
|
8137
8070
|
beforeMount() {
|
|
8138
8071
|
this.featureManager.beforeMount();
|
|
8139
8072
|
}
|
|
8073
|
+
// Mount motion state to DOM element
|
|
8140
8074
|
mount(element, options, notAnimate = false) {
|
|
8141
8075
|
heyListen.invariant(
|
|
8142
8076
|
Boolean(element),
|
|
@@ -8161,13 +8095,14 @@ class MotionState {
|
|
|
8161
8095
|
}
|
|
8162
8096
|
}
|
|
8163
8097
|
this.featureManager.mount();
|
|
8164
|
-
if (!notAnimate) {
|
|
8165
|
-
this.animateUpdates(
|
|
8098
|
+
if (!notAnimate && this.options.animate) {
|
|
8099
|
+
this.animateUpdates();
|
|
8166
8100
|
}
|
|
8167
8101
|
}
|
|
8168
8102
|
beforeUnmount() {
|
|
8169
8103
|
this.featureManager.beforeUnmount();
|
|
8170
8104
|
}
|
|
8105
|
+
// Unmount motion state and optionally unmount children
|
|
8171
8106
|
unmount(unMountChildren = false) {
|
|
8172
8107
|
var _a, _b, _c;
|
|
8173
8108
|
mountedStates.delete(this.element);
|
|
@@ -8193,6 +8128,7 @@ class MotionState {
|
|
|
8193
8128
|
beforeUpdate() {
|
|
8194
8129
|
this.featureManager.beforeUpdate();
|
|
8195
8130
|
}
|
|
8131
|
+
// Update motion state with new options
|
|
8196
8132
|
update(options, notAnimate = false) {
|
|
8197
8133
|
const prevAnimate = JSON.stringify(this.options.animate);
|
|
8198
8134
|
this.options = options;
|
|
@@ -8206,6 +8142,7 @@ class MotionState {
|
|
|
8206
8142
|
this.animateUpdates();
|
|
8207
8143
|
}
|
|
8208
8144
|
}
|
|
8145
|
+
// Set animation state active status
|
|
8209
8146
|
setActive(name, isActive, isAnimate = true) {
|
|
8210
8147
|
var _a;
|
|
8211
8148
|
if (!this.element || this.activeStates[name] === isActive)
|
|
@@ -8218,37 +8155,32 @@ class MotionState {
|
|
|
8218
8155
|
this.animateUpdates();
|
|
8219
8156
|
}
|
|
8220
8157
|
}
|
|
8221
|
-
|
|
8158
|
+
// Core animation update logic
|
|
8159
|
+
animateUpdates(controlActiveState = void 0, controlDelay = 0) {
|
|
8160
|
+
var _a;
|
|
8222
8161
|
const prevTarget = this.target;
|
|
8223
|
-
this.target = {
|
|
8224
|
-
|
|
8162
|
+
this.target = {
|
|
8163
|
+
...this.baseTarget
|
|
8164
|
+
};
|
|
8225
8165
|
const animationOptions = {};
|
|
8226
8166
|
let transition;
|
|
8167
|
+
if (controlActiveState) {
|
|
8168
|
+
this.activeStates = { ...this.activeStates, ...controlActiveState };
|
|
8169
|
+
}
|
|
8227
8170
|
for (const name of STATE_TYPES) {
|
|
8228
|
-
if (name
|
|
8229
|
-
if (!isInitial) {
|
|
8230
|
-
continue;
|
|
8231
|
-
}
|
|
8232
|
-
}
|
|
8233
|
-
if (!this.activeStates[name] && name !== "initial") {
|
|
8171
|
+
if (!this.activeStates[name]) {
|
|
8234
8172
|
continue;
|
|
8235
8173
|
}
|
|
8236
|
-
const definition = isDef(this.options[name]) ? this.options[name] : this.context[name];
|
|
8174
|
+
const definition = core.isDef(this.options[name]) ? this.options[name] : this.context[name];
|
|
8237
8175
|
const variant = resolveVariant(
|
|
8238
8176
|
definition,
|
|
8239
8177
|
this.options.variants,
|
|
8240
8178
|
this.options.custom
|
|
8241
8179
|
);
|
|
8242
8180
|
transition = Object.assign({}, this.options.transition, variant == null ? void 0 : variant.transition);
|
|
8243
|
-
if (typeof definition === "string") {
|
|
8244
|
-
activeState[name] = {
|
|
8245
|
-
definition,
|
|
8246
|
-
transition
|
|
8247
|
-
};
|
|
8248
|
-
}
|
|
8249
8181
|
if (!variant)
|
|
8250
8182
|
continue;
|
|
8251
|
-
const allTarget = { ...
|
|
8183
|
+
const allTarget = { ...variant };
|
|
8252
8184
|
for (const key in allTarget) {
|
|
8253
8185
|
if (key === "transition")
|
|
8254
8186
|
continue;
|
|
@@ -8260,18 +8192,15 @@ class MotionState {
|
|
|
8260
8192
|
}
|
|
8261
8193
|
}
|
|
8262
8194
|
const allTargetKeys = /* @__PURE__ */ new Set([
|
|
8263
|
-
...Object.keys(this.target)
|
|
8264
|
-
...Object.keys(prevTarget)
|
|
8195
|
+
...Object.keys(this.target)
|
|
8265
8196
|
]);
|
|
8266
8197
|
const animationFactories = [];
|
|
8267
8198
|
allTargetKeys.forEach((key) => {
|
|
8268
|
-
var
|
|
8269
|
-
if (this.target[key] === void 0) {
|
|
8270
|
-
this.target[key] = this.baseTarget[key];
|
|
8271
|
-
}
|
|
8199
|
+
var _a2;
|
|
8272
8200
|
if (hasChanged(prevTarget[key], this.target[key])) {
|
|
8273
|
-
(
|
|
8201
|
+
(_a2 = this.baseTarget)[key] ?? (_a2[key] = style.get(this.element, key));
|
|
8274
8202
|
const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
|
|
8203
|
+
const targetTransition = animationOptions[key];
|
|
8275
8204
|
animationFactories.push(
|
|
8276
8205
|
() => {
|
|
8277
8206
|
return animate(
|
|
@@ -8279,7 +8208,10 @@ class MotionState {
|
|
|
8279
8208
|
{
|
|
8280
8209
|
[key]: keyValue
|
|
8281
8210
|
},
|
|
8282
|
-
|
|
8211
|
+
{
|
|
8212
|
+
...targetTransition,
|
|
8213
|
+
delay: ((targetTransition == null ? void 0 : targetTransition.delay) || 0) + controlDelay
|
|
8214
|
+
}
|
|
8283
8215
|
);
|
|
8284
8216
|
}
|
|
8285
8217
|
);
|
|
@@ -8287,10 +8219,15 @@ class MotionState {
|
|
|
8287
8219
|
});
|
|
8288
8220
|
let getChildAnimations = () => Promise.resolve();
|
|
8289
8221
|
let childAnimations = [];
|
|
8290
|
-
if (
|
|
8291
|
-
const {
|
|
8292
|
-
|
|
8293
|
-
|
|
8222
|
+
if (((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) && !controlActiveState) {
|
|
8223
|
+
const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
|
|
8224
|
+
const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
|
|
8225
|
+
const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
8226
|
+
childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
|
|
8227
|
+
const childDelay = delayChildren + generateStaggerDuration(index);
|
|
8228
|
+
return child.state.animateUpdates(this.activeStates, childDelay);
|
|
8229
|
+
}).filter(Boolean);
|
|
8230
|
+
getChildAnimations = () => Promise.all(childAnimations.map((animation) => animation()));
|
|
8294
8231
|
}
|
|
8295
8232
|
let animations;
|
|
8296
8233
|
const getAnimation = () => {
|
|
@@ -8299,29 +8236,38 @@ class MotionState {
|
|
|
8299
8236
|
};
|
|
8300
8237
|
const { when } = transition;
|
|
8301
8238
|
let animationPromise;
|
|
8302
|
-
if (when) {
|
|
8303
|
-
const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
|
|
8304
|
-
animationPromise = first().then(() => last());
|
|
8305
|
-
} else {
|
|
8306
|
-
animationPromise = Promise.all([getAnimation(), getChildAnimations()]);
|
|
8307
|
-
}
|
|
8308
8239
|
const isExit = this.activeStates.exit;
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8240
|
+
const animationTarget2 = { ...this.target };
|
|
8241
|
+
const element = this.element;
|
|
8242
|
+
function finishAnimation2() {
|
|
8243
|
+
if (!(animations == null ? void 0 : animations.length) && !childAnimations.length) {
|
|
8244
|
+
if (isExit) {
|
|
8245
|
+
element.dispatchEvent(motionEvent("motionstart", animationTarget2));
|
|
8246
|
+
element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
|
|
8247
|
+
}
|
|
8248
|
+
return;
|
|
8249
|
+
}
|
|
8250
|
+
element.dispatchEvent(motionEvent("motionstart", animationTarget2));
|
|
8251
|
+
animationPromise.then(() => {
|
|
8252
|
+
element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
|
|
8253
|
+
}).catch(noop);
|
|
8254
|
+
}
|
|
8255
|
+
function getAnimationPromise() {
|
|
8256
|
+
if (when) {
|
|
8257
|
+
const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
|
|
8258
|
+
animationPromise = first().then(() => last());
|
|
8259
|
+
finishAnimation2();
|
|
8260
|
+
return animationPromise;
|
|
8261
|
+
} else {
|
|
8262
|
+
animationPromise = Promise.all([getAnimation(), getChildAnimations()]);
|
|
8263
|
+
finishAnimation2();
|
|
8264
|
+
return animationPromise;
|
|
8315
8265
|
}
|
|
8316
|
-
return;
|
|
8317
8266
|
}
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
...animationTarget2
|
|
8323
|
-
}, isExit));
|
|
8324
|
-
}).catch(noop);
|
|
8267
|
+
if (controlActiveState) {
|
|
8268
|
+
return getAnimationPromise;
|
|
8269
|
+
}
|
|
8270
|
+
getAnimationPromise();
|
|
8325
8271
|
}
|
|
8326
8272
|
isMounted() {
|
|
8327
8273
|
return Boolean(this.element);
|
|
@@ -8426,7 +8372,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8426
8372
|
layoutScroll: false,
|
|
8427
8373
|
layoutRoot: false,
|
|
8428
8374
|
dragListener: true,
|
|
8429
|
-
dragElastic: 0.
|
|
8375
|
+
dragElastic: 0.5,
|
|
8430
8376
|
dragMomentum: true,
|
|
8431
8377
|
whileDrag: void 0,
|
|
8432
8378
|
crossfade: true
|
|
@@ -8539,6 +8485,48 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8539
8485
|
};
|
|
8540
8486
|
}
|
|
8541
8487
|
});
|
|
8488
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
8489
|
+
const motion = new Proxy(_sfc_main$3, {
|
|
8490
|
+
get(target, prop) {
|
|
8491
|
+
if (typeof prop === "symbol")
|
|
8492
|
+
return target[prop];
|
|
8493
|
+
let motionComponent = componentCache.get(prop);
|
|
8494
|
+
if (prop === "create") {
|
|
8495
|
+
return (component) => {
|
|
8496
|
+
return vue.defineComponent({
|
|
8497
|
+
inheritAttrs: false,
|
|
8498
|
+
name: `motion.${component.$name}`,
|
|
8499
|
+
setup(_, { attrs, slots }) {
|
|
8500
|
+
return () => {
|
|
8501
|
+
return vue.h(_sfc_main$3, {
|
|
8502
|
+
...attrs,
|
|
8503
|
+
as: component,
|
|
8504
|
+
asChild: false
|
|
8505
|
+
}, slots);
|
|
8506
|
+
};
|
|
8507
|
+
}
|
|
8508
|
+
});
|
|
8509
|
+
};
|
|
8510
|
+
}
|
|
8511
|
+
if (!motionComponent) {
|
|
8512
|
+
motionComponent = vue.defineComponent({
|
|
8513
|
+
inheritAttrs: false,
|
|
8514
|
+
name: `motion.${prop}`,
|
|
8515
|
+
setup(_, { attrs, slots }) {
|
|
8516
|
+
return () => {
|
|
8517
|
+
return vue.h(_sfc_main$3, {
|
|
8518
|
+
...attrs,
|
|
8519
|
+
as: prop,
|
|
8520
|
+
asChild: false
|
|
8521
|
+
}, slots);
|
|
8522
|
+
};
|
|
8523
|
+
}
|
|
8524
|
+
});
|
|
8525
|
+
componentCache.set(prop, motionComponent);
|
|
8526
|
+
}
|
|
8527
|
+
return motionComponent;
|
|
8528
|
+
}
|
|
8529
|
+
});
|
|
8542
8530
|
function usePopLayout(props) {
|
|
8543
8531
|
const styles = /* @__PURE__ */ new WeakMap();
|
|
8544
8532
|
const config = useMotionConfig();
|
|
@@ -8590,6 +8578,13 @@ function usePopLayout(props) {
|
|
|
8590
8578
|
styles
|
|
8591
8579
|
};
|
|
8592
8580
|
}
|
|
8581
|
+
function requestIdleCallback$1(callback) {
|
|
8582
|
+
if (typeof requestIdleCallback$1 !== "undefined") {
|
|
8583
|
+
requestIdleCallback$1(callback);
|
|
8584
|
+
} else {
|
|
8585
|
+
setTimeout(callback, 50);
|
|
8586
|
+
}
|
|
8587
|
+
}
|
|
8593
8588
|
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
8594
8589
|
...{
|
|
8595
8590
|
name: "AnimatePresence",
|
|
@@ -8650,9 +8645,12 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8650
8645
|
}
|
|
8651
8646
|
if (!styles.has(state2)) {
|
|
8652
8647
|
state2.willUpdate("done");
|
|
8648
|
+
} else {
|
|
8649
|
+
requestIdleCallback$1(() => {
|
|
8650
|
+
removePopStyle(state2);
|
|
8651
|
+
});
|
|
8653
8652
|
}
|
|
8654
8653
|
done();
|
|
8655
|
-
removePopStyle(state2);
|
|
8656
8654
|
if (!(el == null ? void 0 : el.isConnected)) {
|
|
8657
8655
|
state2.unmount(true);
|
|
8658
8656
|
}
|
|
@@ -8662,19 +8660,26 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8662
8660
|
el.addEventListener("motioncomplete", doneCallback);
|
|
8663
8661
|
state2.setActive("exit", true);
|
|
8664
8662
|
}
|
|
8663
|
+
const transitionProps = vue.computed(() => {
|
|
8664
|
+
if (props.multiple) {
|
|
8665
|
+
return {
|
|
8666
|
+
tag: props.as
|
|
8667
|
+
};
|
|
8668
|
+
}
|
|
8669
|
+
return {
|
|
8670
|
+
mode: props.mode === "wait" ? "out-in" : void 0
|
|
8671
|
+
};
|
|
8672
|
+
});
|
|
8665
8673
|
return (_ctx, _cache) => {
|
|
8666
|
-
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.multiple ? vue.TransitionGroup : vue.Transition), {
|
|
8667
|
-
tag: _ctx.multiple ? _ctx.as : void 0,
|
|
8668
|
-
css: false,
|
|
8669
|
-
mode: _ctx.mode === "wait" ? "out-in" : void 0,
|
|
8674
|
+
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.multiple ? vue.TransitionGroup : vue.Transition), vue.mergeProps({ css: false }, transitionProps.value, {
|
|
8670
8675
|
onEnter: enter,
|
|
8671
8676
|
onLeave: exit
|
|
8672
|
-
}, {
|
|
8677
|
+
}), {
|
|
8673
8678
|
default: vue.withCtx(() => [
|
|
8674
8679
|
vue.renderSlot(_ctx.$slots, "default")
|
|
8675
8680
|
]),
|
|
8676
8681
|
_: 3
|
|
8677
|
-
},
|
|
8682
|
+
}, 16);
|
|
8678
8683
|
};
|
|
8679
8684
|
}
|
|
8680
8685
|
});
|
|
@@ -8988,6 +8993,7 @@ function useVelocity(value) {
|
|
|
8988
8993
|
}
|
|
8989
8994
|
const components = {
|
|
8990
8995
|
motion: [
|
|
8996
|
+
"motion",
|
|
8991
8997
|
"Motion",
|
|
8992
8998
|
"AnimatePresence",
|
|
8993
8999
|
"LayoutGroup",
|
|
@@ -9007,7 +9013,8 @@ const utilities = {
|
|
|
9007
9013
|
"useInView",
|
|
9008
9014
|
"useAnimationFrame",
|
|
9009
9015
|
"useMotionValueEvent",
|
|
9010
|
-
"useLayoutGroup"
|
|
9016
|
+
"useLayoutGroup",
|
|
9017
|
+
"useDragControls"
|
|
9011
9018
|
]
|
|
9012
9019
|
};
|
|
9013
9020
|
function useAnimate() {
|
|
@@ -9036,6 +9043,45 @@ function useAnimate() {
|
|
|
9036
9043
|
});
|
|
9037
9044
|
return [domProxy, animate2];
|
|
9038
9045
|
}
|
|
9046
|
+
class DragControls {
|
|
9047
|
+
constructor() {
|
|
9048
|
+
this.componentControls = /* @__PURE__ */ new Set();
|
|
9049
|
+
}
|
|
9050
|
+
/**
|
|
9051
|
+
* Subscribe a component's internal `VisualElementDragControls` to the user-facing API.
|
|
9052
|
+
*
|
|
9053
|
+
* @internal
|
|
9054
|
+
*/
|
|
9055
|
+
subscribe(controls) {
|
|
9056
|
+
this.componentControls.add(controls);
|
|
9057
|
+
return () => this.componentControls.delete(controls);
|
|
9058
|
+
}
|
|
9059
|
+
/**
|
|
9060
|
+
* Start a drag gesture on every `motion` component that has this set of drag controls
|
|
9061
|
+
* passed into it via the `dragControls` prop.
|
|
9062
|
+
*
|
|
9063
|
+
* ```jsx
|
|
9064
|
+
* dragControls.start(e, {
|
|
9065
|
+
* snapToCursor: true
|
|
9066
|
+
* })
|
|
9067
|
+
* ```
|
|
9068
|
+
*
|
|
9069
|
+
* @param event - PointerEvent
|
|
9070
|
+
* @param options - Options
|
|
9071
|
+
*
|
|
9072
|
+
* @public
|
|
9073
|
+
*/
|
|
9074
|
+
start(event, options) {
|
|
9075
|
+
this.componentControls.forEach((controls) => {
|
|
9076
|
+
controls.start(
|
|
9077
|
+
event,
|
|
9078
|
+
options
|
|
9079
|
+
);
|
|
9080
|
+
});
|
|
9081
|
+
}
|
|
9082
|
+
}
|
|
9083
|
+
const createDragControls = () => new DragControls();
|
|
9084
|
+
const useDragControls = createDragControls;
|
|
9039
9085
|
exports.AnimatePresence = _sfc_main$2;
|
|
9040
9086
|
exports.LayoutGroup = _sfc_main;
|
|
9041
9087
|
exports.Motion = _sfc_main$3;
|
|
@@ -9078,6 +9124,7 @@ exports.keyframes = keyframes;
|
|
|
9078
9124
|
exports.millisecondsToSeconds = millisecondsToSeconds;
|
|
9079
9125
|
exports.mirrorEasing = mirrorEasing;
|
|
9080
9126
|
exports.mix = mix;
|
|
9127
|
+
exports.motion = motion;
|
|
9081
9128
|
exports.motionValue = motionValue;
|
|
9082
9129
|
exports.noop = noop;
|
|
9083
9130
|
exports.pipe = pipe;
|
|
@@ -9099,6 +9146,7 @@ exports.useAnimate = useAnimate;
|
|
|
9099
9146
|
exports.useAnimationFrame = useAnimationFrame;
|
|
9100
9147
|
exports.useCombineMotionValues = useCombineMotionValues;
|
|
9101
9148
|
exports.useComputed = useComputed;
|
|
9149
|
+
exports.useDragControls = useDragControls;
|
|
9102
9150
|
exports.useInView = useInView;
|
|
9103
9151
|
exports.useLayoutGroup = useLayoutGroup;
|
|
9104
9152
|
exports.useMotionConfig = useMotionConfig;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { defineComponent, onMounted, onUnmounted, openBlock, createBlock, resolveDynamicComponent, TransitionGroup, Transition, withCtx, renderSlot } from "vue";
|
|
1
|
+
import { defineComponent, onMounted, onUnmounted, computed, openBlock, createBlock, resolveDynamicComponent, TransitionGroup, Transition, mergeProps, withCtx, renderSlot } from "vue";
|
|
2
2
|
import { mountedStates } from "../../state/motion-state.mjs";
|
|
3
3
|
import { provideAnimatePresence, removeDoneCallback, doneCallbacks } from "../presence.mjs";
|
|
4
4
|
import { usePopLayout } from "./use-pop-layout.mjs";
|
|
5
|
+
import { requestIdleCallback } from "./utils.mjs";
|
|
5
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
7
|
...{
|
|
7
8
|
name: "AnimatePresence",
|
|
@@ -62,9 +63,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
62
63
|
}
|
|
63
64
|
if (!styles.has(state)) {
|
|
64
65
|
state.willUpdate("done");
|
|
66
|
+
} else {
|
|
67
|
+
requestIdleCallback(() => {
|
|
68
|
+
removePopStyle(state);
|
|
69
|
+
});
|
|
65
70
|
}
|
|
66
71
|
done();
|
|
67
|
-
removePopStyle(state);
|
|
68
72
|
if (!(el == null ? void 0 : el.isConnected)) {
|
|
69
73
|
state.unmount(true);
|
|
70
74
|
}
|
|
@@ -74,19 +78,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
74
78
|
el.addEventListener("motioncomplete", doneCallback);
|
|
75
79
|
state.setActive("exit", true);
|
|
76
80
|
}
|
|
81
|
+
const transitionProps = computed(() => {
|
|
82
|
+
if (props.multiple) {
|
|
83
|
+
return {
|
|
84
|
+
tag: props.as
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
mode: props.mode === "wait" ? "out-in" : void 0
|
|
89
|
+
};
|
|
90
|
+
});
|
|
77
91
|
return (_ctx, _cache) => {
|
|
78
|
-
return openBlock(), createBlock(resolveDynamicComponent(_ctx.multiple ? TransitionGroup : Transition), {
|
|
79
|
-
tag: _ctx.multiple ? _ctx.as : void 0,
|
|
80
|
-
css: false,
|
|
81
|
-
mode: _ctx.mode === "wait" ? "out-in" : void 0,
|
|
92
|
+
return openBlock(), createBlock(resolveDynamicComponent(_ctx.multiple ? TransitionGroup : Transition), mergeProps({ css: false }, transitionProps.value, {
|
|
82
93
|
onEnter: enter,
|
|
83
94
|
onLeave: exit
|
|
84
|
-
}, {
|
|
95
|
+
}), {
|
|
85
96
|
default: withCtx(() => [
|
|
86
97
|
renderSlot(_ctx.$slots, "default")
|
|
87
98
|
]),
|
|
88
99
|
_: 3
|
|
89
|
-
},
|
|
100
|
+
}, 16);
|
|
90
101
|
};
|
|
91
102
|
}
|
|
92
103
|
});
|