motion-v 0.5.2-beta.1 → 0.6.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 +205 -147
- package/dist/es/components/LayoutGroup.vue.mjs +1 -3
- package/dist/es/components/Motion.vue.mjs +35 -30
- package/dist/es/components/{AnimatePresence.vue.mjs → animate-presence/AnimatePresence.vue.mjs} +37 -14
- package/dist/es/components/{use-pop-layout.mjs → animate-presence/use-pop-layout.mjs} +1 -1
- package/dist/es/components/group.mjs +5 -2
- package/dist/es/components/presence.mjs +0 -2
- package/dist/es/components/utils.mjs +7 -0
- package/dist/es/constants/index.mjs +2 -1
- package/dist/es/features/layout/layout.mjs +17 -8
- package/dist/es/features/layout/projection.mjs +17 -1
- package/dist/es/index.mjs +4 -4
- package/dist/es/state/animate-variants-children.mjs +5 -3
- package/dist/es/state/motion-state.mjs +49 -22
- package/dist/es/state/schedule.mjs +2 -26
- package/dist/es/state/utils.mjs +0 -9
- package/dist/src/components/{AnimatePresence.d.ts → animate-presence/AnimatePresence.d.ts} +1 -1
- package/dist/src/components/animate-presence/index.d.ts +2 -0
- package/dist/src/components/{type.d.ts → animate-presence/types.d.ts} +2 -0
- package/dist/src/components/{use-pop-layout.d.ts → animate-presence/use-pop-layout.d.ts} +2 -2
- package/dist/src/components/animate-presence/use-presence.d.ts +2 -0
- package/dist/src/components/context.d.ts +1 -0
- package/dist/src/components/group.d.ts +1 -0
- package/dist/src/components/hooks/use-motion-elm.d.ts +13 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/presence.d.ts +3 -5
- package/dist/src/components/utils.d.ts +7 -0
- package/dist/src/index.d.ts +1 -3
- package/dist/src/state/animate-variants-children.d.ts +1 -1
- package/dist/src/state/event.d.ts +1 -1
- package/dist/src/state/motion-state.d.ts +10 -7
- package/dist/src/types/state.d.ts +6 -2
- package/package.json +3 -2
- /package/dist/es/components/{AnimatePresence.vue2.mjs → animate-presence/AnimatePresence.vue2.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnimatePresenceProps } from './
|
|
2
|
-
import { MotionState } from '
|
|
1
|
+
import { AnimatePresenceProps } from './types';
|
|
2
|
+
import { MotionState } from '../../state';
|
|
3
3
|
export declare function usePopLayout(props: AnimatePresenceProps): {
|
|
4
4
|
addPopStyle: (state: MotionState) => void;
|
|
5
5
|
removePopStyle: (state: MotionState) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the actual motion element, skipping text and comment nodes
|
|
3
|
+
* @param el - The HTML element to check
|
|
4
|
+
* @returns The first non-text/comment element
|
|
5
|
+
*/
|
|
6
|
+
export declare function getMotionElement(el: HTMLElement): HTMLElement;
|
|
7
|
+
/**
|
|
8
|
+
* Hook to get the motion element of current component instance
|
|
9
|
+
* @returns Function that returns the motion element
|
|
10
|
+
*/
|
|
11
|
+
export declare function useMotionElm(): {
|
|
12
|
+
value: HTMLElement | null;
|
|
13
|
+
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const doneCallbacks: WeakMap<Element, VoidFunction>;
|
|
3
|
-
export declare const unPresenceDom: Ref<WeakMap<Element, boolean> & Omit<WeakMap<Element, boolean>, keyof WeakMap<any, any>>>;
|
|
1
|
+
export declare const doneCallbacks: WeakMap<Element, (v?: any, safeUnmount?: boolean) => void>;
|
|
4
2
|
export declare function removeDoneCallback(element: Element): void;
|
|
5
3
|
export interface PresenceContext {
|
|
6
|
-
initial
|
|
7
|
-
|
|
4
|
+
initial?: boolean;
|
|
5
|
+
custom?: any;
|
|
8
6
|
}
|
|
9
7
|
export declare const injectAnimatePresence: <T extends PresenceContext = PresenceContext>(fallback?: T) => T extends null ? PresenceContext : PresenceContext, provideAnimatePresence: (contextValue: PresenceContext) => PresenceContext;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import { ComponentPublicInstance } from 'vue';
|
|
1
2
|
export declare function getMotionElement(el: HTMLElement): HTMLElement;
|
|
3
|
+
/**
|
|
4
|
+
* 检查是否是隐藏的 motion 元素
|
|
5
|
+
* @param instance
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function checkMotionIsHidden(instance: ComponentPublicInstance): boolean;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
export * from 'framer-motion/dom';
|
|
2
2
|
export { motionValue as useMotionValue } from 'framer-motion/dom';
|
|
3
3
|
export { default as Motion, type MotionProps } from './components/Motion';
|
|
4
|
-
export
|
|
5
|
-
export type { AnimatePresenceProps } from './components/type';
|
|
4
|
+
export * from './components';
|
|
6
5
|
export { default as LayoutGroup } from './components/LayoutGroup';
|
|
7
6
|
export { useLayoutGroup } from './components/use-layout-group';
|
|
8
7
|
export type { LayoutGroupProps } from './components/use-layout-group';
|
|
9
|
-
export * from './components/motion-config';
|
|
10
8
|
export * from './components/context';
|
|
11
9
|
export * from './value';
|
|
12
10
|
export * from './constants';
|
|
@@ -6,7 +6,7 @@ export type ActiveVariant = {
|
|
|
6
6
|
transition: AnimateOptions;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
export declare function animateVariantsChildren(state: MotionState, activeState: ActiveVariant): {
|
|
9
|
+
export declare function animateVariantsChildren(state: MotionState, activeState: ActiveVariant, isFirstAnimate?: boolean): {
|
|
10
10
|
animations: any[];
|
|
11
11
|
getAnimations: () => Promise<void>;
|
|
12
12
|
} | {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Variant } from '../types';
|
|
2
|
-
export type MotionEventNames = 'motionstart' | 'motioncomplete'
|
|
2
|
+
export type MotionEventNames = 'motionstart' | 'motioncomplete';
|
|
3
3
|
export declare function motionEvent(name: MotionEventNames, target: Variant, isExit?: boolean): CustomEvent<{
|
|
4
4
|
target: Variant;
|
|
5
5
|
isExit: boolean;
|
|
@@ -2,13 +2,15 @@ import { MotionStateContext, Options } from '../types';
|
|
|
2
2
|
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
|
-
export declare const mountedStates:
|
|
5
|
+
export declare const mountedStates: Map<string | Element, MotionState>;
|
|
6
6
|
export declare class MotionState {
|
|
7
7
|
readonly id: string;
|
|
8
8
|
element: HTMLElement | null;
|
|
9
9
|
private parent?;
|
|
10
10
|
options: Options;
|
|
11
|
-
|
|
11
|
+
isSafeToRemove: boolean;
|
|
12
|
+
isFirstAnimate: boolean;
|
|
13
|
+
private children?;
|
|
12
14
|
activeStates: Partial<Record<StateType, boolean>>;
|
|
13
15
|
depth: number;
|
|
14
16
|
baseTarget: DOMKeyframesDefinition;
|
|
@@ -22,14 +24,15 @@ export declare class MotionState {
|
|
|
22
24
|
get initial(): string | boolean | import('../types').Variant;
|
|
23
25
|
updateOptions(): void;
|
|
24
26
|
beforeMount(): void;
|
|
25
|
-
mount(element: HTMLElement, options: Options): void;
|
|
27
|
+
mount(element: HTMLElement, options: Options, notAnimate?: boolean): void;
|
|
26
28
|
beforeUnmount(): void;
|
|
27
|
-
unmount(): void;
|
|
29
|
+
unmount(unMountChildren?: boolean): void;
|
|
28
30
|
beforeUpdate(): void;
|
|
29
|
-
update(options: Options): void;
|
|
30
|
-
setActive(name: StateType, isActive: boolean): void;
|
|
31
|
-
animateUpdates():
|
|
31
|
+
update(options: Options, notAnimate?: boolean): void;
|
|
32
|
+
setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
|
|
33
|
+
animateUpdates(isInitial?: boolean): void;
|
|
32
34
|
isMounted(): boolean;
|
|
33
35
|
getOptions(): Options<any>;
|
|
36
|
+
willUpdate(label: string): void;
|
|
34
37
|
}
|
|
35
38
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DOMKeyframesDefinition, DynamicAnimationOptions, Target, TargetAndTransition } from 'framer-motion';
|
|
1
|
+
import { DOMKeyframesDefinition, DynamicAnimationOptions, ResolvedValues, Target, TargetAndTransition } from 'framer-motion';
|
|
2
2
|
import { MotionValue, animate } from 'framer-motion/dom';
|
|
3
3
|
import { IntrinsicElementAttributes } from 'vue';
|
|
4
4
|
import { TransformProperties } from './transform';
|
|
@@ -50,9 +50,13 @@ export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps,
|
|
|
50
50
|
};
|
|
51
51
|
style?: MotionStyle;
|
|
52
52
|
transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
|
|
53
|
-
transition?: AnimateOptions
|
|
53
|
+
transition?: AnimateOptions & {
|
|
54
|
+
layout?: DynamicAnimationOptions;
|
|
55
|
+
};
|
|
54
56
|
layoutGroup?: LayoutGroupState;
|
|
55
57
|
motionConfig?: MotionConfigState;
|
|
58
|
+
onAnimationComplete?: (definition: AnimateOptions) => void;
|
|
59
|
+
onUpdate?: (latest: ResolvedValues) => void;
|
|
56
60
|
}
|
|
57
61
|
export interface MotionStateContext {
|
|
58
62
|
initial?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-v",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@vitest/coverage-v8": "^1.4.0",
|
|
64
64
|
"@vue/test-utils": "^2.4.5",
|
|
65
65
|
"framer-motion": "^11.15.0",
|
|
66
|
+
"happy-dom": "^16.0.1",
|
|
66
67
|
"jsdom": "^24.0.0",
|
|
67
68
|
"vite": "^5.4.8",
|
|
68
69
|
"vite-plugin-dts": "^4.2.4",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"scripts": {
|
|
72
73
|
"dev": "vite build --watch",
|
|
73
74
|
"build": "rm -rf dist && vite build",
|
|
74
|
-
"test": "vitest",
|
|
75
|
+
"test": "vitest --dom",
|
|
75
76
|
"coverage": "vitest run --coverage",
|
|
76
77
|
"pub:release": "pnpm publish --access public"
|
|
77
78
|
}
|
/package/dist/es/components/{AnimatePresence.vue2.mjs → animate-presence/AnimatePresence.vue2.mjs}
RENAMED
|
File without changes
|