motion-v 0.11.0-beta.4 → 0.11.0-beta.6
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 +97 -66
- package/dist/es/animation/hooks/animation-controls.mjs +2 -0
- package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +13 -9
- package/dist/es/components/hooks/use-motion-elm.mjs +9 -0
- package/dist/es/components/motion/Motion.vue.mjs +3 -5
- package/dist/es/components/motion/utils.d.ts +0 -1
- package/dist/es/components/motion/utils.mjs +2 -7
- package/dist/es/components/reorder/Group.vue.mjs +1 -1
- package/dist/es/components/reorder/Item.d.ts +4 -4
- package/dist/es/components/reorder/Item.vue.mjs +1 -1
- package/dist/es/features/gestures/drag/types.d.ts +2 -2
- package/dist/es/features/gestures/focus/types.d.ts +2 -2
- package/dist/es/features/gestures/hover/types.d.ts +2 -2
- package/dist/es/features/gestures/in-view/types.d.ts +2 -2
- package/dist/es/features/gestures/press/types.d.ts +2 -2
- package/dist/es/features/layout/layout.mjs +11 -6
- package/dist/es/index.mjs +2 -0
- package/dist/es/state/animate-updates.mjs +4 -2
- package/dist/es/state/motion-state.d.ts +1 -0
- package/dist/es/state/motion-state.mjs +25 -33
- package/dist/es/state/utils/is-variant-labels.d.ts +2 -0
- package/dist/es/state/utils/is-variant-labels.mjs +6 -0
- package/dist/es/state/utils.mjs +7 -2
- package/dist/es/types/framer-motion.d.ts +1 -1
- package/dist/es/types/state.d.ts +16 -11
- package/dist/es/utils/delay.d.ts +1 -0
- package/dist/es/utils/delay.mjs +8 -0
- package/dist/es/utils/index.d.ts +1 -0
- package/dist/es/utils/use-dom-ref.d.ts +1 -1
- package/dist/es/utils/use-dom-ref.mjs +22 -0
- package/package.json +1 -1
- package/dist/es/shared/index.d.ts +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -4875,7 +4875,7 @@ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease: ease2 } = {})
|
|
|
4875
4875
|
return startDelay + delay2;
|
|
4876
4876
|
};
|
|
4877
4877
|
}
|
|
4878
|
-
function delay(callback, timeout) {
|
|
4878
|
+
function delay$1(callback, timeout) {
|
|
4879
4879
|
const start = time.now();
|
|
4880
4880
|
const checkElapsed = ({ timestamp }) => {
|
|
4881
4881
|
const elapsed = timestamp - start;
|
|
@@ -4888,7 +4888,7 @@ function delay(callback, timeout) {
|
|
|
4888
4888
|
return () => cancelFrame(checkElapsed);
|
|
4889
4889
|
}
|
|
4890
4890
|
function delayInSeconds(callback, timeout) {
|
|
4891
|
-
return delay(callback, secondsToMilliseconds$1(timeout));
|
|
4891
|
+
return delay$1(callback, secondsToMilliseconds$1(timeout));
|
|
4892
4892
|
}
|
|
4893
4893
|
const distance = (a, b) => Math.abs(a - b);
|
|
4894
4894
|
function distance2D(a, b) {
|
|
@@ -4984,10 +4984,37 @@ function millisecondsToSeconds(milliseconds) {
|
|
|
4984
4984
|
function getContextWindow({ current }) {
|
|
4985
4985
|
return current ? current.ownerDocument.defaultView : null;
|
|
4986
4986
|
}
|
|
4987
|
+
function getMotionElement(el) {
|
|
4988
|
+
if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
|
|
4989
|
+
return getMotionElement(el.nextSibling);
|
|
4990
|
+
return el;
|
|
4991
|
+
}
|
|
4992
|
+
function useDomRef() {
|
|
4993
|
+
const dom = vue.ref(null);
|
|
4994
|
+
const domProxy = new Proxy(dom, {
|
|
4995
|
+
get(target, key) {
|
|
4996
|
+
if (typeof key === "string" || typeof key === "symbol") {
|
|
4997
|
+
return Reflect.get(target, key);
|
|
4998
|
+
}
|
|
4999
|
+
return void 0;
|
|
5000
|
+
},
|
|
5001
|
+
set(target, key, value) {
|
|
5002
|
+
if (key === "value")
|
|
5003
|
+
return Reflect.set(target, key, getMotionElement((value == null ? void 0 : value.$el) || value));
|
|
5004
|
+
return true;
|
|
5005
|
+
}
|
|
5006
|
+
});
|
|
5007
|
+
return domProxy;
|
|
5008
|
+
}
|
|
4987
5009
|
const [injectMotion, provideMotion] = createContext("Motion");
|
|
4988
5010
|
const [injectLayoutGroup, provideLayoutGroup] = createContext("LayoutGroup");
|
|
4989
5011
|
function resolveVariant(definition, variants, custom) {
|
|
4990
|
-
if (
|
|
5012
|
+
if (Array.isArray(definition)) {
|
|
5013
|
+
return definition.reduce((acc, item) => {
|
|
5014
|
+
const resolvedVariant = resolveVariant(item, variants, custom);
|
|
5015
|
+
return resolvedVariant ? { ...acc, ...resolvedVariant } : acc;
|
|
5016
|
+
}, {});
|
|
5017
|
+
} else if (typeof definition === "object") {
|
|
4991
5018
|
return definition;
|
|
4992
5019
|
} else if (definition && variants) {
|
|
4993
5020
|
const variant = variants[definition];
|
|
@@ -5012,7 +5039,7 @@ function shallowCompare(next, prev) {
|
|
|
5012
5039
|
return true;
|
|
5013
5040
|
}
|
|
5014
5041
|
function getOptions(options, key) {
|
|
5015
|
-
return options[key] ? { ...options, ...options[key] } : { ...options };
|
|
5042
|
+
return options[key] ? { ...options, ...options[key], [key]: void 0 } : { ...options };
|
|
5016
5043
|
}
|
|
5017
5044
|
function isCssVar(name) {
|
|
5018
5045
|
return name == null ? void 0 : name.startsWith("--");
|
|
@@ -6422,22 +6449,22 @@ class LayoutFeature extends Feature {
|
|
|
6422
6449
|
}
|
|
6423
6450
|
didUpdate() {
|
|
6424
6451
|
var _a, _b;
|
|
6425
|
-
if (this.state.options.layout || this.state.options.layoutId)
|
|
6452
|
+
if (this.state.options.layout || this.state.options.layoutId || this.state.options.drag)
|
|
6426
6453
|
(_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
|
|
6427
6454
|
}
|
|
6428
6455
|
mount() {
|
|
6429
6456
|
var _a;
|
|
6430
6457
|
const options = this.state.options;
|
|
6431
6458
|
const layoutGroup = this.state.options.layoutGroup;
|
|
6432
|
-
if (options.layout || options.layoutId
|
|
6459
|
+
if (options.layout || options.layoutId) {
|
|
6433
6460
|
const projection = this.state.visualElement.projection;
|
|
6434
6461
|
if (projection) {
|
|
6435
6462
|
projection.promote();
|
|
6436
6463
|
(_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
|
|
6437
6464
|
}
|
|
6438
|
-
this.didUpdate();
|
|
6439
6465
|
globalProjectionState.hasEverUpdated = true;
|
|
6440
6466
|
}
|
|
6467
|
+
this.didUpdate();
|
|
6441
6468
|
}
|
|
6442
6469
|
beforeUnmount() {
|
|
6443
6470
|
const projection = this.state.visualElement.projection;
|
|
@@ -6452,11 +6479,16 @@ class LayoutFeature extends Feature {
|
|
|
6452
6479
|
}
|
|
6453
6480
|
}
|
|
6454
6481
|
unmount() {
|
|
6482
|
+
var _a, _b;
|
|
6455
6483
|
const layoutGroup = this.state.options.layoutGroup;
|
|
6456
6484
|
const projection = this.state.visualElement.projection;
|
|
6457
|
-
if (
|
|
6458
|
-
layoutGroup.group
|
|
6459
|
-
|
|
6485
|
+
if (projection) {
|
|
6486
|
+
if (layoutGroup == null ? void 0 : layoutGroup.group) {
|
|
6487
|
+
layoutGroup.group.remove(projection);
|
|
6488
|
+
}
|
|
6489
|
+
if ((_b = (_a = projection.getStack()) == null ? void 0 : _a.lead) == null ? void 0 : _b.animationProgress) {
|
|
6490
|
+
return;
|
|
6491
|
+
}
|
|
6460
6492
|
this.didUpdate();
|
|
6461
6493
|
}
|
|
6462
6494
|
}
|
|
@@ -6971,7 +7003,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6971
7003
|
attachResizeListener(instance, () => {
|
|
6972
7004
|
this.root.updateBlockedByResize = true;
|
|
6973
7005
|
cancelDelay && cancelDelay();
|
|
6974
|
-
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
7006
|
+
cancelDelay = delay$1(resizeUnblockUpdate, 250);
|
|
6975
7007
|
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
6976
7008
|
globalProjectionState.hasAnimatedSinceResize = false;
|
|
6977
7009
|
this.nodes.forEach(finishAnimation);
|
|
@@ -8168,12 +8200,14 @@ function setupChildAnimations(transition, controlActiveState, isFallback) {
|
|
|
8168
8200
|
const childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
|
|
8169
8201
|
const childDelay = delayChildren + generateStaggerDuration(index);
|
|
8170
8202
|
return child.state.animateUpdates({
|
|
8171
|
-
controlActiveState
|
|
8203
|
+
controlActiveState,
|
|
8172
8204
|
controlDelay: isFallback ? 0 : childDelay
|
|
8173
8205
|
});
|
|
8174
8206
|
}).filter(Boolean);
|
|
8175
8207
|
return {
|
|
8176
|
-
getChildAnimations: () => Promise.all(childAnimations.map((animation) =>
|
|
8208
|
+
getChildAnimations: () => Promise.all(childAnimations.map((animation) => {
|
|
8209
|
+
return typeof animation === "function" ? animation() : animation;
|
|
8210
|
+
})),
|
|
8177
8211
|
childAnimations
|
|
8178
8212
|
};
|
|
8179
8213
|
}
|
|
@@ -8204,6 +8238,9 @@ function executeAnimations(factories, getChildAnimations, childAnimations, trans
|
|
|
8204
8238
|
};
|
|
8205
8239
|
return controlActiveState ? getAnimationPromise : getAnimationPromise();
|
|
8206
8240
|
}
|
|
8241
|
+
function isVariantLabels(value) {
|
|
8242
|
+
return typeof value === "string" || Array.isArray(value);
|
|
8243
|
+
}
|
|
8207
8244
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
8208
8245
|
let id = 0;
|
|
8209
8246
|
const mountedLayoutIds = /* @__PURE__ */ new Set();
|
|
@@ -8225,6 +8262,8 @@ class MotionState {
|
|
|
8225
8262
|
this.parent = parent;
|
|
8226
8263
|
(_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
|
|
8227
8264
|
this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
|
|
8265
|
+
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
8266
|
+
this.initTarget(initialVariantSource);
|
|
8228
8267
|
this.visualElement = createVisualElement(this.options.as, {
|
|
8229
8268
|
presenceContext: null,
|
|
8230
8269
|
parent: parent == null ? void 0 : parent.visualElement,
|
|
@@ -8242,12 +8281,12 @@ class MotionState {
|
|
|
8242
8281
|
vars: {},
|
|
8243
8282
|
attrs: {}
|
|
8244
8283
|
},
|
|
8245
|
-
latestValues: {
|
|
8284
|
+
latestValues: {
|
|
8285
|
+
...this.baseTarget
|
|
8286
|
+
}
|
|
8246
8287
|
},
|
|
8247
8288
|
reducedMotionConfig: options.motionConfig.reduceMotion
|
|
8248
8289
|
});
|
|
8249
|
-
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
8250
|
-
this.initTarget(initialVariantSource);
|
|
8251
8290
|
this.featureManager = new FeatureManager(this);
|
|
8252
8291
|
}
|
|
8253
8292
|
// Get animation context, falling back to parent context for inheritance
|
|
@@ -8256,7 +8295,7 @@ class MotionState {
|
|
|
8256
8295
|
const handler = {
|
|
8257
8296
|
get: (target, prop) => {
|
|
8258
8297
|
var _a;
|
|
8259
|
-
return
|
|
8298
|
+
return isVariantLabels(this.options[prop]) ? this.options[prop] : (_a = this.parent) == null ? void 0 : _a.context[prop];
|
|
8260
8299
|
}
|
|
8261
8300
|
};
|
|
8262
8301
|
this._context = new Proxy({}, handler);
|
|
@@ -8266,9 +8305,6 @@ class MotionState {
|
|
|
8266
8305
|
// Initialize animation target values
|
|
8267
8306
|
initTarget(initialVariantSource) {
|
|
8268
8307
|
this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
|
|
8269
|
-
for (const key in this.baseTarget) {
|
|
8270
|
-
this.visualElement.setStaticValue(key, this.baseTarget[key]);
|
|
8271
|
-
}
|
|
8272
8308
|
this.target = {};
|
|
8273
8309
|
}
|
|
8274
8310
|
// Update visual element with new options
|
|
@@ -8322,34 +8358,26 @@ class MotionState {
|
|
|
8322
8358
|
unmount(unMountChildren = false) {
|
|
8323
8359
|
const shouldDelay = this.options.layoutId && !mountedLayoutIds.has(this.options.layoutId);
|
|
8324
8360
|
const unmount = () => {
|
|
8325
|
-
var _a, _b, _c;
|
|
8326
|
-
mountedStates.delete(this.element);
|
|
8327
|
-
this.featureManager.unmount();
|
|
8328
|
-
if (unMountChildren && !shouldDelay) {
|
|
8329
|
-
frame.render(() => {
|
|
8330
|
-
var _a2;
|
|
8331
|
-
(_a2 = this.visualElement) == null ? void 0 : _a2.unmount();
|
|
8332
|
-
});
|
|
8333
|
-
} else {
|
|
8334
|
-
(_a = this.visualElement) == null ? void 0 : _a.unmount();
|
|
8335
|
-
}
|
|
8336
8361
|
if (unMountChildren) {
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8362
|
+
Array.from(this.children).reverse().forEach(this.unmountChild);
|
|
8363
|
+
}
|
|
8364
|
+
const unmountState = () => {
|
|
8365
|
+
var _a, _b, _c;
|
|
8366
|
+
(_b = (_a = this.parent) == null ? void 0 : _a.children) == null ? void 0 : _b.delete(this);
|
|
8367
|
+
mountedStates.delete(this.element);
|
|
8368
|
+
this.featureManager.unmount();
|
|
8369
|
+
(_c = this.visualElement) == null ? void 0 : _c.unmount();
|
|
8370
|
+
};
|
|
8371
|
+
if (shouldDelay) {
|
|
8372
|
+
Promise.resolve().then(unmountState);
|
|
8373
|
+
} else {
|
|
8374
|
+
unmountState();
|
|
8343
8375
|
}
|
|
8344
|
-
(_c = (_b = this.parent) == null ? void 0 : _b.children) == null ? void 0 : _c.delete(this);
|
|
8345
8376
|
};
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
} else {
|
|
8351
|
-
unmount();
|
|
8352
|
-
}
|
|
8377
|
+
unmount();
|
|
8378
|
+
}
|
|
8379
|
+
unmountChild(child) {
|
|
8380
|
+
child.unmount(true);
|
|
8353
8381
|
}
|
|
8354
8382
|
// Called before updating, executes in parent-to-child order
|
|
8355
8383
|
beforeUpdate() {
|
|
@@ -8376,7 +8404,7 @@ class MotionState {
|
|
|
8376
8404
|
});
|
|
8377
8405
|
if (isAnimate) {
|
|
8378
8406
|
this.animateUpdates({
|
|
8379
|
-
isFallback: !isActive
|
|
8407
|
+
isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants
|
|
8380
8408
|
});
|
|
8381
8409
|
}
|
|
8382
8410
|
}
|
|
@@ -8394,11 +8422,6 @@ class MotionState {
|
|
|
8394
8422
|
}
|
|
8395
8423
|
}
|
|
8396
8424
|
}
|
|
8397
|
-
function getMotionElement(el) {
|
|
8398
|
-
if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
|
|
8399
|
-
return getMotionElement(el.nextSibling);
|
|
8400
|
-
return el;
|
|
8401
|
-
}
|
|
8402
8425
|
function checkMotionIsHidden(instance) {
|
|
8403
8426
|
var _a;
|
|
8404
8427
|
const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
|
|
@@ -8425,7 +8448,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8425
8448
|
asChild: { type: Boolean },
|
|
8426
8449
|
whileDrag: {},
|
|
8427
8450
|
custom: {},
|
|
8428
|
-
initial: { type: [String, Object, Boolean] },
|
|
8451
|
+
initial: { type: [String, Array, Object, Boolean] },
|
|
8429
8452
|
animate: {},
|
|
8430
8453
|
exit: {},
|
|
8431
8454
|
variants: {},
|
|
@@ -8562,9 +8585,6 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8562
8585
|
Object.assign(attrsProps, attributes);
|
|
8563
8586
|
Object.assign(styleProps, style2);
|
|
8564
8587
|
}
|
|
8565
|
-
if (!state2.isMounted()) {
|
|
8566
|
-
Object.assign(styleProps, state2.baseTarget);
|
|
8567
|
-
}
|
|
8568
8588
|
if (props.drag && props.dragListener !== false) {
|
|
8569
8589
|
Object.assign(styleProps, {
|
|
8570
8590
|
userSelect: "none",
|
|
@@ -8699,6 +8719,11 @@ function usePopLayout(props) {
|
|
|
8699
8719
|
styles
|
|
8700
8720
|
};
|
|
8701
8721
|
}
|
|
8722
|
+
function delay(fn) {
|
|
8723
|
+
return Promise.resolve().then(() => {
|
|
8724
|
+
fn();
|
|
8725
|
+
});
|
|
8726
|
+
}
|
|
8702
8727
|
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
8703
8728
|
...{
|
|
8704
8729
|
name: "AnimatePresence",
|
|
@@ -8734,20 +8759,21 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8734
8759
|
removePopStyle(state2);
|
|
8735
8760
|
state2.isVShow = true;
|
|
8736
8761
|
removeDoneCallback(el);
|
|
8737
|
-
|
|
8762
|
+
delay(() => {
|
|
8763
|
+
state2.setActive("exit", false);
|
|
8764
|
+
});
|
|
8738
8765
|
}
|
|
8739
8766
|
const exitDom = /* @__PURE__ */ new Map();
|
|
8740
8767
|
vue.onUnmounted(() => {
|
|
8741
8768
|
exitDom.clear();
|
|
8742
8769
|
});
|
|
8743
8770
|
function exit(el, done) {
|
|
8744
|
-
|
|
8745
|
-
if (!state2) {
|
|
8746
|
-
if (!props.unwrapElement) {
|
|
8747
|
-
return done();
|
|
8748
|
-
}
|
|
8771
|
+
if (props.unwrapElement) {
|
|
8749
8772
|
el = el.firstElementChild;
|
|
8750
|
-
|
|
8773
|
+
}
|
|
8774
|
+
const state2 = mountedStates.get(el);
|
|
8775
|
+
if (!state2) {
|
|
8776
|
+
return done();
|
|
8751
8777
|
}
|
|
8752
8778
|
exitDom.set(el, true);
|
|
8753
8779
|
removeDoneCallback(el);
|
|
@@ -8770,14 +8796,16 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8770
8796
|
removePopStyle(state2);
|
|
8771
8797
|
}
|
|
8772
8798
|
done();
|
|
8773
|
-
if (!
|
|
8799
|
+
if (!el.isConnected) {
|
|
8774
8800
|
state2.unmount(true);
|
|
8775
8801
|
}
|
|
8776
8802
|
}
|
|
8777
8803
|
}
|
|
8778
8804
|
doneCallbacks.set(el, doneCallback);
|
|
8779
8805
|
el.addEventListener("motioncomplete", doneCallback);
|
|
8780
|
-
|
|
8806
|
+
delay(() => {
|
|
8807
|
+
state2.setActive("exit", true);
|
|
8808
|
+
});
|
|
8781
8809
|
}
|
|
8782
8810
|
const transitionProps = vue.computed(() => {
|
|
8783
8811
|
if (props.multiple) {
|
|
@@ -8878,7 +8906,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
8878
8906
|
asChild: { type: Boolean },
|
|
8879
8907
|
whileDrag: {},
|
|
8880
8908
|
custom: {},
|
|
8881
|
-
initial: { type: [String, Object, Boolean] },
|
|
8909
|
+
initial: { type: [String, Array, Object, Boolean] },
|
|
8882
8910
|
animate: {},
|
|
8883
8911
|
exit: {},
|
|
8884
8912
|
variants: {},
|
|
@@ -9202,7 +9230,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
9202
9230
|
asChild: { type: Boolean },
|
|
9203
9231
|
whileDrag: { default: void 0 },
|
|
9204
9232
|
custom: {},
|
|
9205
|
-
initial: { type: [String, Object, Boolean], default: void 0 },
|
|
9233
|
+
initial: { type: [String, Array, Object, Boolean], default: void 0 },
|
|
9206
9234
|
animate: { default: void 0 },
|
|
9207
9235
|
exit: {},
|
|
9208
9236
|
variants: {},
|
|
@@ -9533,6 +9561,8 @@ function animationControls() {
|
|
|
9533
9561
|
function setValues(state2, definition) {
|
|
9534
9562
|
if (typeof definition === "string") {
|
|
9535
9563
|
return setVariants(state2, [definition]);
|
|
9564
|
+
} else if (Array.isArray(definition)) {
|
|
9565
|
+
return setVariants(state2, definition);
|
|
9536
9566
|
} else {
|
|
9537
9567
|
setStateTarget(state2, definition);
|
|
9538
9568
|
setTarget(state2.visualElement, definition);
|
|
@@ -9673,6 +9703,7 @@ exports.useAnimationControls = useAnimationControls;
|
|
|
9673
9703
|
exports.useAnimationFrame = useAnimationFrame;
|
|
9674
9704
|
exports.useCombineMotionValues = useCombineMotionValues;
|
|
9675
9705
|
exports.useComputed = useComputed;
|
|
9706
|
+
exports.useDomRef = useDomRef;
|
|
9676
9707
|
exports.useDragControls = useDragControls;
|
|
9677
9708
|
exports.useInView = useInView;
|
|
9678
9709
|
exports.useLayoutGroup = useLayoutGroup;
|
|
@@ -64,6 +64,8 @@ function animationControls() {
|
|
|
64
64
|
function setValues(state, definition) {
|
|
65
65
|
if (typeof definition === "string") {
|
|
66
66
|
return setVariants(state, [definition]);
|
|
67
|
+
} else if (Array.isArray(definition)) {
|
|
68
|
+
return setVariants(state, definition);
|
|
67
69
|
} else {
|
|
68
70
|
setStateTarget(state, definition);
|
|
69
71
|
setTarget(state.visualElement, definition);
|
|
@@ -2,6 +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 { delay } from "../../utils/delay.mjs";
|
|
5
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
7
|
...{
|
|
7
8
|
name: "AnimatePresence",
|
|
@@ -37,20 +38,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
37
38
|
removePopStyle(state);
|
|
38
39
|
state.isVShow = true;
|
|
39
40
|
removeDoneCallback(el);
|
|
40
|
-
|
|
41
|
+
delay(() => {
|
|
42
|
+
state.setActive("exit", false);
|
|
43
|
+
});
|
|
41
44
|
}
|
|
42
45
|
const exitDom = /* @__PURE__ */ new Map();
|
|
43
46
|
onUnmounted(() => {
|
|
44
47
|
exitDom.clear();
|
|
45
48
|
});
|
|
46
49
|
function exit(el, done) {
|
|
47
|
-
|
|
48
|
-
if (!state) {
|
|
49
|
-
if (!props.unwrapElement) {
|
|
50
|
-
return done();
|
|
51
|
-
}
|
|
50
|
+
if (props.unwrapElement) {
|
|
52
51
|
el = el.firstElementChild;
|
|
53
|
-
|
|
52
|
+
}
|
|
53
|
+
const state = mountedStates.get(el);
|
|
54
|
+
if (!state) {
|
|
55
|
+
return done();
|
|
54
56
|
}
|
|
55
57
|
exitDom.set(el, true);
|
|
56
58
|
removeDoneCallback(el);
|
|
@@ -73,14 +75,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
73
75
|
removePopStyle(state);
|
|
74
76
|
}
|
|
75
77
|
done();
|
|
76
|
-
if (!
|
|
78
|
+
if (!el.isConnected) {
|
|
77
79
|
state.unmount(true);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
doneCallbacks.set(el, doneCallback);
|
|
82
84
|
el.addEventListener("motioncomplete", doneCallback);
|
|
83
|
-
|
|
85
|
+
delay(() => {
|
|
86
|
+
state.setActive("exit", true);
|
|
87
|
+
});
|
|
84
88
|
}
|
|
85
89
|
const transitionProps = computed(() => {
|
|
86
90
|
if (props.multiple) {
|
|
@@ -4,8 +4,9 @@ import { convertSvgStyleToAttributes, createStyles } from "../../state/style.mjs
|
|
|
4
4
|
import { Primitive } from "./Primitive.mjs";
|
|
5
5
|
import { MotionState } from "../../state/motion-state.mjs";
|
|
6
6
|
import { injectAnimatePresence } from "../presence.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { checkMotionIsHidden } from "./utils.mjs";
|
|
8
8
|
import { useMotionConfig } from "../motion-config/context.mjs";
|
|
9
|
+
import { getMotionElement } from "../hooks/use-motion-elm.mjs";
|
|
9
10
|
import { isMotionValue } from "../../utils/motion-value.mjs";
|
|
10
11
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
12
|
...{
|
|
@@ -18,7 +19,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18
19
|
asChild: { type: Boolean },
|
|
19
20
|
whileDrag: {},
|
|
20
21
|
custom: {},
|
|
21
|
-
initial: { type: [String, Object, Boolean] },
|
|
22
|
+
initial: { type: [String, Array, Object, Boolean] },
|
|
22
23
|
animate: {},
|
|
23
24
|
exit: {},
|
|
24
25
|
variants: {},
|
|
@@ -155,9 +156,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
155
156
|
Object.assign(attrsProps, attributes);
|
|
156
157
|
Object.assign(styleProps, style);
|
|
157
158
|
}
|
|
158
|
-
if (!state.isMounted()) {
|
|
159
|
-
Object.assign(styleProps, state.baseTarget);
|
|
160
|
-
}
|
|
161
159
|
if (props.drag && props.dragListener !== false) {
|
|
162
160
|
Object.assign(styleProps, {
|
|
163
161
|
userSelect: "none",
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
|
|
3
|
-
return getMotionElement(el.nextSibling);
|
|
4
|
-
return el;
|
|
5
|
-
}
|
|
1
|
+
import { getMotionElement } from "../hooks/use-motion-elm.mjs";
|
|
6
2
|
function checkMotionIsHidden(instance) {
|
|
7
3
|
var _a;
|
|
8
4
|
const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
|
|
@@ -10,6 +6,5 @@ function checkMotionIsHidden(instance) {
|
|
|
10
6
|
return hasTransition && isHidden;
|
|
11
7
|
}
|
|
12
8
|
export {
|
|
13
|
-
checkMotionIsHidden
|
|
14
|
-
getMotionElement
|
|
9
|
+
checkMotionIsHidden
|
|
15
10
|
};
|
|
@@ -17,7 +17,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17
17
|
asChild: { type: Boolean },
|
|
18
18
|
whileDrag: {},
|
|
19
19
|
custom: {},
|
|
20
|
-
initial: { type: [String, Object, Boolean] },
|
|
20
|
+
initial: { type: [String, Array, Object, Boolean] },
|
|
21
21
|
animate: {},
|
|
22
22
|
exit: {},
|
|
23
23
|
variants: {},
|
|
@@ -51,10 +51,10 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
51
51
|
layoutScroll: boolean;
|
|
52
52
|
layoutRoot: boolean;
|
|
53
53
|
crossfade: boolean;
|
|
54
|
-
initial:
|
|
55
|
-
animate:
|
|
56
|
-
inView:
|
|
57
|
-
hover:
|
|
54
|
+
initial: import('../../types').VariantLabels | import('../../types').Variant | boolean;
|
|
55
|
+
animate: import('../../types').VariantLabels | import('../../types').Variant | import('../../animation/types').AnimationControls;
|
|
56
|
+
inView: import('../../types').VariantLabels | import('../../types').Variant;
|
|
57
|
+
hover: import('../../types').VariantLabels | import('../../types').Variant;
|
|
58
58
|
whileDrag: import('../../types').Options["whileDrag"];
|
|
59
59
|
dragElastic: number;
|
|
60
60
|
dragMomentum: boolean;
|
|
@@ -17,7 +17,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17
17
|
asChild: { type: Boolean },
|
|
18
18
|
whileDrag: { default: void 0 },
|
|
19
19
|
custom: {},
|
|
20
|
-
initial: { type: [String, Object, Boolean], default: void 0 },
|
|
20
|
+
initial: { type: [String, Array, Object, Boolean], default: void 0 },
|
|
21
21
|
animate: { default: void 0 },
|
|
22
22
|
exit: {},
|
|
23
23
|
variants: {},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DragControls } from './use-drag-controls';
|
|
2
|
-
import { Variant } from '../../../types';
|
|
2
|
+
import { Variant, VariantLabels } from '../../../types';
|
|
3
3
|
import { Axis, BoundingBox, DragElastic, InertiaOptions, PanInfo } from 'framer-motion';
|
|
4
4
|
export interface ResolvedConstraints {
|
|
5
5
|
x: Partial<Axis>;
|
|
@@ -221,5 +221,5 @@ export interface DragProps extends DragHandlers {
|
|
|
221
221
|
* ```
|
|
222
222
|
*/
|
|
223
223
|
dragControls?: DragControls;
|
|
224
|
-
whileDrag?:
|
|
224
|
+
whileDrag?: VariantLabels | Variant;
|
|
225
225
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Variant } from '../../../types';
|
|
1
|
+
import { Variant, VariantLabels } from '../../../types';
|
|
2
2
|
export type FocusProps = {
|
|
3
|
-
focus?:
|
|
3
|
+
focus?: VariantLabels | Variant;
|
|
4
4
|
onFocus?: (e: FocusEvent) => void;
|
|
5
5
|
onBlur?: (e: FocusEvent) => void;
|
|
6
6
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Variant } from '../../../types';
|
|
1
|
+
import { Variant, VariantLabels } from '../../../types';
|
|
2
2
|
import { EventInfo } from 'framer-motion';
|
|
3
3
|
export type HoverEvent = (event: MouseEvent, info: EventInfo) => void;
|
|
4
4
|
export interface HoverProps {
|
|
5
|
-
hover?:
|
|
5
|
+
hover?: VariantLabels | Variant;
|
|
6
6
|
onHoverStart?: HoverEvent;
|
|
7
7
|
onHoverEnd?: HoverEvent;
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Variant } from '../../../types';
|
|
1
|
+
import { Variant, VariantLabels } from '../../../types';
|
|
2
2
|
type MarginValue = `${number}${'px' | '%'}`;
|
|
3
3
|
type MarginType = MarginValue | `${MarginValue} ${MarginValue}` | `${MarginValue} ${MarginValue} ${MarginValue}` | `${MarginValue} ${MarginValue} ${MarginValue} ${MarginValue}`;
|
|
4
4
|
export interface InViewOptions {
|
|
@@ -11,7 +11,7 @@ export interface InViewProps {
|
|
|
11
11
|
inViewOptions?: InViewOptions & {
|
|
12
12
|
once?: boolean;
|
|
13
13
|
};
|
|
14
|
-
inView?:
|
|
14
|
+
inView?: VariantLabels | Variant;
|
|
15
15
|
onViewportEnter?: ViewportEventHandler;
|
|
16
16
|
onViewportLeave?: ViewportEventHandler;
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Variant } from '../../../types';
|
|
1
|
+
import { Variant, VariantLabels } from '../../../types';
|
|
2
2
|
import { EventInfo } from 'framer-motion';
|
|
3
3
|
export type PressEvent = (event: PointerEvent, info: EventInfo) => void;
|
|
4
4
|
export interface PressProps {
|
|
@@ -6,7 +6,7 @@ export interface PressProps {
|
|
|
6
6
|
* If `true`, the press gesture will attach its start listener to window.
|
|
7
7
|
*/
|
|
8
8
|
globalPressTarget?: boolean;
|
|
9
|
-
press?:
|
|
9
|
+
press?: VariantLabels | Variant;
|
|
10
10
|
onPressStart?: PressEvent;
|
|
11
11
|
onPress?: PressEvent;
|
|
12
12
|
onPressCancel?: PressEvent;
|
|
@@ -15,22 +15,22 @@ class LayoutFeature extends Feature {
|
|
|
15
15
|
}
|
|
16
16
|
didUpdate() {
|
|
17
17
|
var _a, _b;
|
|
18
|
-
if (this.state.options.layout || this.state.options.layoutId)
|
|
18
|
+
if (this.state.options.layout || this.state.options.layoutId || this.state.options.drag)
|
|
19
19
|
(_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
|
|
20
20
|
}
|
|
21
21
|
mount() {
|
|
22
22
|
var _a;
|
|
23
23
|
const options = this.state.options;
|
|
24
24
|
const layoutGroup = this.state.options.layoutGroup;
|
|
25
|
-
if (options.layout || options.layoutId
|
|
25
|
+
if (options.layout || options.layoutId) {
|
|
26
26
|
const projection = this.state.visualElement.projection;
|
|
27
27
|
if (projection) {
|
|
28
28
|
projection.promote();
|
|
29
29
|
(_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
|
|
30
30
|
}
|
|
31
|
-
this.didUpdate();
|
|
32
31
|
globalProjectionState.hasEverUpdated = true;
|
|
33
32
|
}
|
|
33
|
+
this.didUpdate();
|
|
34
34
|
}
|
|
35
35
|
beforeUnmount() {
|
|
36
36
|
const projection = this.state.visualElement.projection;
|
|
@@ -45,11 +45,16 @@ class LayoutFeature extends Feature {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
unmount() {
|
|
48
|
+
var _a, _b;
|
|
48
49
|
const layoutGroup = this.state.options.layoutGroup;
|
|
49
50
|
const projection = this.state.visualElement.projection;
|
|
50
|
-
if (
|
|
51
|
-
layoutGroup.group
|
|
52
|
-
|
|
51
|
+
if (projection) {
|
|
52
|
+
if (layoutGroup == null ? void 0 : layoutGroup.group) {
|
|
53
|
+
layoutGroup.group.remove(projection);
|
|
54
|
+
}
|
|
55
|
+
if ((_b = (_a = projection.getStack()) == null ? void 0 : _a.lead) == null ? void 0 : _b.animationProgress) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
53
58
|
this.didUpdate();
|
|
54
59
|
}
|
|
55
60
|
}
|
package/dist/es/index.mjs
CHANGED
|
@@ -62,6 +62,7 @@ import { useInView } from "./utils/use-in-view.mjs";
|
|
|
62
62
|
import { useAnimationFrame } from "./utils/use-animation-frame.mjs";
|
|
63
63
|
import { millisecondsToSeconds, secondsToMilliseconds } from "./utils/time-conversion.mjs";
|
|
64
64
|
import { getContextWindow } from "./utils/get-context-window.mjs";
|
|
65
|
+
import { useDomRef } from "./utils/use-dom-ref.mjs";
|
|
65
66
|
export {
|
|
66
67
|
default5 as AnimatePresence,
|
|
67
68
|
default2 as LayoutGroup,
|
|
@@ -135,6 +136,7 @@ export {
|
|
|
135
136
|
useAnimationFrame,
|
|
136
137
|
useCombineMotionValues,
|
|
137
138
|
useComputed,
|
|
139
|
+
useDomRef,
|
|
138
140
|
useDragControls,
|
|
139
141
|
useInView,
|
|
140
142
|
useLayoutGroup,
|
|
@@ -88,12 +88,14 @@ function setupChildAnimations(transition, controlActiveState, isFallback) {
|
|
|
88
88
|
const childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
|
|
89
89
|
const childDelay = delayChildren + generateStaggerDuration(index);
|
|
90
90
|
return child.state.animateUpdates({
|
|
91
|
-
controlActiveState
|
|
91
|
+
controlActiveState,
|
|
92
92
|
controlDelay: isFallback ? 0 : childDelay
|
|
93
93
|
});
|
|
94
94
|
}).filter(Boolean);
|
|
95
95
|
return {
|
|
96
|
-
getChildAnimations: () => Promise.all(childAnimations.map((animation) =>
|
|
96
|
+
getChildAnimations: () => Promise.all(childAnimations.map((animation) => {
|
|
97
|
+
return typeof animation === "function" ? animation() : animation;
|
|
98
|
+
})),
|
|
97
99
|
childAnimations
|
|
98
100
|
};
|
|
99
101
|
}
|
|
@@ -29,6 +29,7 @@ export declare class MotionState {
|
|
|
29
29
|
mount(element: HTMLElement, options: Options, notAnimate?: boolean): void;
|
|
30
30
|
beforeUnmount(): void;
|
|
31
31
|
unmount(unMountChildren?: boolean): void;
|
|
32
|
+
private unmountChild;
|
|
32
33
|
beforeUpdate(): void;
|
|
33
34
|
update(options: Options): void;
|
|
34
35
|
setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
|
|
@@ -5,6 +5,7 @@ import { FeatureManager } from "../features/feature-manager.mjs";
|
|
|
5
5
|
import { createVisualElement } from "./create-visual-element.mjs";
|
|
6
6
|
import { doneCallbacks } from "../components/presence.mjs";
|
|
7
7
|
import { animateUpdates } from "./animate-updates.mjs";
|
|
8
|
+
import { isVariantLabels } from "./utils/is-variant-labels.mjs";
|
|
8
9
|
import { frame } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
|
|
9
10
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
10
11
|
let id = 0;
|
|
@@ -27,6 +28,8 @@ class MotionState {
|
|
|
27
28
|
this.parent = parent;
|
|
28
29
|
(_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
|
|
29
30
|
this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
|
|
31
|
+
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
32
|
+
this.initTarget(initialVariantSource);
|
|
30
33
|
this.visualElement = createVisualElement(this.options.as, {
|
|
31
34
|
presenceContext: null,
|
|
32
35
|
parent: parent == null ? void 0 : parent.visualElement,
|
|
@@ -44,12 +47,12 @@ class MotionState {
|
|
|
44
47
|
vars: {},
|
|
45
48
|
attrs: {}
|
|
46
49
|
},
|
|
47
|
-
latestValues: {
|
|
50
|
+
latestValues: {
|
|
51
|
+
...this.baseTarget
|
|
52
|
+
}
|
|
48
53
|
},
|
|
49
54
|
reducedMotionConfig: options.motionConfig.reduceMotion
|
|
50
55
|
});
|
|
51
|
-
const initialVariantSource = options.initial === false ? "animate" : "initial";
|
|
52
|
-
this.initTarget(initialVariantSource);
|
|
53
56
|
this.featureManager = new FeatureManager(this);
|
|
54
57
|
}
|
|
55
58
|
// Get animation context, falling back to parent context for inheritance
|
|
@@ -58,7 +61,7 @@ class MotionState {
|
|
|
58
61
|
const handler = {
|
|
59
62
|
get: (target, prop) => {
|
|
60
63
|
var _a;
|
|
61
|
-
return
|
|
64
|
+
return isVariantLabels(this.options[prop]) ? this.options[prop] : (_a = this.parent) == null ? void 0 : _a.context[prop];
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
67
|
this._context = new Proxy({}, handler);
|
|
@@ -68,9 +71,6 @@ class MotionState {
|
|
|
68
71
|
// Initialize animation target values
|
|
69
72
|
initTarget(initialVariantSource) {
|
|
70
73
|
this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
|
|
71
|
-
for (const key in this.baseTarget) {
|
|
72
|
-
this.visualElement.setStaticValue(key, this.baseTarget[key]);
|
|
73
|
-
}
|
|
74
74
|
this.target = {};
|
|
75
75
|
}
|
|
76
76
|
// Update visual element with new options
|
|
@@ -124,34 +124,26 @@ class MotionState {
|
|
|
124
124
|
unmount(unMountChildren = false) {
|
|
125
125
|
const shouldDelay = this.options.layoutId && !mountedLayoutIds.has(this.options.layoutId);
|
|
126
126
|
const unmount = () => {
|
|
127
|
-
var _a, _b, _c;
|
|
128
|
-
mountedStates.delete(this.element);
|
|
129
|
-
this.featureManager.unmount();
|
|
130
|
-
if (unMountChildren && !shouldDelay) {
|
|
131
|
-
frame.render(() => {
|
|
132
|
-
var _a2;
|
|
133
|
-
(_a2 = this.visualElement) == null ? void 0 : _a2.unmount();
|
|
134
|
-
});
|
|
135
|
-
} else {
|
|
136
|
-
(_a = this.visualElement) == null ? void 0 : _a.unmount();
|
|
137
|
-
}
|
|
138
127
|
if (unMountChildren) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
128
|
+
Array.from(this.children).reverse().forEach(this.unmountChild);
|
|
129
|
+
}
|
|
130
|
+
const unmountState = () => {
|
|
131
|
+
var _a, _b, _c;
|
|
132
|
+
(_b = (_a = this.parent) == null ? void 0 : _a.children) == null ? void 0 : _b.delete(this);
|
|
133
|
+
mountedStates.delete(this.element);
|
|
134
|
+
this.featureManager.unmount();
|
|
135
|
+
(_c = this.visualElement) == null ? void 0 : _c.unmount();
|
|
136
|
+
};
|
|
137
|
+
if (shouldDelay) {
|
|
138
|
+
Promise.resolve().then(unmountState);
|
|
139
|
+
} else {
|
|
140
|
+
unmountState();
|
|
145
141
|
}
|
|
146
|
-
(_c = (_b = this.parent) == null ? void 0 : _b.children) == null ? void 0 : _c.delete(this);
|
|
147
142
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} else {
|
|
153
|
-
unmount();
|
|
154
|
-
}
|
|
143
|
+
unmount();
|
|
144
|
+
}
|
|
145
|
+
unmountChild(child) {
|
|
146
|
+
child.unmount(true);
|
|
155
147
|
}
|
|
156
148
|
// Called before updating, executes in parent-to-child order
|
|
157
149
|
beforeUpdate() {
|
|
@@ -178,7 +170,7 @@ class MotionState {
|
|
|
178
170
|
});
|
|
179
171
|
if (isAnimate) {
|
|
180
172
|
this.animateUpdates({
|
|
181
|
-
isFallback: !isActive
|
|
173
|
+
isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants
|
|
182
174
|
});
|
|
183
175
|
}
|
|
184
176
|
}
|
package/dist/es/state/utils.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
function resolveVariant(definition, variants, custom) {
|
|
2
|
-
if (
|
|
2
|
+
if (Array.isArray(definition)) {
|
|
3
|
+
return definition.reduce((acc, item) => {
|
|
4
|
+
const resolvedVariant = resolveVariant(item, variants, custom);
|
|
5
|
+
return resolvedVariant ? { ...acc, ...resolvedVariant } : acc;
|
|
6
|
+
}, {});
|
|
7
|
+
} else if (typeof definition === "object") {
|
|
3
8
|
return definition;
|
|
4
9
|
} else if (definition && variants) {
|
|
5
10
|
const variant = variants[definition];
|
|
@@ -24,7 +29,7 @@ function shallowCompare(next, prev) {
|
|
|
24
29
|
return true;
|
|
25
30
|
}
|
|
26
31
|
function getOptions(options, key) {
|
|
27
|
-
return options[key] ? { ...options, ...options[key] } : { ...options };
|
|
32
|
+
return options[key] ? { ...options, ...options[key], [key]: void 0 } : { ...options };
|
|
28
33
|
}
|
|
29
34
|
function isCssVar(name) {
|
|
30
35
|
return name == null ? void 0 : name.startsWith("--");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Inertia, Keyframes, None, Repeat, Spring, Tween } from 'framer-motion';
|
|
2
|
+
export type { Point } from 'framer-motion';
|
|
2
3
|
export interface FrameData {
|
|
3
4
|
delta: number;
|
|
4
5
|
timestamp: number;
|
|
@@ -40,4 +41,3 @@ type TransitionMap = Orchestration & TransitionDefinition & {
|
|
|
40
41
|
[key: string]: TransitionDefinition;
|
|
41
42
|
};
|
|
42
43
|
export type $Transition = (Orchestration & Repeat & TransitionDefinition) | (Orchestration & Repeat & TransitionMap);
|
|
43
|
-
export {};
|
package/dist/es/types/state.d.ts
CHANGED
|
@@ -17,7 +17,11 @@ export type TargetResolver = (custom: any, current: Target, velocity: Target) =>
|
|
|
17
17
|
export interface Variant extends DOMKeyframesDefinition {
|
|
18
18
|
transition?: $Transition;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Either a string, or array of strings, that reference variants defined via the `variants` prop.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export type VariantLabels = string | string[];
|
|
21
25
|
interface BoundingBox {
|
|
22
26
|
top: number;
|
|
23
27
|
right: number;
|
|
@@ -28,16 +32,17 @@ export interface DragOptions {
|
|
|
28
32
|
constraints?: false | Partial<BoundingBox>;
|
|
29
33
|
dragSnapToOrigin?: boolean;
|
|
30
34
|
}
|
|
35
|
+
type TransformPropertiesWithoutTransition = Omit<TransformProperties, 'transition'>;
|
|
31
36
|
export type MotionStyle = Partial<{
|
|
32
|
-
[K in keyof Variant]:
|
|
37
|
+
[K in keyof (Variant & TransformPropertiesWithoutTransition)]: string | number | undefined | MotionValue;
|
|
33
38
|
}>;
|
|
34
39
|
export type ElementType = keyof IntrinsicElementAttributes;
|
|
35
40
|
export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps, InViewProps, DragProps, PanProps, FocusProps {
|
|
36
41
|
custom?: T;
|
|
37
42
|
as?: ElementType;
|
|
38
|
-
initial?:
|
|
39
|
-
animate?:
|
|
40
|
-
exit?:
|
|
43
|
+
initial?: VariantLabels | Variant | boolean;
|
|
44
|
+
animate?: VariantLabels | Variant | AnimationControls;
|
|
45
|
+
exit?: VariantLabels | Variant;
|
|
41
46
|
variants?: {
|
|
42
47
|
[k: string]: Variant | ((custom: T) => Variant);
|
|
43
48
|
};
|
|
@@ -52,12 +57,12 @@ export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps,
|
|
|
52
57
|
onUpdate?: (latest: ResolvedValues) => void;
|
|
53
58
|
}
|
|
54
59
|
export interface MotionStateContext {
|
|
55
|
-
initial?:
|
|
56
|
-
animate?:
|
|
57
|
-
inView?:
|
|
58
|
-
hover?:
|
|
59
|
-
press?:
|
|
60
|
-
exit?:
|
|
60
|
+
initial?: VariantLabels;
|
|
61
|
+
animate?: VariantLabels;
|
|
62
|
+
inView?: VariantLabels;
|
|
63
|
+
hover?: VariantLabels;
|
|
64
|
+
press?: VariantLabels;
|
|
65
|
+
exit?: VariantLabels;
|
|
61
66
|
}
|
|
62
67
|
export type AnimationFactory = () => AnimationPlaybackControls | undefined;
|
|
63
68
|
export interface CssPropertyDefinition {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function delay(fn: () => void): Promise<void>;
|
package/dist/es/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useDomRef
|
|
1
|
+
export declare function useDomRef(): import('vue').Ref<any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getMotionElement } from "../components/hooks/use-motion-elm.mjs";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
function useDomRef() {
|
|
4
|
+
const dom = ref(null);
|
|
5
|
+
const domProxy = new Proxy(dom, {
|
|
6
|
+
get(target, key) {
|
|
7
|
+
if (typeof key === "string" || typeof key === "symbol") {
|
|
8
|
+
return Reflect.get(target, key);
|
|
9
|
+
}
|
|
10
|
+
return void 0;
|
|
11
|
+
},
|
|
12
|
+
set(target, key, value) {
|
|
13
|
+
if (key === "value")
|
|
14
|
+
return Reflect.set(target, key, getMotionElement((value == null ? void 0 : value.$el) || value));
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return domProxy;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
useDomRef
|
|
22
|
+
};
|
package/package.json
CHANGED
|
File without changes
|