motion-v 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +213 -165
- package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +19 -8
- package/dist/es/components/animate-presence/utils.mjs +10 -0
- package/dist/es/components/{Motion.vue.mjs → motion/Motion.vue.mjs} +7 -7
- package/dist/es/components/motion/NameSpace.mjs +47 -0
- package/dist/es/constants/index.mjs +3 -1
- package/dist/es/features/gestures/drag/use-drag-controls.mjs +43 -0
- package/dist/es/features/gestures/in-view/index.mjs +25 -5
- package/dist/es/features/layout/projection.mjs +7 -30
- package/dist/es/index.mjs +8 -4
- package/dist/es/state/motion-state.mjs +69 -53
- package/dist/es/state/transform.mjs +1 -0
- package/dist/src/components/LayoutGroup.d.ts +10 -1
- package/dist/src/components/animate-presence/AnimatePresence.d.ts +27 -2
- package/dist/src/components/animate-presence/utils.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/{Motion.d.ts → motion/Motion.d.ts} +2 -2
- package/dist/src/components/motion/NameSpace.d.ts +11 -0
- package/dist/src/components/{Primitive.d.ts → motion/Primitive.d.ts} +5 -5
- package/dist/src/components/{Slot.d.ts → motion/Slot.d.ts} +1 -1
- package/dist/src/components/motion/index.d.ts +2 -0
- package/dist/src/components/motion-config/MotionConfig.d.ts +23 -2
- package/dist/src/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
- package/dist/src/features/gestures/in-view/index.d.ts +2 -0
- package/dist/src/features/layout/projection.d.ts +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/shared/test.d.ts +1 -0
- package/dist/src/state/animate-variants-children.d.ts +2 -2
- package/dist/src/state/motion-state.d.ts +4 -1
- package/dist/src/state/utils.d.ts +3 -3
- package/dist/src/types/framer-motion.d.ts +17 -0
- package/dist/src/types/state.d.ts +6 -14
- package/dist/src/utils/use-dom-ref.d.ts +1 -2
- package/dist/src/utils/use-in-view.d.ts +1 -1
- package/package.json +1 -2
- package/dist/es/external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs +0 -6
- package/dist/es/state/animate-variants-children.mjs +0 -74
- package/dist/src/utils/events.d.ts +0 -2
- /package/dist/es/components/{Motion.vue2.mjs → motion/Motion.vue2.mjs} +0 -0
- /package/dist/es/components/{Primitive.mjs → motion/Primitive.mjs} +0 -0
- /package/dist/es/components/{Slot.mjs → motion/Slot.mjs} +0 -0
- /package/dist/es/components/{renderSlotFragments.mjs → motion/renderSlotFragments.mjs} +0 -0
- /package/dist/es/components/{utils.mjs → motion/utils.mjs} +0 -0
- /package/dist/src/components/{renderSlotFragments.d.ts → motion/renderSlotFragments.d.ts} +0 -0
- /package/dist/src/components/{utils.d.ts → motion/utils.d.ts} +0 -0
|
@@ -13,7 +13,7 @@ export interface PrimitiveProps {
|
|
|
13
13
|
*/
|
|
14
14
|
as?: AsTag | Component;
|
|
15
15
|
}
|
|
16
|
-
export declare const Primitive: import('vue').DefineComponent<
|
|
16
|
+
export declare const Primitive: import('vue').DefineComponent<{
|
|
17
17
|
asChild: {
|
|
18
18
|
type: BooleanConstructor;
|
|
19
19
|
default: boolean;
|
|
@@ -26,9 +26,9 @@ export declare const Primitive: import('vue').DefineComponent<import('vue').Extr
|
|
|
26
26
|
type: FunctionConstructor;
|
|
27
27
|
default: () => {};
|
|
28
28
|
};
|
|
29
|
-
}
|
|
29
|
+
}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
30
30
|
[key: string]: any;
|
|
31
|
-
}>,
|
|
31
|
+
}>, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
32
32
|
asChild: {
|
|
33
33
|
type: BooleanConstructor;
|
|
34
34
|
default: boolean;
|
|
@@ -41,8 +41,8 @@ export declare const Primitive: import('vue').DefineComponent<import('vue').Extr
|
|
|
41
41
|
type: FunctionConstructor;
|
|
42
42
|
default: () => {};
|
|
43
43
|
};
|
|
44
|
-
}
|
|
44
|
+
}>>, {
|
|
45
45
|
as: AsTag;
|
|
46
46
|
asChild: boolean;
|
|
47
47
|
getProps: Function;
|
|
48
|
-
}, {}
|
|
48
|
+
}, {}>;
|
|
@@ -2,4 +2,4 @@ export declare const Slot: import('vue').DefineComponent<{}, () => import('vue')
|
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}> | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
4
4
|
[key: string]: any;
|
|
5
|
-
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<
|
|
5
|
+
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
|
|
@@ -6,13 +6,34 @@ declare function __VLS_template(): {
|
|
|
6
6
|
attrs: Partial<{}>;
|
|
7
7
|
};
|
|
8
8
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
9
|
-
declare const __VLS_component: import('vue').DefineComponent<
|
|
9
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<import('./types').MotionConfigState>, {
|
|
10
10
|
reduceMotion: "user" | "never" | "always";
|
|
11
|
-
}, {}, {}, {}, string, import('vue').
|
|
11
|
+
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<import('./types').MotionConfigState>, {
|
|
12
|
+
reduceMotion: "user" | "never" | "always";
|
|
13
|
+
}>>>, {
|
|
14
|
+
reduceMotion: "user" | "never" | "always";
|
|
15
|
+
}, {}>;
|
|
12
16
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
13
17
|
export default _default;
|
|
18
|
+
type __VLS_WithDefaults<P, D> = {
|
|
19
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
20
|
+
default: D[K];
|
|
21
|
+
}> : P[K];
|
|
22
|
+
};
|
|
23
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
24
|
+
type __VLS_TypePropsToOption<T> = {
|
|
25
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
26
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
27
|
+
} : {
|
|
28
|
+
type: import('vue').PropType<T[K]>;
|
|
29
|
+
required: true;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
14
32
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
15
33
|
new (): {
|
|
16
34
|
$slots: S;
|
|
17
35
|
};
|
|
18
36
|
};
|
|
37
|
+
type __VLS_PrettifyLocal<T> = {
|
|
38
|
+
[K in keyof T]: T[K];
|
|
39
|
+
} & {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MotionProps } from '../../../components/Motion';
|
|
1
|
+
import { MotionProps } from '../../../components/motion/Motion';
|
|
2
2
|
import { Options } from '../../../types';
|
|
3
3
|
import { Point, VisualElement } from 'framer-motion';
|
|
4
4
|
export declare const elementDragControls: WeakMap<VisualElement<unknown, unknown, {}>, VisualElementDragControls>;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from 'framer-motion/dom';
|
|
2
2
|
export { motionValue as useMotionValue } from 'framer-motion/dom';
|
|
3
|
-
export { default as Motion, type MotionProps } from './components/Motion';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export { default as LayoutGroup } from './components/LayoutGroup';
|
|
6
5
|
export { useLayoutGroup } from './components/use-layout-group';
|
|
@@ -11,4 +10,5 @@ export * from './constants';
|
|
|
11
10
|
export * from './types';
|
|
12
11
|
export * from './animation';
|
|
13
12
|
export * from './utils';
|
|
13
|
+
export { useDragControls } from './features/gestures/drag/use-drag-controls';
|
|
14
14
|
export type { PanInfo } from './features/gestures/pan/PanSession';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const delay: (ms: number) => Promise<unknown>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MotionState } from './motion-state';
|
|
2
|
-
import {
|
|
2
|
+
import { $Transition, AnimationFactory } from '../types';
|
|
3
3
|
export type ActiveVariant = {
|
|
4
4
|
[key: string]: {
|
|
5
5
|
definition: string;
|
|
6
|
-
transition:
|
|
6
|
+
transition: $Transition;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
export declare function animateVariantsChildren(state: MotionState, activeState: ActiveVariant, isFirstAnimate?: boolean): {
|
|
@@ -3,6 +3,9 @@ import { DOMKeyframesDefinition, VisualElement } from 'framer-motion';
|
|
|
3
3
|
declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
|
|
4
4
|
type StateType = typeof STATE_TYPES[number];
|
|
5
5
|
export declare const mountedStates: WeakMap<Element, MotionState>;
|
|
6
|
+
/**
|
|
7
|
+
* Core class that manages animation state and orchestrates animations
|
|
8
|
+
*/
|
|
6
9
|
export declare class MotionState {
|
|
7
10
|
readonly id: string;
|
|
8
11
|
element: HTMLElement | null;
|
|
@@ -30,7 +33,7 @@ export declare class MotionState {
|
|
|
30
33
|
beforeUpdate(): void;
|
|
31
34
|
update(options: Options, notAnimate?: boolean): void;
|
|
32
35
|
setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
|
|
33
|
-
animateUpdates(
|
|
36
|
+
animateUpdates(controlActiveState?: typeof this.activeStates, controlDelay?: number): () => Promise<any>;
|
|
34
37
|
isMounted(): boolean;
|
|
35
38
|
getOptions(): Options<any>;
|
|
36
39
|
willUpdate(label: string): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Options } from '../types';
|
|
2
|
-
import {
|
|
1
|
+
import { $Transition, Options } from '../types';
|
|
2
|
+
import { Variant } from 'framer-motion';
|
|
3
3
|
import { IntrinsicElementAttributes } from 'vue';
|
|
4
4
|
export declare function resolveVariant(definition?: Options['initial'], variants?: Options['variants'], custom?: Options['custom']): Variant | undefined;
|
|
5
5
|
export declare function hasChanged(a: any, b: any): boolean;
|
|
6
6
|
export declare function shallowCompare(next: any[], prev: any[]): boolean;
|
|
7
7
|
export declare function addUniqueItem<T>(array: T[], item: T): void;
|
|
8
8
|
export declare function removeItem<T>(array: T[], item: T): void;
|
|
9
|
-
export declare function getOptions(options:
|
|
9
|
+
export declare function getOptions(options: $Transition, key: string): $Transition;
|
|
10
10
|
export declare function isCssVar(name: string): boolean;
|
|
11
11
|
export declare const noopReturn: <V>(v: V) => V;
|
|
12
12
|
export declare function isNumber(value: any): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Inertia, Keyframes, None, Repeat, Spring, Tween } from 'framer-motion';
|
|
1
2
|
export interface FrameData {
|
|
2
3
|
delta: number;
|
|
3
4
|
timestamp: number;
|
|
@@ -24,3 +25,19 @@ export interface ScrollInfoOptions {
|
|
|
24
25
|
axis?: 'x' | 'y';
|
|
25
26
|
offset?: ScrollOffset;
|
|
26
27
|
}
|
|
28
|
+
export interface Orchestration {
|
|
29
|
+
delay?: number;
|
|
30
|
+
when?: false | 'beforeChildren' | 'afterChildren' | string;
|
|
31
|
+
delayChildren?: number;
|
|
32
|
+
staggerChildren?: number;
|
|
33
|
+
staggerDirection?: number;
|
|
34
|
+
}
|
|
35
|
+
type PermissiveTransitionDefinition = {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
type TransitionDefinition = Tween | Spring | Keyframes | Inertia | None | PermissiveTransitionDefinition;
|
|
39
|
+
type TransitionMap = Orchestration & TransitionDefinition & {
|
|
40
|
+
[key: string]: TransitionDefinition;
|
|
41
|
+
};
|
|
42
|
+
export type $Transition = (Orchestration & Repeat & TransitionDefinition) | (Orchestration & Repeat & TransitionMap);
|
|
43
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DOMKeyframesDefinition, ResolvedValues, Target, TargetAndTransition } from 'framer-motion';
|
|
2
2
|
import { MotionValue, TransformProperties, animate } from 'framer-motion/dom';
|
|
3
3
|
import { IntrinsicElementAttributes } from 'vue';
|
|
4
4
|
import { LayoutOptions } from '../features/layout/types';
|
|
@@ -9,19 +9,11 @@ import { InViewProps } from '../features/gestures/in-view/types';
|
|
|
9
9
|
import { LayoutGroupState } from '../components/context';
|
|
10
10
|
import { PanProps } from '../features/gestures/pan/types';
|
|
11
11
|
import { MotionConfigState } from '../components/motion-config/types';
|
|
12
|
+
import { $Transition } from './framer-motion';
|
|
12
13
|
type AnimationPlaybackControls = ReturnType<typeof animate>;
|
|
13
|
-
export interface Orchestration {
|
|
14
|
-
delay?: number;
|
|
15
|
-
when?: false | 'beforeChildren' | 'afterChildren' | string;
|
|
16
|
-
delayChildren?: number;
|
|
17
|
-
staggerChildren?: number;
|
|
18
|
-
staggerDirection?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface AnimateOptions extends Omit<Orchestration, 'delay'>, AnimationOptions {
|
|
21
|
-
}
|
|
22
14
|
export type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition | string;
|
|
23
15
|
export interface Variant extends DOMKeyframesDefinition {
|
|
24
|
-
transition?:
|
|
16
|
+
transition?: $Transition;
|
|
25
17
|
}
|
|
26
18
|
export type VariantLabels = string | Variant;
|
|
27
19
|
interface BoundingBox {
|
|
@@ -49,12 +41,12 @@ export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps,
|
|
|
49
41
|
};
|
|
50
42
|
style?: MotionStyle;
|
|
51
43
|
transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
|
|
52
|
-
transition?:
|
|
53
|
-
layout?:
|
|
44
|
+
transition?: $Transition & {
|
|
45
|
+
layout?: $Transition;
|
|
54
46
|
};
|
|
55
47
|
layoutGroup?: LayoutGroupState;
|
|
56
48
|
motionConfig?: MotionConfigState;
|
|
57
|
-
onAnimationComplete?: (definition:
|
|
49
|
+
onAnimationComplete?: (definition: Options['animate']) => void;
|
|
58
50
|
onUpdate?: (latest: ResolvedValues) => void;
|
|
59
51
|
}
|
|
60
52
|
export interface MotionStateContext {
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useDomRef<T extends Element = any>(): Ref<T>;
|
|
1
|
+
export declare function useDomRef<T extends Element = any>(): import('vue').Ref<import('vue').UnwrapRef<T>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { Options } from '../types/state';
|
|
3
|
-
export declare function useInView<T extends Element = any>(domRef: Ref<T>, options?: Options['inViewOptions'] | Ref<Options['inViewOptions']>): Ref<boolean
|
|
3
|
+
export declare function useInView<T extends Element = any>(domRef: Ref<T>, options?: Options['inViewOptions'] | Ref<Options['inViewOptions']>): Ref<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-v",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
66
66
|
"@vitest/coverage-v8": "^1.4.0",
|
|
67
67
|
"@vue/test-utils": "^2.4.5",
|
|
68
|
-
"framer-motion": "^11.15.0",
|
|
69
68
|
"happy-dom": "^16.0.1",
|
|
70
69
|
"jsdom": "^24.0.0",
|
|
71
70
|
"vite": "^5.4.8",
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { style } from "./style.mjs";
|
|
2
|
-
import { transformResetValue } from "./transform.mjs";
|
|
3
|
-
import { resolveVariant, hasChanged, getOptions } from "./utils.mjs";
|
|
4
|
-
import { animate } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/animation/animate/index.mjs";
|
|
5
|
-
function animateVariantsChildren(state, activeState, isFirstAnimate = false) {
|
|
6
|
-
const variantChildren = state.visualElement.variantChildren;
|
|
7
|
-
if (!(variantChildren == null ? void 0 : variantChildren.size)) {
|
|
8
|
-
return {
|
|
9
|
-
animations: [],
|
|
10
|
-
getAnimations: () => Promise.resolve()
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const animationFactories = [];
|
|
14
|
-
Array.from(variantChildren).forEach((child, index) => {
|
|
15
|
-
var _a;
|
|
16
|
-
const prevTarget = isFirstAnimate ? child.state.baseTarget : child.state.target;
|
|
17
|
-
const childState = child.state;
|
|
18
|
-
childState.target = {};
|
|
19
|
-
for (const name in activeState) {
|
|
20
|
-
if (name === "initial" && !isFirstAnimate) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const { definition, transition } = activeState[name];
|
|
24
|
-
const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
|
|
25
|
-
const maxStaggerDuration = (variantChildren.size - 1) * staggerChildren;
|
|
26
|
-
const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
27
|
-
const variant = resolveVariant(
|
|
28
|
-
definition,
|
|
29
|
-
child.props.variants,
|
|
30
|
-
child.props.custom
|
|
31
|
-
);
|
|
32
|
-
const animationOptions = {};
|
|
33
|
-
const allTarget = { ...prevTarget, ...variant };
|
|
34
|
-
for (const key in allTarget) {
|
|
35
|
-
if (key === "transition")
|
|
36
|
-
continue;
|
|
37
|
-
childState.target[key] = allTarget[key];
|
|
38
|
-
if (childState.target[key] === void 0) {
|
|
39
|
-
childState.target[key] = childState.baseTarget[key];
|
|
40
|
-
}
|
|
41
|
-
if (hasChanged(prevTarget[key], childState.target[key])) {
|
|
42
|
-
(_a = childState.baseTarget)[key] ?? (_a[key] = style.get(child.current, key));
|
|
43
|
-
animationOptions[key] = getOptions(
|
|
44
|
-
Object.assign({}, transition, allTarget.transition, child.props.transition),
|
|
45
|
-
key
|
|
46
|
-
);
|
|
47
|
-
const keyValue = childState.target[key] === "none" ? transformResetValue[key] : childState.target[key];
|
|
48
|
-
animationFactories.push(
|
|
49
|
-
() => {
|
|
50
|
-
var _a2;
|
|
51
|
-
return animate(
|
|
52
|
-
child.current,
|
|
53
|
-
{
|
|
54
|
-
[key]: keyValue
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
...animationOptions[key] || {},
|
|
58
|
-
delay: (((_a2 = animationOptions[key]) == null ? void 0 : _a2.delay) || 0) + delayChildren + generateStaggerDuration(index)
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
animations: animationFactories,
|
|
69
|
-
getAnimations: () => Promise.all(animationFactories.map((factory) => factory()))
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
animateVariantsChildren
|
|
74
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|