motion-v 0.13.1 → 1.0.0-alpha.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 +1055 -1009
- package/dist/es/components/index.d.ts +2 -0
- package/dist/es/components/lazy-motion/context.d.ts +7 -0
- package/dist/es/components/lazy-motion/context.mjs +6 -0
- package/dist/es/components/lazy-motion/index.d.ts +26 -0
- package/dist/es/components/lazy-motion/index.mjs +36 -0
- package/dist/es/components/motion/index.d.ts +179 -2
- package/dist/es/components/motion/index.mjs +8 -0
- package/dist/es/components/motion/m.d.ts +178 -0
- package/dist/es/components/motion/m.mjs +7 -0
- package/dist/es/components/motion/props.d.ts +227 -0
- package/dist/es/components/motion/props.mjs +93 -0
- package/dist/es/components/motion/{Motion.d.ts → types.d.ts} +12 -9
- package/dist/es/components/motion/use-motion-state.d.ts +790 -0
- package/dist/es/components/motion/use-motion-state.mjs +116 -0
- package/dist/es/components/motion/utils.d.ts +20 -5
- package/dist/es/components/motion/utils.mjs +122 -1
- package/dist/es/components/reorder/Group.vue.mjs +5 -2
- package/dist/es/components/reorder/Item.vue.mjs +5 -2
- package/dist/es/components/reorder/index.d.ts +12 -0
- package/dist/es/features/animation/animation.d.ts +32 -0
- package/dist/es/features/animation/animation.mjs +186 -5
- package/dist/es/features/animation/types.d.ts +17 -0
- package/dist/es/features/dom-animation.d.ts +2 -0
- package/dist/es/features/dom-animation.mjs +19 -0
- package/dist/es/features/dom-max.d.ts +2 -0
- package/dist/es/features/dom-max.mjs +23 -0
- package/dist/es/features/feature-manager.mjs +20 -20
- package/dist/es/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
- package/dist/es/features/gestures/hover/index.d.ts +2 -0
- package/dist/es/features/gestures/hover/index.mjs +13 -2
- package/dist/es/features/gestures/in-view/index.mjs +3 -3
- package/dist/es/features/gestures/index.d.ts +0 -1
- package/dist/es/features/gestures/press/index.mjs +17 -19
- package/dist/es/features/index.d.ts +2 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.mjs +17 -9
- package/dist/es/state/motion-state.d.ts +8 -6
- package/dist/es/state/motion-state.mjs +13 -45
- package/dist/es/state/style.mjs +2 -2
- package/dist/es/state/transform.d.ts +0 -1
- package/dist/es/state/transform.mjs +0 -1
- package/dist/es/types/state.d.ts +1 -0
- package/dist/nuxt/index.cjs +3 -1
- package/dist/nuxt/index.mjs +3 -1
- package/dist/resolver/index.cjs +3 -1
- package/dist/resolver/index.mjs +3 -1
- package/package.json +1 -1
- package/dist/es/components/motion/Motion.vue.mjs +0 -241
- package/dist/es/components/motion/Motion.vue2.mjs +0 -4
- package/dist/es/components/motion/NameSpace.d.ts +0 -15
- package/dist/es/components/motion/NameSpace.mjs +0 -48
- package/dist/es/components/motion/Primitive.d.ts +0 -57
- package/dist/es/components/motion/Primitive.mjs +0 -45
- package/dist/es/components/motion/Slot.d.ts +0 -5
- package/dist/es/components/motion/Slot.mjs +0 -36
- package/dist/es/components/motion/renderSlotFragments.mjs +0 -13
- package/dist/es/features/gestures/base.d.ts +0 -8
- package/dist/es/state/animate-updates.d.ts +0 -20
- package/dist/es/state/animate-updates.mjs +0 -147
- package/dist/es/utils/noop.d.ts +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $Transition, Options } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Core animation update function that handles all animation state changes and execution
|
|
4
|
+
* @param controlActiveState - Animation states that need to be updated
|
|
5
|
+
* @param controlDelay - Animation delay time
|
|
6
|
+
* @param directAnimate - Direct animation target value
|
|
7
|
+
* @param directTransition - Direct animation transition config
|
|
8
|
+
*/
|
|
9
|
+
export interface AnimateUpdatesOptions {
|
|
10
|
+
controlActiveState?: Partial<Record<string, boolean>>;
|
|
11
|
+
controlDelay?: number;
|
|
12
|
+
directAnimate?: Options['animate'];
|
|
13
|
+
directTransition?: $Transition;
|
|
14
|
+
isFallback?: boolean;
|
|
15
|
+
isExit?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type AnimateUpdates = (options?: AnimateUpdatesOptions) => Promise<any> | (() => Promise<any>);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AnimationFeature } from "./animation/animation.mjs";
|
|
2
|
+
import { PressGesture } from "./gestures/press/index.mjs";
|
|
3
|
+
import { HoverGesture } from "./gestures/hover/index.mjs";
|
|
4
|
+
import { InViewGesture } from "./gestures/in-view/index.mjs";
|
|
5
|
+
import { FocusGesture } from "./gestures/focus/index.mjs";
|
|
6
|
+
const domAnimation = [
|
|
7
|
+
AnimationFeature,
|
|
8
|
+
PressGesture,
|
|
9
|
+
HoverGesture,
|
|
10
|
+
InViewGesture,
|
|
11
|
+
FocusGesture
|
|
12
|
+
// ProjectionFeature,
|
|
13
|
+
// DragGesture,
|
|
14
|
+
// LayoutFeature,
|
|
15
|
+
// PanGesture,
|
|
16
|
+
];
|
|
17
|
+
export {
|
|
18
|
+
domAnimation
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AnimationFeature } from "./animation/animation.mjs";
|
|
2
|
+
import { PressGesture } from "./gestures/press/index.mjs";
|
|
3
|
+
import { HoverGesture } from "./gestures/hover/index.mjs";
|
|
4
|
+
import { InViewGesture } from "./gestures/in-view/index.mjs";
|
|
5
|
+
import { FocusGesture } from "./gestures/focus/index.mjs";
|
|
6
|
+
import { ProjectionFeature } from "./layout/projection.mjs";
|
|
7
|
+
import { DragGesture } from "./gestures/drag/index.mjs";
|
|
8
|
+
import { LayoutFeature } from "./layout/layout.mjs";
|
|
9
|
+
import { PanGesture } from "./gestures/pan/index.mjs";
|
|
10
|
+
const domMax = [
|
|
11
|
+
AnimationFeature,
|
|
12
|
+
PressGesture,
|
|
13
|
+
HoverGesture,
|
|
14
|
+
InViewGesture,
|
|
15
|
+
FocusGesture,
|
|
16
|
+
ProjectionFeature,
|
|
17
|
+
PanGesture,
|
|
18
|
+
DragGesture,
|
|
19
|
+
LayoutFeature
|
|
20
|
+
];
|
|
21
|
+
export {
|
|
22
|
+
domMax
|
|
23
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PanGesture } from "./gestures/pan/index.mjs";
|
|
3
|
-
import { AnimationFeature } from "./animation/animation.mjs";
|
|
4
|
-
import { ProjectionFeature } from "./layout/projection.mjs";
|
|
5
|
-
import { FocusGesture } from "./gestures/focus/index.mjs";
|
|
6
|
-
import { HoverGesture } from "./gestures/hover/index.mjs";
|
|
7
|
-
import { PressGesture } from "./gestures/press/index.mjs";
|
|
8
|
-
import { InViewGesture } from "./gestures/in-view/index.mjs";
|
|
9
|
-
import { DragGesture } from "./gestures/drag/index.mjs";
|
|
1
|
+
import { watch } from "vue";
|
|
10
2
|
class FeatureManager {
|
|
11
3
|
constructor(state) {
|
|
12
4
|
this.features = [];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
const { features = [], lazyMotionContext } = state.options;
|
|
6
|
+
const allFeatures = features.concat(lazyMotionContext.features.value);
|
|
7
|
+
this.features = allFeatures.map((Feature) => new Feature(state));
|
|
8
|
+
const featureInstances = this.features;
|
|
9
|
+
watch(lazyMotionContext.features, (features2) => {
|
|
10
|
+
features2.forEach((feature) => {
|
|
11
|
+
if (!allFeatures.includes(feature)) {
|
|
12
|
+
allFeatures.push(feature);
|
|
13
|
+
const featureInstance = new feature(state);
|
|
14
|
+
featureInstances.push(featureInstance);
|
|
15
|
+
if (state.isMounted()) {
|
|
16
|
+
featureInstance.beforeMount();
|
|
17
|
+
featureInstance.mount();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}, {
|
|
22
|
+
flush: "pre"
|
|
23
|
+
});
|
|
24
24
|
}
|
|
25
25
|
mount() {
|
|
26
26
|
this.features.forEach((feature) => feature.mount());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MotionProps } from '../../../components/motion/Motion';
|
|
2
1
|
import { Options } from '../../../types';
|
|
3
2
|
import { Point, VisualElement } from 'framer-motion';
|
|
3
|
+
import { MotionProps } from '../../../components';
|
|
4
4
|
export declare const elementDragControls: WeakMap<VisualElement<unknown, unknown, {}>, VisualElementDragControls>;
|
|
5
5
|
export interface DragControlOptions {
|
|
6
6
|
snapToCursor?: boolean;
|
|
@@ -14,15 +14,26 @@ function handleHoverEvent(state, event, lifecycle) {
|
|
|
14
14
|
}
|
|
15
15
|
class HoverGesture extends Feature {
|
|
16
16
|
isActive() {
|
|
17
|
-
|
|
17
|
+
const { whileHover, onHoverStart, onHoverEnd } = this.state.options;
|
|
18
|
+
return Boolean(whileHover || onHoverStart || onHoverEnd);
|
|
18
19
|
}
|
|
19
20
|
constructor(state) {
|
|
20
21
|
super(state);
|
|
21
22
|
}
|
|
22
23
|
mount() {
|
|
24
|
+
this.register();
|
|
25
|
+
}
|
|
26
|
+
update() {
|
|
27
|
+
const { whileHover, onHoverStart, onHoverEnd } = this.state.visualElement.prevProps;
|
|
28
|
+
if (!(whileHover || onHoverStart || onHoverEnd)) {
|
|
29
|
+
this.register();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
register() {
|
|
23
33
|
const element = this.state.element;
|
|
24
|
-
if (!element)
|
|
34
|
+
if (!element || !this.isActive())
|
|
25
35
|
return;
|
|
36
|
+
this.unmount();
|
|
26
37
|
this.unmount = hover(
|
|
27
38
|
element,
|
|
28
39
|
(el, startEvent) => {
|
|
@@ -14,17 +14,17 @@ function handleHoverEvent(state, entry, lifecycle) {
|
|
|
14
14
|
}
|
|
15
15
|
class InViewGesture extends Feature {
|
|
16
16
|
isActive() {
|
|
17
|
-
return Boolean(this.state.
|
|
17
|
+
return Boolean(this.state.options.whileInView);
|
|
18
18
|
}
|
|
19
19
|
constructor(state) {
|
|
20
20
|
super(state);
|
|
21
21
|
}
|
|
22
22
|
startObserver() {
|
|
23
23
|
const element = this.state.element;
|
|
24
|
-
if (!element)
|
|
24
|
+
if (!element || !this.isActive())
|
|
25
25
|
return;
|
|
26
26
|
this.unmount();
|
|
27
|
-
const { once, ...viewOptions } = this.state.
|
|
27
|
+
const { once, ...viewOptions } = this.state.options.inViewOptions || {};
|
|
28
28
|
this.unmount = inView(
|
|
29
29
|
element,
|
|
30
30
|
(_, entry) => {
|
|
@@ -31,30 +31,28 @@ class PressGesture extends Feature {
|
|
|
31
31
|
this.register();
|
|
32
32
|
}
|
|
33
33
|
update() {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
34
|
+
const { whilePress, onPress, onPressCancel, onPressStart } = this.state.options;
|
|
35
|
+
if (!(whilePress || onPress || onPressCancel || onPressStart)) {
|
|
36
36
|
this.register();
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
register() {
|
|
40
|
+
const element = this.state.element;
|
|
41
|
+
if (!element || !this.isActive())
|
|
42
|
+
return;
|
|
40
43
|
this.unmount();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
{ useGlobalTarget: this.state.options.globalPressTarget }
|
|
56
|
-
);
|
|
57
|
-
}
|
|
44
|
+
this.unmount = press(
|
|
45
|
+
element,
|
|
46
|
+
(el, startEvent) => {
|
|
47
|
+
handlePressEvent(this.state, startEvent, "Start");
|
|
48
|
+
return (endEvent, { success }) => handlePressEvent(
|
|
49
|
+
this.state,
|
|
50
|
+
endEvent,
|
|
51
|
+
success ? "End" : "Cancel"
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
{ useGlobalTarget: this.state.options.globalPressTarget }
|
|
55
|
+
);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
export {
|
package/dist/es/index.d.ts
CHANGED
package/dist/es/index.mjs
CHANGED
|
@@ -3,10 +3,11 @@ import { default as default2 } from "./components/LayoutGroup.vue.mjs";
|
|
|
3
3
|
import { useLayoutGroup } from "./components/use-layout-group.mjs";
|
|
4
4
|
import { injectLayoutGroup, injectMotion, provideLayoutGroup, provideMotion } from "./components/context.mjs";
|
|
5
5
|
import { useDragControls } from "./features/gestures/drag/use-drag-controls.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
6
|
+
import { domMax } from "./features/dom-max.mjs";
|
|
7
|
+
import { domAnimation } from "./features/dom-animation.mjs";
|
|
8
|
+
import { default as default3 } from "./components/RowValue.vue.mjs";
|
|
9
|
+
import { default as default4 } from "./components/animate-presence/AnimatePresence.vue.mjs";
|
|
10
|
+
import { default as default5 } from "./components/motion-config/MotionConfig.vue.mjs";
|
|
10
11
|
import { MotionValue, cancelFrame, frame, frameData, hover, isDragActive, motionValue, press, time, motionValue as motionValue2 } from "motion-dom";
|
|
11
12
|
import { invariant } from "./external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
12
13
|
import { noop } from "./external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
|
|
@@ -36,10 +37,12 @@ import { mix } from "./external/.pnpm/framer-motion@12.5.0/external/framer-motio
|
|
|
36
37
|
import { pipe } from "./external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/pipe.mjs";
|
|
37
38
|
import { transform } from "./external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/transform.mjs";
|
|
38
39
|
import { wrap } from "./external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/wrap.mjs";
|
|
39
|
-
import { motion } from "./components/motion/
|
|
40
|
+
import { Motion, motion } from "./components/motion/index.mjs";
|
|
40
41
|
import { mountedStates } from "./state/motion-state.mjs";
|
|
41
42
|
import { provideMotionConfig, useMotionConfig } from "./components/motion-config/context.mjs";
|
|
42
43
|
import { Reorder, ReorderGroup, ReorderItem } from "./components/reorder/index.mjs";
|
|
44
|
+
import { LazyMotion } from "./components/lazy-motion/index.mjs";
|
|
45
|
+
import { M, m } from "./components/motion/m.mjs";
|
|
43
46
|
import { useComputed } from "./value/use-computed.mjs";
|
|
44
47
|
import { useCombineMotionValues } from "./value/use-combine-values.mjs";
|
|
45
48
|
import { useTransform } from "./value/use-transform.mjs";
|
|
@@ -60,15 +63,17 @@ import { millisecondsToSeconds, secondsToMilliseconds } from "./utils/time-conve
|
|
|
60
63
|
import { getContextWindow } from "./utils/get-context-window.mjs";
|
|
61
64
|
import { useDomRef } from "./utils/use-dom-ref.mjs";
|
|
62
65
|
export {
|
|
63
|
-
|
|
66
|
+
default4 as AnimatePresence,
|
|
64
67
|
default2 as LayoutGroup,
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
LazyMotion,
|
|
69
|
+
M,
|
|
70
|
+
Motion,
|
|
71
|
+
default5 as MotionConfig,
|
|
67
72
|
MotionValue,
|
|
68
73
|
Reorder,
|
|
69
74
|
ReorderGroup,
|
|
70
75
|
ReorderItem,
|
|
71
|
-
|
|
76
|
+
default3 as RowValue,
|
|
72
77
|
addScaleCorrector,
|
|
73
78
|
animate,
|
|
74
79
|
animateMini,
|
|
@@ -87,6 +92,8 @@ export {
|
|
|
87
92
|
delayInSeconds as delay,
|
|
88
93
|
distance,
|
|
89
94
|
distance2D,
|
|
95
|
+
domAnimation,
|
|
96
|
+
domMax,
|
|
90
97
|
easeIn,
|
|
91
98
|
easeInOut,
|
|
92
99
|
easeOut,
|
|
@@ -103,6 +110,7 @@ export {
|
|
|
103
110
|
isDragActive,
|
|
104
111
|
isMotionValue,
|
|
105
112
|
keyframes,
|
|
113
|
+
m,
|
|
106
114
|
millisecondsToSeconds,
|
|
107
115
|
mirrorEasing,
|
|
108
116
|
mix,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { MotionStateContext, Options } from '../types';
|
|
2
2
|
import { DOMKeyframesDefinition, VisualElement } from 'framer-motion';
|
|
3
3
|
import { frame } from 'framer-motion/dom';
|
|
4
|
+
import { Feature, StateType } from '../features';
|
|
4
5
|
import { PresenceContext } from '../components/presence';
|
|
5
|
-
import {
|
|
6
|
+
import { AnimateUpdates } from '../features/animation/types';
|
|
7
|
+
import { LazyMotionContext } from '../components/lazy-motion/context';
|
|
6
8
|
export declare const mountedStates: WeakMap<Element, MotionState>;
|
|
7
9
|
/**
|
|
8
10
|
* Core class that manages animation state and orchestrates animations.
|
|
@@ -10,10 +12,13 @@ export declare const mountedStates: WeakMap<Element, MotionState>;
|
|
|
10
12
|
*/
|
|
11
13
|
export declare class MotionState {
|
|
12
14
|
readonly id: string;
|
|
15
|
+
type: 'html' | 'svg';
|
|
13
16
|
element: HTMLElement | null;
|
|
14
|
-
|
|
17
|
+
parent?: MotionState;
|
|
15
18
|
options: Options & {
|
|
16
19
|
animatePresenceContext?: PresenceContext;
|
|
20
|
+
features?: Feature[];
|
|
21
|
+
lazyMotionContext?: LazyMotionContext;
|
|
17
22
|
};
|
|
18
23
|
isSafeToRemove: boolean;
|
|
19
24
|
isVShow: boolean;
|
|
@@ -46,10 +51,7 @@ export declare class MotionState {
|
|
|
46
51
|
beforeUpdate(): void;
|
|
47
52
|
update(options: Options): void;
|
|
48
53
|
setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
|
|
49
|
-
animateUpdates:
|
|
54
|
+
animateUpdates: AnimateUpdates;
|
|
50
55
|
isMounted(): boolean;
|
|
51
|
-
getOptions(): Options<any> & {
|
|
52
|
-
animatePresenceContext?: PresenceContext;
|
|
53
|
-
};
|
|
54
56
|
willUpdate(label: string): void;
|
|
55
57
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { invariant } from "hey-listen";
|
|
2
|
-
import {
|
|
3
|
-
import { resolveVariant, isAnimateChanged } from "./utils.mjs";
|
|
2
|
+
import { isSVGElement, resolveVariant, isAnimateChanged } from "./utils.mjs";
|
|
4
3
|
import { FeatureManager } from "../features/feature-manager.mjs";
|
|
5
|
-
import { createVisualElement } from "./create-visual-element.mjs";
|
|
6
4
|
import { doneCallbacks } from "../components/presence.mjs";
|
|
7
|
-
import { animateUpdates } from "./animate-updates.mjs";
|
|
8
5
|
import { isVariantLabels } from "./utils/is-variant-labels.mjs";
|
|
6
|
+
import { noop } from "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
|
|
7
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
9
8
|
import { frame, cancelFrame } from "motion-dom";
|
|
10
9
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
11
10
|
let id = 0;
|
|
@@ -23,7 +22,7 @@ class MotionState {
|
|
|
23
22
|
};
|
|
24
23
|
this.currentProcess = null;
|
|
25
24
|
this._context = null;
|
|
26
|
-
this.animateUpdates =
|
|
25
|
+
this.animateUpdates = noop;
|
|
27
26
|
this.id = `motion-state-${id++}`;
|
|
28
27
|
this.options = options;
|
|
29
28
|
this.parent = parent;
|
|
@@ -31,30 +30,8 @@ class MotionState {
|
|
|
31
30
|
this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
|
|
32
31
|
const initialVariantSource = this.context.initial === false ? ["initial", "animate"] : ["initial"];
|
|
33
32
|
this.initTarget(initialVariantSource);
|
|
34
|
-
this.visualElement = createVisualElement(this.options.as, {
|
|
35
|
-
presenceContext: null,
|
|
36
|
-
parent: parent == null ? void 0 : parent.visualElement,
|
|
37
|
-
props: {
|
|
38
|
-
...this.options,
|
|
39
|
-
whileHover: this.options.whileHover,
|
|
40
|
-
whileTap: this.options.whilePress,
|
|
41
|
-
whileInView: this.options.whileInView
|
|
42
|
-
},
|
|
43
|
-
visualState: {
|
|
44
|
-
renderState: {
|
|
45
|
-
transform: {},
|
|
46
|
-
transformOrigin: {},
|
|
47
|
-
style: {},
|
|
48
|
-
vars: {},
|
|
49
|
-
attrs: {}
|
|
50
|
-
},
|
|
51
|
-
latestValues: {
|
|
52
|
-
...this.baseTarget
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
reducedMotionConfig: options.motionConfig.reduceMotion
|
|
56
|
-
});
|
|
57
33
|
this.featureManager = new FeatureManager(this);
|
|
34
|
+
this.type = isSVGElement(this.options.as) ? "svg" : "html";
|
|
58
35
|
}
|
|
59
36
|
// Get animation context, falling back to parent context for inheritance
|
|
60
37
|
get context() {
|
|
@@ -81,11 +58,10 @@ class MotionState {
|
|
|
81
58
|
}
|
|
82
59
|
// Update visual element with new options
|
|
83
60
|
updateOptions() {
|
|
84
|
-
|
|
61
|
+
var _a;
|
|
62
|
+
(_a = this.visualElement) == null ? void 0 : _a.update({
|
|
85
63
|
...this.options,
|
|
86
|
-
|
|
87
|
-
whileTap: this.options.press,
|
|
88
|
-
whileInView: this.options.inView,
|
|
64
|
+
whileTap: this.options.whilePress,
|
|
89
65
|
reducedMotionConfig: this.options.motionConfig.reduceMotion
|
|
90
66
|
}, {
|
|
91
67
|
isPresent: !doneCallbacks.has(this.element)
|
|
@@ -97,25 +73,20 @@ class MotionState {
|
|
|
97
73
|
}
|
|
98
74
|
// Mount motion state to DOM element, handles parent-child relationships
|
|
99
75
|
mount(element, options, notAnimate = false) {
|
|
76
|
+
var _a;
|
|
100
77
|
invariant(
|
|
101
78
|
Boolean(element),
|
|
102
79
|
"Animation state must be mounted with valid Element"
|
|
103
80
|
);
|
|
104
81
|
this.element = element;
|
|
105
82
|
this.options = options;
|
|
106
|
-
mountedStates.set(element, this);
|
|
107
|
-
if (!visualElementStore.get(element)) {
|
|
108
|
-
this.visualElement.mount(element);
|
|
109
|
-
visualElementStore.set(element, this.visualElement);
|
|
110
|
-
}
|
|
111
|
-
this.visualElement.state = this;
|
|
112
83
|
this.updateOptions();
|
|
113
84
|
this.featureManager.mount();
|
|
114
85
|
if (!notAnimate && this.options.animate) {
|
|
115
|
-
if (this.
|
|
86
|
+
if (this.type === "svg") {
|
|
116
87
|
this.visualElement.updateDimensions();
|
|
117
88
|
}
|
|
118
|
-
this.startAnimation();
|
|
89
|
+
(_a = this.startAnimation) == null ? void 0 : _a.call(this);
|
|
119
90
|
}
|
|
120
91
|
if (this.options.layoutId) {
|
|
121
92
|
mountedLayoutIds.add(this.options.layoutId);
|
|
@@ -125,10 +96,10 @@ class MotionState {
|
|
|
125
96
|
}
|
|
126
97
|
}
|
|
127
98
|
clearAnimation() {
|
|
128
|
-
var _a;
|
|
99
|
+
var _a, _b;
|
|
129
100
|
this.currentProcess && cancelFrame(this.currentProcess);
|
|
130
101
|
this.currentProcess = null;
|
|
131
|
-
(_a = this.visualElement.variantChildren) == null ? void 0 :
|
|
102
|
+
(_b = (_a = this.visualElement) == null ? void 0 : _a.variantChildren) == null ? void 0 : _b.forEach((child) => {
|
|
132
103
|
child.state.clearAnimation();
|
|
133
104
|
});
|
|
134
105
|
}
|
|
@@ -203,9 +174,6 @@ class MotionState {
|
|
|
203
174
|
isMounted() {
|
|
204
175
|
return Boolean(this.element);
|
|
205
176
|
}
|
|
206
|
-
getOptions() {
|
|
207
|
-
return this.options;
|
|
208
|
-
}
|
|
209
177
|
// Called before layout updates to prepare for changes
|
|
210
178
|
willUpdate(label) {
|
|
211
179
|
var _a;
|
package/dist/es/state/style.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isTransform, transformAlias,
|
|
1
|
+
import { isCssVar, isNumber } from "./utils.mjs";
|
|
2
|
+
import { transformDefinitions, isTransform, transformAlias, buildTransformTemplate } from "./transform.mjs";
|
|
3
3
|
import { px } from "../value/types/numbers/units.mjs";
|
|
4
4
|
import { isMotionValue } from "../utils/motion-value.mjs";
|
|
5
5
|
const style = {
|
|
@@ -13,7 +13,6 @@ export declare const transformAlias: {
|
|
|
13
13
|
};
|
|
14
14
|
export declare function compareTransformOrder([a]: [string, any], [b]: [string, any]): number;
|
|
15
15
|
export declare function buildTransformTemplate(transforms: [string, any][]): string;
|
|
16
|
-
export declare function getFirstAnimateTransform(initialFrame: any, animateFrame: any): any;
|
|
17
16
|
export declare const transformResetValue: {
|
|
18
17
|
translate: number[];
|
|
19
18
|
rotate: number;
|
package/dist/es/types/state.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps,
|
|
|
58
58
|
motionConfig?: MotionConfigState;
|
|
59
59
|
onAnimationComplete?: (definition: Options['animate']) => void;
|
|
60
60
|
onUpdate?: (latest: ResolvedValues) => void;
|
|
61
|
+
onAnimationStart?: (definition: Options['animate']) => void;
|
|
61
62
|
}
|
|
62
63
|
export interface MotionStateContext {
|
|
63
64
|
initial?: VariantLabels | boolean;
|
package/dist/nuxt/index.cjs
CHANGED
package/dist/nuxt/index.mjs
CHANGED
package/dist/resolver/index.cjs
CHANGED
package/dist/resolver/index.mjs
CHANGED