motion-v 0.7.0 → 0.7.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 +280 -134
- package/dist/es/animation/hooks/animation-controls.mjs +78 -0
- package/dist/es/animation/{use-animate.mjs → hooks/use-animate.mjs} +1 -1
- package/dist/es/animation/hooks/use-animation-controls.mjs +16 -0
- package/dist/es/animation/utils.mjs +6 -0
- package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +2 -2
- package/dist/es/components/motion/Motion.vue.mjs +4 -1
- package/dist/es/constants/index.mjs +0 -1
- package/dist/es/features/animation/animation.mjs +33 -0
- package/dist/es/features/feature-manager.mjs +5 -1
- package/dist/es/features/gestures/focus/index.mjs +36 -0
- package/dist/es/index.mjs +3 -1
- package/dist/es/state/animate-updates.mjs +129 -0
- package/dist/es/state/motion-state.mjs +6 -123
- package/dist/es/state/style.mjs +2 -2
- package/dist/src/animation/hooks/animation-controls.d.ts +8 -0
- package/dist/src/animation/hooks/use-animate.d.ts +8 -0
- package/dist/src/animation/hooks/use-animation-controls.d.ts +33 -0
- package/dist/src/animation/index.d.ts +2 -1
- package/dist/src/animation/types.d.ts +68 -0
- package/dist/src/animation/utils.d.ts +2 -0
- package/dist/src/components/animate-presence/utils.d.ts +0 -1
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/motion/NameSpace.d.ts +2 -2
- package/dist/src/features/animation/animation.d.ts +13 -0
- package/dist/src/features/gestures/focus/index.d.ts +7 -0
- package/dist/src/features/gestures/focus/types.d.ts +6 -0
- package/dist/src/features/index.d.ts +1 -0
- package/dist/src/state/animate-updates.d.ts +19 -0
- package/dist/src/state/animation/types.d.ts +0 -0
- package/dist/src/state/motion-state.d.ts +2 -4
- package/dist/src/state/utils.d.ts +1 -1
- package/dist/src/types/state.d.ts +4 -2
- package/package.json +3 -2
- package/dist/es/components/animate-presence/utils.mjs +0 -10
- /package/dist/src/{animation/use-animation.d.ts → state/animation/index.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -3309,7 +3309,7 @@ function initPrefersReducedMotion() {
|
|
|
3309
3309
|
}
|
|
3310
3310
|
const valueTypes = [...dimensionValueTypes, color, complex];
|
|
3311
3311
|
const findValueType = (v) => valueTypes.find(testValueType(v));
|
|
3312
|
-
function isAnimationControls(v) {
|
|
3312
|
+
function isAnimationControls$1(v) {
|
|
3313
3313
|
return v !== null && typeof v === "object" && typeof v.start === "function";
|
|
3314
3314
|
}
|
|
3315
3315
|
function isVariantLabel(v) {
|
|
@@ -3326,7 +3326,7 @@ const variantPriorityOrder = [
|
|
|
3326
3326
|
];
|
|
3327
3327
|
const variantProps = ["initial", ...variantPriorityOrder];
|
|
3328
3328
|
function isControllingVariants(props) {
|
|
3329
|
-
return isAnimationControls(props.animate) || variantProps.some((name) => isVariantLabel(props[name]));
|
|
3329
|
+
return isAnimationControls$1(props.animate) || variantProps.some((name) => isVariantLabel(props[name]));
|
|
3330
3330
|
}
|
|
3331
3331
|
function isVariantNode(props) {
|
|
3332
3332
|
return Boolean(isControllingVariants(props) || props.variants);
|
|
@@ -7943,6 +7943,36 @@ class ProjectionFeature extends Feature {
|
|
|
7943
7943
|
(_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
|
|
7944
7944
|
}
|
|
7945
7945
|
}
|
|
7946
|
+
class FocusGesture extends Feature {
|
|
7947
|
+
constructor() {
|
|
7948
|
+
super(...arguments);
|
|
7949
|
+
this.isActive = false;
|
|
7950
|
+
}
|
|
7951
|
+
onFocus() {
|
|
7952
|
+
let isFocusVisible = false;
|
|
7953
|
+
try {
|
|
7954
|
+
isFocusVisible = this.state.element.matches(":focus-visible");
|
|
7955
|
+
} catch (e) {
|
|
7956
|
+
isFocusVisible = true;
|
|
7957
|
+
}
|
|
7958
|
+
if (!isFocusVisible)
|
|
7959
|
+
return;
|
|
7960
|
+
this.state.setActive("focus", true);
|
|
7961
|
+
this.isActive = true;
|
|
7962
|
+
}
|
|
7963
|
+
onBlur() {
|
|
7964
|
+
if (!this.isActive)
|
|
7965
|
+
return;
|
|
7966
|
+
this.state.setActive("focus", false);
|
|
7967
|
+
this.isActive = false;
|
|
7968
|
+
}
|
|
7969
|
+
mount() {
|
|
7970
|
+
this.unmount = pipe(
|
|
7971
|
+
addDomEvent$1(this.state.element, "focus", () => this.onFocus()),
|
|
7972
|
+
addDomEvent$1(this.state.element, "blur", () => this.onBlur())
|
|
7973
|
+
);
|
|
7974
|
+
}
|
|
7975
|
+
}
|
|
7946
7976
|
class FeatureManager {
|
|
7947
7977
|
constructor(state2) {
|
|
7948
7978
|
this.features = [];
|
|
@@ -7954,7 +7984,9 @@ class FeatureManager {
|
|
|
7954
7984
|
new LayoutFeature(state2),
|
|
7955
7985
|
new ProjectionFeature(state2),
|
|
7956
7986
|
new PanGesture(state2),
|
|
7957
|
-
new DragGesture(state2)
|
|
7987
|
+
new DragGesture(state2),
|
|
7988
|
+
new FocusGesture(state2),
|
|
7989
|
+
new AnimationFeature(state2)
|
|
7958
7990
|
];
|
|
7959
7991
|
}
|
|
7960
7992
|
mount() {
|
|
@@ -7982,13 +8014,160 @@ class FeatureManager {
|
|
|
7982
8014
|
this.features.forEach((feature) => feature.beforeUnmount());
|
|
7983
8015
|
}
|
|
7984
8016
|
}
|
|
7985
|
-
function
|
|
7986
|
-
return
|
|
8017
|
+
function isAnimationControls(v) {
|
|
8018
|
+
return v !== null && typeof v === "object" && typeof v.start === "function";
|
|
8019
|
+
}
|
|
8020
|
+
class AnimationFeature extends Feature {
|
|
8021
|
+
constructor(state2) {
|
|
8022
|
+
super(state2);
|
|
8023
|
+
}
|
|
8024
|
+
updateAnimationControlsSubscription() {
|
|
8025
|
+
const { animate: animate2 } = this.state.options;
|
|
8026
|
+
if (isAnimationControls(animate2)) {
|
|
8027
|
+
this.unmountControls = animate2.subscribe(this.state);
|
|
8028
|
+
}
|
|
8029
|
+
}
|
|
8030
|
+
/**
|
|
8031
|
+
* Subscribe any provided AnimationControls to the component's VisualElement
|
|
8032
|
+
*/
|
|
8033
|
+
mount() {
|
|
8034
|
+
this.updateAnimationControlsSubscription();
|
|
8035
|
+
}
|
|
8036
|
+
update() {
|
|
8037
|
+
const { animate: animate2 } = this.state.options;
|
|
8038
|
+
const { animate: prevAnimate } = this.state.visualElement.prevProps || {};
|
|
8039
|
+
if (animate2 !== prevAnimate) {
|
|
8040
|
+
this.updateAnimationControlsSubscription();
|
|
8041
|
+
}
|
|
8042
|
+
}
|
|
8043
|
+
unmount() {
|
|
8044
|
+
var _a;
|
|
8045
|
+
(_a = this.unmountControls) == null ? void 0 : _a.call(this);
|
|
8046
|
+
}
|
|
7987
8047
|
}
|
|
7988
8048
|
function createVisualElement(Component, options) {
|
|
7989
8049
|
return isSVGElement$1(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
|
|
7990
8050
|
}
|
|
7991
|
-
|
|
8051
|
+
function motionEvent(name, target, isExit) {
|
|
8052
|
+
return new CustomEvent(name, { detail: { target, isExit } });
|
|
8053
|
+
}
|
|
8054
|
+
const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "focus", "exit"];
|
|
8055
|
+
function animateUpdates({
|
|
8056
|
+
controlActiveState = void 0,
|
|
8057
|
+
controlDelay = 0,
|
|
8058
|
+
directAnimate,
|
|
8059
|
+
directTransition,
|
|
8060
|
+
isFallback = false
|
|
8061
|
+
} = {}) {
|
|
8062
|
+
const prevTarget = this.target;
|
|
8063
|
+
this.target = { ...this.baseTarget };
|
|
8064
|
+
const animationOptions = {};
|
|
8065
|
+
const transition = { ...this.options.transition };
|
|
8066
|
+
if (directAnimate)
|
|
8067
|
+
resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
|
|
8068
|
+
else
|
|
8069
|
+
resolveStateAnimation.call(this, controlActiveState, animationOptions);
|
|
8070
|
+
const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
|
|
8071
|
+
const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, transition, controlActiveState, isFallback);
|
|
8072
|
+
return executeAnimations.call(this, factories, getChildAnimations, childAnimations, transition, controlActiveState);
|
|
8073
|
+
}
|
|
8074
|
+
function resolveDirectAnimation(directAnimate, directTransition, animationOptions) {
|
|
8075
|
+
const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom);
|
|
8076
|
+
if (!variant)
|
|
8077
|
+
return;
|
|
8078
|
+
const transition = { ...this.options.transition, ...directTransition || variant.transition };
|
|
8079
|
+
Object.entries(variant).forEach(([key, value]) => {
|
|
8080
|
+
if (key === "transition")
|
|
8081
|
+
return;
|
|
8082
|
+
this.target[key] = value;
|
|
8083
|
+
animationOptions[key] = getOptions(transition, key);
|
|
8084
|
+
});
|
|
8085
|
+
}
|
|
8086
|
+
function resolveStateAnimation(controlActiveState, animationOptions) {
|
|
8087
|
+
if (controlActiveState)
|
|
8088
|
+
this.activeStates = { ...this.activeStates, ...controlActiveState };
|
|
8089
|
+
STATE_TYPES.forEach((name) => {
|
|
8090
|
+
if (!this.activeStates[name] || isAnimationControls(this.options[name]))
|
|
8091
|
+
return;
|
|
8092
|
+
const definition = core.isDef(this.options[name]) ? this.options[name] : this.context[name];
|
|
8093
|
+
const variant = resolveVariant(definition, this.options.variants, this.options.custom);
|
|
8094
|
+
if (!variant)
|
|
8095
|
+
return;
|
|
8096
|
+
const transition = { ...this.options.transition, ...variant.transition };
|
|
8097
|
+
Object.entries(variant).forEach(([key, value]) => {
|
|
8098
|
+
if (key === "transition")
|
|
8099
|
+
return;
|
|
8100
|
+
this.target[key] = value;
|
|
8101
|
+
animationOptions[key] = getOptions(transition, key);
|
|
8102
|
+
});
|
|
8103
|
+
});
|
|
8104
|
+
}
|
|
8105
|
+
function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
|
|
8106
|
+
const factories = [];
|
|
8107
|
+
new Set(Object.keys(this.target)).forEach((key) => {
|
|
8108
|
+
var _a;
|
|
8109
|
+
if (!hasChanged(this.visualElement.getValue(key), this.target[key]))
|
|
8110
|
+
return;
|
|
8111
|
+
(_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
|
|
8112
|
+
const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
|
|
8113
|
+
const targetTransition = animationOptions[key];
|
|
8114
|
+
factories.push(() => animate(
|
|
8115
|
+
this.element,
|
|
8116
|
+
{ [key]: keyValue },
|
|
8117
|
+
{
|
|
8118
|
+
...targetTransition,
|
|
8119
|
+
delay: ((targetTransition == null ? void 0 : targetTransition.delay) || 0) + controlDelay
|
|
8120
|
+
}
|
|
8121
|
+
));
|
|
8122
|
+
});
|
|
8123
|
+
return factories;
|
|
8124
|
+
}
|
|
8125
|
+
function setupChildAnimations(transition, controlActiveState, isFallback) {
|
|
8126
|
+
var _a;
|
|
8127
|
+
if (!((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) || controlActiveState)
|
|
8128
|
+
return { getChildAnimations: () => Promise.resolve(), childAnimations: [] };
|
|
8129
|
+
const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
|
|
8130
|
+
const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
|
|
8131
|
+
const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
8132
|
+
const childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
|
|
8133
|
+
const childDelay = delayChildren + generateStaggerDuration(index);
|
|
8134
|
+
return child.state.animateUpdates({
|
|
8135
|
+
controlActiveState: this.activeStates,
|
|
8136
|
+
controlDelay: isFallback ? 0 : childDelay
|
|
8137
|
+
});
|
|
8138
|
+
}).filter(Boolean);
|
|
8139
|
+
return {
|
|
8140
|
+
getChildAnimations: () => Promise.all(childAnimations.map((animation) => animation())),
|
|
8141
|
+
childAnimations
|
|
8142
|
+
};
|
|
8143
|
+
}
|
|
8144
|
+
function executeAnimations(factories, getChildAnimations, childAnimations, transition, controlActiveState) {
|
|
8145
|
+
let animations;
|
|
8146
|
+
const getAnimation = () => {
|
|
8147
|
+
animations = factories.map((factory) => factory()).filter(Boolean);
|
|
8148
|
+
return Promise.all(animations);
|
|
8149
|
+
};
|
|
8150
|
+
const isExit = this.activeStates.exit;
|
|
8151
|
+
const animationTarget2 = { ...this.target };
|
|
8152
|
+
const element = this.element;
|
|
8153
|
+
const finishAnimation2 = (animationPromise) => {
|
|
8154
|
+
if (!(animations == null ? void 0 : animations.length) && !childAnimations.length) {
|
|
8155
|
+
if (isExit) {
|
|
8156
|
+
element.dispatchEvent(motionEvent("motionstart", animationTarget2));
|
|
8157
|
+
element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit));
|
|
8158
|
+
}
|
|
8159
|
+
return;
|
|
8160
|
+
}
|
|
8161
|
+
element.dispatchEvent(motionEvent("motionstart", animationTarget2));
|
|
8162
|
+
animationPromise.then(() => element.dispatchEvent(motionEvent("motioncomplete", animationTarget2, isExit))).catch(noop);
|
|
8163
|
+
};
|
|
8164
|
+
const getAnimationPromise = () => {
|
|
8165
|
+
const animationPromise = (transition == null ? void 0 : transition.when) ? (transition.when === "beforeChildren" ? getAnimation() : getChildAnimations()).then(() => transition.when === "beforeChildren" ? getChildAnimations() : getAnimation()) : Promise.all([getAnimation(), getChildAnimations()]);
|
|
8166
|
+
finishAnimation2(animationPromise);
|
|
8167
|
+
return animationPromise;
|
|
8168
|
+
};
|
|
8169
|
+
return controlActiveState ? getAnimationPromise : getAnimationPromise();
|
|
8170
|
+
}
|
|
7992
8171
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
7993
8172
|
let id = 0;
|
|
7994
8173
|
class MotionState {
|
|
@@ -8003,6 +8182,7 @@ class MotionState {
|
|
|
8003
8182
|
animate: true
|
|
8004
8183
|
};
|
|
8005
8184
|
this._context = null;
|
|
8185
|
+
this.animateUpdates = animateUpdates;
|
|
8006
8186
|
this.id = `motion-state-${id++}`;
|
|
8007
8187
|
this.options = options;
|
|
8008
8188
|
this.parent = parent;
|
|
@@ -8152,122 +8332,10 @@ class MotionState {
|
|
|
8152
8332
|
child.state.setActive(name, isActive, false);
|
|
8153
8333
|
});
|
|
8154
8334
|
if (isAnimate) {
|
|
8155
|
-
this.animateUpdates(
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
// Core animation update logic
|
|
8159
|
-
animateUpdates(controlActiveState = void 0, controlDelay = 0) {
|
|
8160
|
-
var _a;
|
|
8161
|
-
const prevTarget = this.target;
|
|
8162
|
-
this.target = {
|
|
8163
|
-
...this.baseTarget
|
|
8164
|
-
};
|
|
8165
|
-
const animationOptions = {};
|
|
8166
|
-
let transition;
|
|
8167
|
-
if (controlActiveState) {
|
|
8168
|
-
this.activeStates = { ...this.activeStates, ...controlActiveState };
|
|
8169
|
-
}
|
|
8170
|
-
for (const name of STATE_TYPES) {
|
|
8171
|
-
if (!this.activeStates[name]) {
|
|
8172
|
-
continue;
|
|
8173
|
-
}
|
|
8174
|
-
const definition = core.isDef(this.options[name]) ? this.options[name] : this.context[name];
|
|
8175
|
-
const variant = resolveVariant(
|
|
8176
|
-
definition,
|
|
8177
|
-
this.options.variants,
|
|
8178
|
-
this.options.custom
|
|
8179
|
-
);
|
|
8180
|
-
transition = Object.assign({}, this.options.transition, variant == null ? void 0 : variant.transition);
|
|
8181
|
-
if (!variant)
|
|
8182
|
-
continue;
|
|
8183
|
-
const allTarget = { ...variant };
|
|
8184
|
-
for (const key in allTarget) {
|
|
8185
|
-
if (key === "transition")
|
|
8186
|
-
continue;
|
|
8187
|
-
this.target[key] = variant[key];
|
|
8188
|
-
animationOptions[key] = getOptions(
|
|
8189
|
-
transition,
|
|
8190
|
-
key
|
|
8191
|
-
);
|
|
8192
|
-
}
|
|
8193
|
-
}
|
|
8194
|
-
const allTargetKeys = /* @__PURE__ */ new Set([
|
|
8195
|
-
...Object.keys(this.target)
|
|
8196
|
-
]);
|
|
8197
|
-
const animationFactories = [];
|
|
8198
|
-
allTargetKeys.forEach((key) => {
|
|
8199
|
-
var _a2;
|
|
8200
|
-
if (hasChanged(prevTarget[key], this.target[key])) {
|
|
8201
|
-
(_a2 = this.baseTarget)[key] ?? (_a2[key] = style.get(this.element, key));
|
|
8202
|
-
const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
|
|
8203
|
-
const targetTransition = animationOptions[key];
|
|
8204
|
-
animationFactories.push(
|
|
8205
|
-
() => {
|
|
8206
|
-
return animate(
|
|
8207
|
-
this.element,
|
|
8208
|
-
{
|
|
8209
|
-
[key]: keyValue
|
|
8210
|
-
},
|
|
8211
|
-
{
|
|
8212
|
-
...targetTransition,
|
|
8213
|
-
delay: ((targetTransition == null ? void 0 : targetTransition.delay) || 0) + controlDelay
|
|
8214
|
-
}
|
|
8215
|
-
);
|
|
8216
|
-
}
|
|
8217
|
-
);
|
|
8218
|
-
}
|
|
8219
|
-
});
|
|
8220
|
-
let getChildAnimations = () => Promise.resolve();
|
|
8221
|
-
let childAnimations = [];
|
|
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()));
|
|
8231
|
-
}
|
|
8232
|
-
let animations;
|
|
8233
|
-
const getAnimation = () => {
|
|
8234
|
-
animations = animationFactories.map((factory) => factory()).filter(Boolean);
|
|
8235
|
-
return Promise.all(animations);
|
|
8236
|
-
};
|
|
8237
|
-
const { when } = transition;
|
|
8238
|
-
let animationPromise;
|
|
8239
|
-
const isExit = this.activeStates.exit;
|
|
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;
|
|
8265
|
-
}
|
|
8266
|
-
}
|
|
8267
|
-
if (controlActiveState) {
|
|
8268
|
-
return getAnimationPromise;
|
|
8335
|
+
this.animateUpdates({
|
|
8336
|
+
isFallback: !isActive
|
|
8337
|
+
});
|
|
8269
8338
|
}
|
|
8270
|
-
getAnimationPromise();
|
|
8271
8339
|
}
|
|
8272
8340
|
isMounted() {
|
|
8273
8341
|
return Boolean(this.element);
|
|
@@ -8359,7 +8427,10 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8359
8427
|
onPanSessionStart: { type: Function },
|
|
8360
8428
|
onPanStart: { type: Function },
|
|
8361
8429
|
onPan: { type: Function },
|
|
8362
|
-
onPanEnd: { type: Function }
|
|
8430
|
+
onPanEnd: { type: Function },
|
|
8431
|
+
focus: {},
|
|
8432
|
+
onFocus: { type: Function },
|
|
8433
|
+
onBlur: { type: Function }
|
|
8363
8434
|
}, {
|
|
8364
8435
|
as: "div",
|
|
8365
8436
|
asChild: false,
|
|
@@ -8578,13 +8649,6 @@ function usePopLayout(props) {
|
|
|
8578
8649
|
styles
|
|
8579
8650
|
};
|
|
8580
8651
|
}
|
|
8581
|
-
function requestIdleCallback$1(callback) {
|
|
8582
|
-
if (typeof requestIdleCallback$1 !== "undefined") {
|
|
8583
|
-
requestIdleCallback$1(callback);
|
|
8584
|
-
} else {
|
|
8585
|
-
setTimeout(callback, 50);
|
|
8586
|
-
}
|
|
8587
|
-
}
|
|
8588
8652
|
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
8589
8653
|
...{
|
|
8590
8654
|
name: "AnimatePresence",
|
|
@@ -8646,7 +8710,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8646
8710
|
if (!styles.has(state2)) {
|
|
8647
8711
|
state2.willUpdate("done");
|
|
8648
8712
|
} else {
|
|
8649
|
-
|
|
8713
|
+
frame.render(() => {
|
|
8650
8714
|
removePopStyle(state2);
|
|
8651
8715
|
});
|
|
8652
8716
|
}
|
|
@@ -8891,7 +8955,7 @@ function useSpring(source, config = {}) {
|
|
|
8891
8955
|
let latestValue = value.get();
|
|
8892
8956
|
let latestSetter = () => {
|
|
8893
8957
|
};
|
|
8894
|
-
const
|
|
8958
|
+
const stopAnimation2 = () => {
|
|
8895
8959
|
if (activeSpringAnimation) {
|
|
8896
8960
|
activeSpringAnimation.stop();
|
|
8897
8961
|
activeSpringAnimation = null;
|
|
@@ -8902,7 +8966,7 @@ function useSpring(source, config = {}) {
|
|
|
8902
8966
|
if ((animation == null ? void 0 : animation.time) === 0) {
|
|
8903
8967
|
animation.sample(frameData.delta);
|
|
8904
8968
|
}
|
|
8905
|
-
|
|
8969
|
+
stopAnimation2();
|
|
8906
8970
|
activeSpringAnimation = animateValue({
|
|
8907
8971
|
keyframes: [value.get(), latestValue],
|
|
8908
8972
|
velocity: value.getVelocity(),
|
|
@@ -8919,7 +8983,7 @@ function useSpring(source, config = {}) {
|
|
|
8919
8983
|
latestSetter = set;
|
|
8920
8984
|
frame.update(startAnimation);
|
|
8921
8985
|
return value.get();
|
|
8922
|
-
},
|
|
8986
|
+
}, stopAnimation2);
|
|
8923
8987
|
}, { immediate: true });
|
|
8924
8988
|
if (isMotionValue(source)) {
|
|
8925
8989
|
source.on("change", (v) => {
|
|
@@ -8993,7 +9057,6 @@ function useVelocity(value) {
|
|
|
8993
9057
|
}
|
|
8994
9058
|
const components = {
|
|
8995
9059
|
motion: [
|
|
8996
|
-
"motion",
|
|
8997
9060
|
"Motion",
|
|
8998
9061
|
"AnimatePresence",
|
|
8999
9062
|
"LayoutGroup",
|
|
@@ -9043,6 +9106,88 @@ function useAnimate() {
|
|
|
9043
9106
|
});
|
|
9044
9107
|
return [domProxy, animate2];
|
|
9045
9108
|
}
|
|
9109
|
+
function stopAnimation(visualElement) {
|
|
9110
|
+
visualElement.values.forEach((value) => value.stop());
|
|
9111
|
+
}
|
|
9112
|
+
function animationControls() {
|
|
9113
|
+
let hasMounted = false;
|
|
9114
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
9115
|
+
const controls = {
|
|
9116
|
+
subscribe(state2) {
|
|
9117
|
+
subscribers.add(state2);
|
|
9118
|
+
return () => void subscribers.delete(state2);
|
|
9119
|
+
},
|
|
9120
|
+
start(definition, transitionOverride) {
|
|
9121
|
+
heyListen.invariant(
|
|
9122
|
+
hasMounted,
|
|
9123
|
+
"controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook."
|
|
9124
|
+
);
|
|
9125
|
+
const animations = [];
|
|
9126
|
+
subscribers.forEach((state2) => {
|
|
9127
|
+
animations.push(
|
|
9128
|
+
state2.animateUpdates({
|
|
9129
|
+
directAnimate: definition,
|
|
9130
|
+
directTransition: transitionOverride
|
|
9131
|
+
})
|
|
9132
|
+
);
|
|
9133
|
+
});
|
|
9134
|
+
return Promise.all(animations);
|
|
9135
|
+
},
|
|
9136
|
+
set(definition) {
|
|
9137
|
+
heyListen.invariant(
|
|
9138
|
+
hasMounted,
|
|
9139
|
+
"controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook."
|
|
9140
|
+
);
|
|
9141
|
+
return subscribers.forEach((state2) => {
|
|
9142
|
+
setValues(state2, definition);
|
|
9143
|
+
});
|
|
9144
|
+
},
|
|
9145
|
+
stop() {
|
|
9146
|
+
subscribers.forEach((state2) => {
|
|
9147
|
+
stopAnimation(state2.visualElement);
|
|
9148
|
+
});
|
|
9149
|
+
},
|
|
9150
|
+
mount() {
|
|
9151
|
+
hasMounted = true;
|
|
9152
|
+
return () => {
|
|
9153
|
+
hasMounted = false;
|
|
9154
|
+
controls.stop();
|
|
9155
|
+
};
|
|
9156
|
+
}
|
|
9157
|
+
};
|
|
9158
|
+
return controls;
|
|
9159
|
+
}
|
|
9160
|
+
function setValues(state2, definition) {
|
|
9161
|
+
if (typeof definition === "string") {
|
|
9162
|
+
return setVariants(state2, [definition]);
|
|
9163
|
+
} else {
|
|
9164
|
+
setTarget(state2.visualElement, definition);
|
|
9165
|
+
}
|
|
9166
|
+
}
|
|
9167
|
+
function setVariants(state2, variantLabels) {
|
|
9168
|
+
const reversedLabels = [...variantLabels].reverse();
|
|
9169
|
+
const visualElement = state2.visualElement;
|
|
9170
|
+
reversedLabels.forEach((key) => {
|
|
9171
|
+
const variant = visualElement.getVariant(key);
|
|
9172
|
+
variant && setTarget(visualElement, variant);
|
|
9173
|
+
if (visualElement.variantChildren) {
|
|
9174
|
+
visualElement.variantChildren.forEach((child) => {
|
|
9175
|
+
setVariants(mountedStates.get(child.current), variantLabels);
|
|
9176
|
+
});
|
|
9177
|
+
}
|
|
9178
|
+
});
|
|
9179
|
+
}
|
|
9180
|
+
function useAnimationControls() {
|
|
9181
|
+
const controls = animationControls();
|
|
9182
|
+
let unmount;
|
|
9183
|
+
vue.onMounted(() => {
|
|
9184
|
+
unmount = controls.mount();
|
|
9185
|
+
});
|
|
9186
|
+
vue.onUnmounted(() => {
|
|
9187
|
+
unmount();
|
|
9188
|
+
});
|
|
9189
|
+
return controls;
|
|
9190
|
+
}
|
|
9046
9191
|
class DragControls {
|
|
9047
9192
|
constructor() {
|
|
9048
9193
|
this.componentControls = /* @__PURE__ */ new Set();
|
|
@@ -9143,6 +9288,7 @@ exports.sync = sync;
|
|
|
9143
9288
|
exports.time = time;
|
|
9144
9289
|
exports.transform = transform;
|
|
9145
9290
|
exports.useAnimate = useAnimate;
|
|
9291
|
+
exports.useAnimationControls = useAnimationControls;
|
|
9146
9292
|
exports.useAnimationFrame = useAnimationFrame;
|
|
9147
9293
|
exports.useCombineMotionValues = useCombineMotionValues;
|
|
9148
9294
|
exports.useComputed = useComputed;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { mountedStates } from "../../state/motion-state.mjs";
|
|
2
|
+
import { invariant } from "hey-listen";
|
|
3
|
+
import { setTarget } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/render/utils/setters.mjs";
|
|
4
|
+
function stopAnimation(visualElement) {
|
|
5
|
+
visualElement.values.forEach((value) => value.stop());
|
|
6
|
+
}
|
|
7
|
+
function animationControls() {
|
|
8
|
+
let hasMounted = false;
|
|
9
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
10
|
+
const controls = {
|
|
11
|
+
subscribe(state) {
|
|
12
|
+
subscribers.add(state);
|
|
13
|
+
return () => void subscribers.delete(state);
|
|
14
|
+
},
|
|
15
|
+
start(definition, transitionOverride) {
|
|
16
|
+
invariant(
|
|
17
|
+
hasMounted,
|
|
18
|
+
"controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook."
|
|
19
|
+
);
|
|
20
|
+
const animations = [];
|
|
21
|
+
subscribers.forEach((state) => {
|
|
22
|
+
animations.push(
|
|
23
|
+
state.animateUpdates({
|
|
24
|
+
directAnimate: definition,
|
|
25
|
+
directTransition: transitionOverride
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
return Promise.all(animations);
|
|
30
|
+
},
|
|
31
|
+
set(definition) {
|
|
32
|
+
invariant(
|
|
33
|
+
hasMounted,
|
|
34
|
+
"controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook."
|
|
35
|
+
);
|
|
36
|
+
return subscribers.forEach((state) => {
|
|
37
|
+
setValues(state, definition);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
stop() {
|
|
41
|
+
subscribers.forEach((state) => {
|
|
42
|
+
stopAnimation(state.visualElement);
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
mount() {
|
|
46
|
+
hasMounted = true;
|
|
47
|
+
return () => {
|
|
48
|
+
hasMounted = false;
|
|
49
|
+
controls.stop();
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return controls;
|
|
54
|
+
}
|
|
55
|
+
function setValues(state, definition) {
|
|
56
|
+
if (typeof definition === "string") {
|
|
57
|
+
return setVariants(state, [definition]);
|
|
58
|
+
} else {
|
|
59
|
+
setTarget(state.visualElement, definition);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function setVariants(state, variantLabels) {
|
|
63
|
+
const reversedLabels = [...variantLabels].reverse();
|
|
64
|
+
const visualElement = state.visualElement;
|
|
65
|
+
reversedLabels.forEach((key) => {
|
|
66
|
+
const variant = visualElement.getVariant(key);
|
|
67
|
+
variant && setTarget(visualElement, variant);
|
|
68
|
+
if (visualElement.variantChildren) {
|
|
69
|
+
visualElement.variantChildren.forEach((child) => {
|
|
70
|
+
setVariants(mountedStates.get(child.current), variantLabels);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
animationControls,
|
|
77
|
+
setValues
|
|
78
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, onUnmounted } from "vue";
|
|
2
|
-
import { createScopedAnimate } from "
|
|
2
|
+
import { createScopedAnimate } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/animation/animate/index.mjs";
|
|
3
3
|
function useAnimate() {
|
|
4
4
|
const dom = ref(null);
|
|
5
5
|
const domProxy = new Proxy(dom, {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { animationControls } from "./animation-controls.mjs";
|
|
2
|
+
import { onMounted, onUnmounted } from "vue";
|
|
3
|
+
function useAnimationControls() {
|
|
4
|
+
const controls = animationControls();
|
|
5
|
+
let unmount;
|
|
6
|
+
onMounted(() => {
|
|
7
|
+
unmount = controls.mount();
|
|
8
|
+
});
|
|
9
|
+
onUnmounted(() => {
|
|
10
|
+
unmount();
|
|
11
|
+
});
|
|
12
|
+
return controls;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
useAnimationControls
|
|
16
|
+
};
|
|
@@ -2,7 +2,7 @@ import { defineComponent, onMounted, onUnmounted, computed, openBlock, createBlo
|
|
|
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 {
|
|
5
|
+
import { frame } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
...{
|
|
8
8
|
name: "AnimatePresence",
|
|
@@ -64,7 +64,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
64
64
|
if (!styles.has(state)) {
|
|
65
65
|
state.willUpdate("done");
|
|
66
66
|
} else {
|
|
67
|
-
|
|
67
|
+
frame.render(() => {
|
|
68
68
|
removePopStyle(state);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -66,7 +66,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
66
66
|
onPanSessionStart: { type: Function },
|
|
67
67
|
onPanStart: { type: Function },
|
|
68
68
|
onPan: { type: Function },
|
|
69
|
-
onPanEnd: { type: Function }
|
|
69
|
+
onPanEnd: { type: Function },
|
|
70
|
+
focus: {},
|
|
71
|
+
onFocus: { type: Function },
|
|
72
|
+
onBlur: { type: Function }
|
|
70
73
|
}, {
|
|
71
74
|
as: "div",
|
|
72
75
|
asChild: false,
|