motion-v 0.6.2 → 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.
Files changed (38) hide show
  1. package/dist/cjs/index.js +201 -160
  2. package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +5 -1
  3. package/dist/es/components/animate-presence/utils.mjs +10 -0
  4. package/dist/es/components/{Motion.vue.mjs → motion/Motion.vue.mjs} +7 -7
  5. package/dist/es/components/motion/NameSpace.mjs +47 -0
  6. package/dist/es/constants/index.mjs +3 -1
  7. package/dist/es/features/gestures/drag/use-drag-controls.mjs +43 -0
  8. package/dist/es/features/gestures/in-view/index.mjs +25 -5
  9. package/dist/es/features/layout/projection.mjs +7 -30
  10. package/dist/es/index.mjs +8 -4
  11. package/dist/es/state/motion-state.mjs +70 -54
  12. package/dist/es/state/transform.mjs +1 -0
  13. package/dist/src/components/animate-presence/utils.d.ts +1 -0
  14. package/dist/src/components/index.d.ts +1 -0
  15. package/dist/src/components/{Motion.d.ts → motion/Motion.d.ts} +1 -1
  16. package/dist/src/components/motion/NameSpace.d.ts +11 -0
  17. package/dist/src/components/motion/index.d.ts +2 -0
  18. package/dist/src/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
  19. package/dist/src/features/gestures/in-view/index.d.ts +2 -0
  20. package/dist/src/features/layout/projection.d.ts +1 -0
  21. package/dist/src/index.d.ts +1 -1
  22. package/dist/src/state/animate-variants-children.d.ts +2 -2
  23. package/dist/src/state/motion-state.d.ts +4 -1
  24. package/dist/src/state/utils.d.ts +3 -3
  25. package/dist/src/types/framer-motion.d.ts +17 -0
  26. package/dist/src/types/state.d.ts +6 -14
  27. package/package.json +1 -2
  28. package/dist/es/external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs +0 -6
  29. package/dist/es/state/animate-variants-children.mjs +0 -74
  30. /package/dist/es/components/{Motion.vue2.mjs → motion/Motion.vue2.mjs} +0 -0
  31. /package/dist/es/components/{Primitive.mjs → motion/Primitive.mjs} +0 -0
  32. /package/dist/es/components/{Slot.mjs → motion/Slot.mjs} +0 -0
  33. /package/dist/es/components/{renderSlotFragments.mjs → motion/renderSlotFragments.mjs} +0 -0
  34. /package/dist/es/components/{utils.mjs → motion/utils.mjs} +0 -0
  35. /package/dist/src/components/{Primitive.d.ts → motion/Primitive.d.ts} +0 -0
  36. /package/dist/src/components/{Slot.d.ts → motion/Slot.d.ts} +0 -0
  37. /package/dist/src/components/{renderSlotFragments.d.ts → motion/renderSlotFragments.d.ts} +0 -0
  38. /package/dist/src/components/{utils.d.ts → motion/utils.d.ts} +0 -0
@@ -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 { AnimationOptions, DOMKeyframesDefinition, ResolvedValues, Target, TargetAndTransition } from 'framer-motion';
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?: AnimateOptions;
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?: AnimateOptions & {
53
- layout?: AnimationOptions;
44
+ transition?: $Transition & {
45
+ layout?: $Transition;
54
46
  };
55
47
  layoutGroup?: LayoutGroupState;
56
48
  motionConfig?: MotionConfigState;
57
- onAnimationComplete?: (definition: AnimateOptions) => void;
49
+ onAnimationComplete?: (definition: Options['animate']) => void;
58
50
  onUpdate?: (latest: ResolvedValues) => void;
59
51
  }
60
52
  export interface MotionStateContext {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.6.2",
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,6 +0,0 @@
1
- import "vue";
2
- typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
3
- const isDef = (val) => typeof val !== "undefined";
4
- export {
5
- isDef
6
- };
@@ -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
- };