motion-v 0.1.0 → 0.2.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.
Files changed (41) hide show
  1. package/dist/index.cjs +1 -0
  2. package/dist/index.js +1281 -1097
  3. package/dist/src/components/Motion.d.ts +2 -7
  4. package/dist/src/components/type.d.ts +25 -0
  5. package/dist/src/{state/features → features}/feature.d.ts +1 -1
  6. package/dist/src/{state/features → features}/gestures/base.d.ts +2 -2
  7. package/dist/src/features/gestures/drag/index.d.ts +12 -0
  8. package/dist/src/features/gestures/drag/types.d.ts +144 -0
  9. package/dist/src/{state/features → features}/gestures/hover.d.ts +2 -2
  10. package/dist/src/{state/features → features}/gestures/in-view.d.ts +2 -2
  11. package/dist/src/{state/features → features}/gestures/index.d.ts +1 -0
  12. package/dist/src/{state/features → features}/gestures/press.d.ts +2 -2
  13. package/dist/src/features/gestures/types.d.ts +29 -0
  14. package/dist/src/index.d.ts +2 -0
  15. package/dist/src/state/motion-state.d.ts +4 -3
  16. package/dist/src/state/style.d.ts +2 -1
  17. package/dist/src/state/types.d.ts +22 -3
  18. package/dist/src/state/utils.d.ts +9 -6
  19. package/dist/src/types/framer-motion.d.ts +104 -0
  20. package/dist/src/types/index.d.ts +3 -14
  21. package/dist/src/types/transform.d.ts +47 -0
  22. package/dist/src/utils/events.d.ts +1 -1
  23. package/dist/src/utils/index.d.ts +1 -0
  24. package/dist/src/utils/motion-value.d.ts +2 -0
  25. package/dist/src/utils/use-animation-frame.d.ts +2 -0
  26. package/dist/src/value/index.d.ts +5 -0
  27. package/dist/src/value/use-combine-values.d.ts +6 -0
  28. package/dist/src/value/use-computed.d.ts +2 -0
  29. package/dist/src/value/use-motion-template.d.ts +21 -0
  30. package/dist/src/value/use-motion-value-event.d.ts +3 -0
  31. package/dist/src/value/use-scroll.d.ts +12 -0
  32. package/dist/src/value/use-spring.d.ts +3 -0
  33. package/dist/src/value/use-time.d.ts +1 -0
  34. package/dist/src/value/use-transform.d.ts +58 -0
  35. package/dist/src/value/use-velocity.d.ts +13 -0
  36. package/package.json +10 -4
  37. package/dist/index.umd.cjs +0 -1
  38. package/dist/src/components/utils.d.ts +0 -3
  39. package/dist/src/state/features/gestures/types.d.ts +0 -9
  40. /package/dist/src/{state/features → features}/events.d.ts +0 -0
  41. /package/dist/src/{state/features → features}/index.d.ts +0 -0
@@ -1,17 +1,12 @@
1
1
  import { Options } from '../state/types';
2
- import { CSSProperties, IntrinsicElementAttributes } from 'vue';
2
+ import { IntrinsicElementAttributes } from 'vue';
3
3
  export interface MotionProps<T extends ElementType = 'div'> extends Options {
4
4
  as?: T;
5
5
  asChild?: boolean;
6
- style?: CSSProperties;
7
- hover?: Options['hover'];
8
- press?: Options['press'];
9
- inView?: Options['inView'];
10
- inViewOptions?: Options['inViewOptions'];
11
6
  }
12
7
  type ElementType = keyof IntrinsicElementAttributes;
13
8
  declare const _default: <T extends ElementType = "div">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
14
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{}>>, never>, never> & (MotionProps<T> & Omit<IntrinsicElementAttributes[T], "asChild" | "as" | keyof Options>)> & import('vue').PublicProps;
9
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{}>>, never>, never> & (MotionProps<T> & Omit<IntrinsicElementAttributes[T], "asChild" | keyof Options>)> & import('vue').PublicProps;
15
10
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
16
11
  attrs: any;
17
12
  slots: {
@@ -0,0 +1,25 @@
1
+ interface SVGRenderState {
2
+ style: Record<string, any>;
3
+ transform: Record<string, any>;
4
+ transformOrigin: {
5
+ originX?: string | number;
6
+ originY?: string | number;
7
+ originZ?: string | number;
8
+ };
9
+ attrs: Record<string, any>;
10
+ dimensions?: {
11
+ x: number;
12
+ y: number;
13
+ width: number;
14
+ height: number;
15
+ };
16
+ }
17
+ interface SVGProps {
18
+ attrX?: number;
19
+ attrY?: number;
20
+ attrScale?: number;
21
+ pathLength?: number;
22
+ pathSpacing?: number;
23
+ pathOffset?: number;
24
+ [key: string]: any;
25
+ }
@@ -1,4 +1,4 @@
1
- import { MotionState } from '../motion-state';
1
+ import { MotionState } from '../state/motion-state';
2
2
  export declare abstract class Feature {
3
3
  state: MotionState;
4
4
  constructor(state: MotionState);
@@ -1,5 +1,5 @@
1
1
  import { Feature } from '../feature';
2
- import { MotionEventNames } from '../../../types';
2
+ import { MotionEventNames } from '../../types';
3
3
  export declare abstract class BaseGesture extends Feature {
4
4
  abstract isActive(): boolean;
5
5
  removeGestureSubscriptions?: VoidFunction;
@@ -7,4 +7,4 @@ export declare abstract class BaseGesture extends Feature {
7
7
  protected updateGestureSubscriptions(): void;
8
8
  unmount(): void;
9
9
  }
10
- export declare function createGestureEvent(element: Element, name: MotionEventNames, action: VoidFunction): (event: PointerEvent) => void;
10
+ export declare function createGestureEvent(element: HTMLElement, name: MotionEventNames, action: VoidFunction): (event: PointerEvent) => void;
@@ -0,0 +1,12 @@
1
+ import { MotionState } from '../../../state/motion-state';
2
+ import { BaseGesture } from '..';
3
+ export declare class DragGesture extends BaseGesture {
4
+ private isDragging;
5
+ private currentPosition;
6
+ private startPosition;
7
+ private constraints?;
8
+ isActive(): boolean;
9
+ constructor(state: MotionState);
10
+ mount(): void;
11
+ update(): void;
12
+ }
@@ -0,0 +1,144 @@
1
+ import { VariantLabels } from '../../../state/types';
2
+ export interface BoundingBox {
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ left: number;
7
+ }
8
+ type DragElastic = boolean | number | Partial<BoundingBox>;
9
+ export interface DragOptions {
10
+ /**
11
+ * Enable dragging for this element. Set to `false` by default.
12
+ * Set `true` to drag in both directions.
13
+ * Set `"x"` or `"y"` to only drag in a specific direction.
14
+ *
15
+ * ```template
16
+ * <Motion drag="x" />
17
+ * ```
18
+ */
19
+ drag?: boolean | 'x' | 'y';
20
+ /**
21
+ * If `true`, the drag direction will be locked to the initial drag direction.
22
+ * Set to `false` by default.
23
+ *
24
+ * ```template
25
+ * <Motion dragOptions="{ directionLock: true, drag: 'x' }" />
26
+ * ```
27
+ */
28
+ directionLock?: boolean;
29
+ /**
30
+ * Allows drag gesture propagation to child components. Set to `false` by
31
+ * default.
32
+ *
33
+ * ```template
34
+ * <Motion dragOptions="{ propagation: true, drag: 'x' }" />
35
+ * ```
36
+ */
37
+ propagation?: boolean;
38
+ /**
39
+ * Applies constraints on the permitted draggable area.
40
+ *
41
+ * It can accept an object of optional `top`, `left`, `right`, and `bottom` values, measured in pixels.
42
+ * This will define a distance the named edge of the draggable component.
43
+ *
44
+ * Alternatively, it can accept a `ref` to another component created with React's `useRef` hook.
45
+ * This `ref` should be passed both to the draggable component's `dragConstraints` prop, and the `ref`
46
+ * of the component you want to use as constraints.
47
+ *
48
+ * ```template
49
+ * // In pixels
50
+ * <Motion dragOptions="{ constraints: { left: 0, right: 300 }, drag: 'x' }" />
51
+ *
52
+ * // As a ref to another component
53
+ * const MyComponent = () => {
54
+ * const constraintsRef = ref()
55
+ *
56
+ * return (
57
+ * <div ref={constraintsRef}>
58
+ * <Motion dragOptions="{ constraints: constraintsRef, drag: 'x' }" />
59
+ * </div>
60
+ * )
61
+ * }
62
+ * ```
63
+ */
64
+ constraints?: false | Partial<BoundingBox> | HTMLElement;
65
+ /**
66
+ * The degree of movement allowed outside constraints. 0 = no movement, 1 =
67
+ * full movement.
68
+ *
69
+ * Set to `0.5` by default. Can also be set as `false` to disable movement.
70
+ *
71
+ * By passing an object of `top`/`right`/`bottom`/`left`, individual values can be set
72
+ * per constraint. Any missing values will be set to `0`.
73
+ *
74
+ * ```template
75
+ * <Motion dragOptions="{ dragElastic: 0.2, constraints: { left: 0, right: 300 }, drag: 'x' }" />
76
+ * ```
77
+ */
78
+ elastic?: DragElastic;
79
+ /**
80
+ * Apply momentum from the pan gesture to the component when dragging
81
+ * finishes. Set to `true` by default.
82
+ *
83
+ * ```template
84
+ * <Motion dragOptions="{ dragMomentum: false, constraints: { left: 0, right: 300 }, drag: 'x' }" />
85
+ * ```
86
+ */
87
+ momentum?: boolean;
88
+ /**
89
+ * Allows you to change dragging inertia parameters.
90
+ * When releasing a draggable Frame, an animation with type `inertia` starts. The animation is based on your dragging velocity. This property allows you to customize it.
91
+ *
92
+ * ```jsx
93
+ * <motion.div
94
+ * drag
95
+ * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
96
+ * />
97
+ * ```
98
+ */
99
+ /**
100
+ * Usually, dragging is initiated by pressing down on a component and moving it. For some
101
+ * use-cases, for instance clicking at an arbitrary point on a video scrubber, we
102
+ * might want to initiate dragging from a different component than the draggable one.
103
+ *
104
+ * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
105
+ * the draggable component's `dragControls` prop. It exposes a `start` method
106
+ * that can start dragging from pointer events on other components.
107
+ *
108
+ * ```jsx
109
+ * const dragControls = useDragControls()
110
+ *
111
+ * function startDrag(event) {
112
+ * dragControls.start(event, { snapToCursor: true })
113
+ * }
114
+ *
115
+ * return (
116
+ * <>
117
+ * <div onPointerDown={startDrag} />
118
+ * <motion.div drag="x" dragControls={dragControls} />
119
+ * </>
120
+ * )
121
+ * ```
122
+ */
123
+ /**
124
+ * If true, element will snap back to its origin when dragging ends.
125
+ *
126
+ * Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
127
+ * with `dragElastic={1}`, but when used together `dragConstraints` can define
128
+ * a wider draggable area and `dragSnapToOrigin` will ensure the element
129
+ * animates back to its origin on release.
130
+ */
131
+ snapToOrigin?: boolean;
132
+ }
133
+ export interface DragProps {
134
+ /**
135
+ * Properties or variant label to animate to while the drag gesture is recognised.
136
+ *
137
+ * ```jsx
138
+ * <motion.div whileDrag={{ scale: 1.2 }} />
139
+ * ```
140
+ */
141
+ drag?: VariantLabels;
142
+ dragOptions?: DragOptions;
143
+ }
144
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { Gesture } from './types';
2
- import { MotionState } from '../../motion-state';
3
- import { BaseGesture } from '.';
2
+ import { MotionState } from '../../state/motion-state';
3
+ import { BaseGesture } from '..';
4
4
  export declare const hover: Gesture;
5
5
  export declare class HoverGesture extends BaseGesture {
6
6
  isActive(): boolean;
@@ -1,5 +1,5 @@
1
- import { MotionState } from '../../motion-state';
2
- import { BaseGesture } from '.';
1
+ import { MotionState } from '../../state/motion-state';
2
+ import { BaseGesture } from '..';
3
3
  export declare class InViewGesture extends BaseGesture {
4
4
  isActive(): boolean;
5
5
  constructor(state: MotionState);
@@ -2,3 +2,4 @@ export * from './base';
2
2
  export * from './hover';
3
3
  export * from './press';
4
4
  export * from './in-view';
5
+ export * from './drag';
@@ -1,5 +1,5 @@
1
- import { MotionState } from '../../motion-state';
2
- import { BaseGesture } from '.';
1
+ import { MotionState } from '../../state/motion-state';
2
+ import { BaseGesture } from '..';
3
3
  export declare class PressGesture extends BaseGesture {
4
4
  isActive(): boolean;
5
5
  constructor(state: MotionState);
@@ -0,0 +1,29 @@
1
+ import { Options } from '../../state/types';
2
+ export interface StateHandlers {
3
+ enable: VoidFunction;
4
+ disable: VoidFunction;
5
+ }
6
+ export interface Gesture {
7
+ isActive: (options: Options) => void;
8
+ subscribe: (element: HTMLElement, stateHandlers: StateHandlers, options: Options) => () => void;
9
+ }
10
+ export interface DragOptions {
11
+ constraints?: {
12
+ top?: number;
13
+ right?: number;
14
+ bottom?: number;
15
+ left?: number;
16
+ };
17
+ dragSnapToOrigin?: boolean;
18
+ dragElastic?: number;
19
+ dragMomentum?: boolean;
20
+ dragTransition?: {
21
+ power?: number;
22
+ timeConstant?: number;
23
+ };
24
+ }
25
+ export interface DragHandlers {
26
+ onDragStart?: (event: PointerEvent) => void;
27
+ onDrag?: (event: PointerEvent) => void;
28
+ onDragEnd?: (event: PointerEvent) => void;
29
+ }
@@ -1,3 +1,5 @@
1
1
  export * from 'framer-motion/dom';
2
+ export { motionValue as useMotionValue } from 'framer-motion/dom';
2
3
  export { default as Motion, type MotionProps } from './components/Motion';
3
4
  export { default as AnimatePresence, type AnimatePresenceProps } from './components/AnimatePresence';
5
+ export * from './value';
@@ -1,6 +1,6 @@
1
1
  import { Options } from './types';
2
2
  import { DOMKeyframesDefinition } from 'framer-motion';
3
- declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "exit"];
3
+ declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "exit", "drag"];
4
4
  type StateType = typeof STATE_TYPES[number];
5
5
  export declare const mountedStates: WeakMap<Element, MotionState>;
6
6
  export declare class MotionState {
@@ -13,11 +13,12 @@ export declare class MotionState {
13
13
  private baseTarget;
14
14
  private target;
15
15
  private featureManager;
16
+ private visualElement;
16
17
  constructor(options: Options, parent?: MotionState);
17
18
  private initContext;
18
19
  private initTarget;
19
20
  get initial(): string | boolean | import('./types').Variant;
20
- mount(element: Element): void;
21
+ mount(element: HTMLElement): void;
21
22
  unmount(): void;
22
23
  update(options: Options): void;
23
24
  setActive(name: StateType, isActive: boolean): void;
@@ -25,7 +26,7 @@ export declare class MotionState {
25
26
  isMounted(): boolean;
26
27
  getDepth(): number;
27
28
  getOptions(): Options;
28
- getElement(): Element;
29
+ getElement(): HTMLElement;
29
30
  getTarget(): DOMKeyframesDefinition;
30
31
  }
31
32
  export {};
@@ -1,6 +1,7 @@
1
1
  import { DOMKeyframesDefinition } from 'framer-motion';
2
+ import { MotionStyle } from './types';
2
3
  export declare const style: {
3
4
  get: (element: Element, name: string) => string | undefined;
4
5
  set: (element: Element, name: string, value: string | number) => void;
5
6
  };
6
- export declare function createStyles(keyframes?: DOMKeyframesDefinition): any;
7
+ export declare function createStyles(keyframes?: MotionStyle | DOMKeyframesDefinition): any;
@@ -1,10 +1,13 @@
1
+ import { TransformProperties } from '../types';
1
2
  import { DOMKeyframesDefinition, DynamicAnimationOptions } from 'framer-motion';
2
- import { animate } from 'framer-motion/dom';
3
- import { CSSProperties } from 'vue';
3
+ import { MotionValue } from 'framer-motion/dom';
4
+ import { animate } from '../../node_modules/framer-motion/dist/es/animation/animate/index.mjs';
5
+ import { IntrinsicElementAttributes } from 'vue';
4
6
  type AnimationPlaybackControls = ReturnType<typeof animate>;
5
7
  export interface Variant extends DOMKeyframesDefinition {
6
8
  transition?: DynamicAnimationOptions;
7
9
  }
10
+ export type VariantLabels = string | Variant;
8
11
  type MarginValue = `${number}${'px' | '%'}`;
9
12
  type MarginType = MarginValue | `${MarginValue} ${MarginValue}` | `${MarginValue} ${MarginValue} ${MarginValue}` | `${MarginValue} ${MarginValue} ${MarginValue} ${MarginValue}`;
10
13
  export interface InViewOptions {
@@ -12,7 +15,22 @@ export interface InViewOptions {
12
15
  margin?: MarginType;
13
16
  amount?: 'some' | 'all' | number;
14
17
  }
18
+ interface BoundingBox {
19
+ top: number;
20
+ right: number;
21
+ bottom: number;
22
+ left: number;
23
+ }
24
+ export interface DragOptions {
25
+ constraints?: false | Partial<BoundingBox>;
26
+ dragSnapToOrigin?: boolean;
27
+ }
28
+ export type MotionStyle = Partial<{
29
+ [K in keyof Variant]: Variant[K] | MotionValue;
30
+ }>;
31
+ export type ElementType = keyof IntrinsicElementAttributes;
15
32
  export interface Options {
33
+ as?: ElementType;
16
34
  inViewOptions?: InViewOptions & {
17
35
  once?: boolean;
18
36
  };
@@ -25,8 +43,9 @@ export interface Options {
25
43
  variants?: {
26
44
  [k: string]: Variant;
27
45
  };
46
+ style?: MotionStyle;
47
+ transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
28
48
  transition?: DynamicAnimationOptions;
29
- style?: CSSProperties;
30
49
  onMotionStart?: (target: DOMKeyframesDefinition) => void;
31
50
  onMotionComplete?: (target: DOMKeyframesDefinition) => void;
32
51
  onHoverStart?: (e: PointerEvent) => void;
@@ -1,7 +1,7 @@
1
- import { AnimateOptions } from '../types';
1
+ import { Options } from './types';
2
2
  import { DynamicAnimationOptions, Variant } from 'framer-motion';
3
- import { VNode } from 'vue';
4
- export declare function resolveVariant(definition?: AnimateOptions['initial'], variants?: AnimateOptions['variants']): Variant | undefined;
3
+ import { IntrinsicElementAttributes } from 'vue';
4
+ export declare function resolveVariant(definition?: Options['initial'], variants?: Options['variants']): 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;
@@ -11,6 +11,9 @@ export declare function isCssVar(name: string): boolean;
11
11
  export declare function noop(): void;
12
12
  export declare const noopReturn: <V>(v: V) => V;
13
13
  export declare function isNumber(value: any): boolean;
14
- export declare function isElement(vNode: VNode): boolean;
15
- export declare function getChildKey(vNode: VNode): PropertyKey;
16
- export declare function setStaticValue(): void;
14
+ type ElementType = keyof IntrinsicElementAttributes;
15
+ export declare const svgElements: readonly ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"];
16
+ type UnionStringArray<T extends Readonly<string[]>> = T[number];
17
+ export type SVGElements = UnionStringArray<typeof svgElements>;
18
+ export declare function isSVGElement(as: ElementType): as is SVGElements;
19
+ export {};
@@ -0,0 +1,104 @@
1
+ import { EasingFunction, ResolvedValues } from 'framer-motion';
2
+ export interface FrameData {
3
+ delta: number;
4
+ timestamp: number;
5
+ isProcessing: boolean;
6
+ }
7
+ export interface MotionValueEventCallbacks<V> {
8
+ animationStart: () => void;
9
+ animationComplete: () => void;
10
+ animationCancel: () => void;
11
+ change: (latestValue: V) => void;
12
+ renderRequest: () => void;
13
+ }
14
+ export interface ScrollOptions {
15
+ source?: HTMLElement;
16
+ container?: HTMLElement;
17
+ target?: Element;
18
+ axis?: 'x' | 'y';
19
+ offset?: ScrollOffset;
20
+ }
21
+ export type OnScrollProgress = (progress: number) => void;
22
+ export type OnScrollWithInfo = (progress: number, info: ScrollInfo) => void;
23
+ export type OnScroll = OnScrollProgress | OnScrollWithInfo;
24
+ export interface AxisScrollInfo {
25
+ current: number;
26
+ offset: number[];
27
+ progress: number;
28
+ scrollLength: number;
29
+ velocity: number;
30
+ targetOffset: number;
31
+ targetLength: number;
32
+ containerLength: number;
33
+ interpolatorOffsets?: number[];
34
+ interpolate?: EasingFunction;
35
+ }
36
+ export interface ScrollInfo {
37
+ time: number;
38
+ x: AxisScrollInfo;
39
+ y: AxisScrollInfo;
40
+ }
41
+ export type OnScrollInfo = (info: ScrollInfo) => void;
42
+ export type OnScrollHandler = {
43
+ measure: () => void;
44
+ update: (time: number) => void;
45
+ notify: () => void;
46
+ };
47
+ export type SupportedEdgeUnit = 'px' | 'vw' | 'vh' | '%';
48
+ export type EdgeUnit = `${number}${SupportedEdgeUnit}`;
49
+ export type NamedEdges = 'start' | 'end' | 'center';
50
+ export type EdgeString = NamedEdges | EdgeUnit | `${number}`;
51
+ export type Edge = EdgeString | number;
52
+ export type ProgressIntersection = [number, number];
53
+ export type Intersection = `${Edge} ${Edge}`;
54
+ export type ScrollOffset = Array<Edge | Intersection | ProgressIntersection>;
55
+ export interface ScrollInfoOptions {
56
+ container?: HTMLElement;
57
+ target?: Element;
58
+ axis?: 'x' | 'y';
59
+ offset?: ScrollOffset;
60
+ }
61
+ export interface TransformOrigin {
62
+ originX?: number | string;
63
+ originY?: number | string;
64
+ originZ?: number | string;
65
+ }
66
+ export interface HTMLRenderState {
67
+ /**
68
+ * A mutable record of transforms we want to apply directly to the rendered Element
69
+ * every frame. We use a mutable data structure to reduce GC during animations.
70
+ */
71
+ transform: ResolvedValues;
72
+ /**
73
+ * A mutable record of transform origins we want to apply directly to the rendered Element
74
+ * every frame. We use a mutable data structure to reduce GC during animations.
75
+ */
76
+ transformOrigin: TransformOrigin;
77
+ /**
78
+ * A mutable record of styles we want to apply directly to the rendered Element
79
+ * every frame. We use a mutable data structure to reduce GC during animations.
80
+ */
81
+ style: ResolvedValues;
82
+ /**
83
+ * A mutable record of CSS variables we want to apply directly to the rendered Element
84
+ * every frame. We use a mutable data structure to reduce GC during animations.
85
+ */
86
+ vars: ResolvedValues;
87
+ }
88
+ export type SVGDimensions = {
89
+ x: number;
90
+ y: number;
91
+ width: number;
92
+ height: number;
93
+ };
94
+ export interface SVGRenderState extends HTMLRenderState {
95
+ /**
96
+ * Measured dimensions of the SVG element to be used to calculate a transform-origin.
97
+ */
98
+ dimensions?: SVGDimensions;
99
+ /**
100
+ * A mutable record of attributes we want to apply directly to the rendered Element
101
+ * every frame. We use a mutable data structure to reduce GC during animations.
102
+ */
103
+ attrs: ResolvedValues;
104
+ }
@@ -1,14 +1,3 @@
1
- import { DOMKeyframesDefinition, DynamicAnimationOptions } from 'framer-motion';
2
- export interface Variant extends DOMKeyframesDefinition {
3
- transition?: DynamicAnimationOptions;
4
- }
5
- export interface AnimateOptions {
6
- initial?: string | Variant | boolean;
7
- animate?: string | Variant;
8
- exit?: string | Variant;
9
- variants?: {
10
- [k: string]: Variant;
11
- };
12
- transition?: DynamicAnimationOptions;
13
- }
14
- export type MotionEventNames = 'motionstart' | 'motioncomplete' | 'hoverstart' | 'hoverend' | 'pressstart' | 'pressend' | 'viewenter' | 'viewleave';
1
+ export * from './transform';
2
+ export * from './framer-motion';
3
+ export type MotionEventNames = 'motionstart' | 'motioncomplete' | 'hoverstart' | 'hoverend' | 'pressstart' | 'pressend' | 'viewenter' | 'viewleave' | 'dragstart' | 'dragend' | 'dragcancel' | 'dragmove' | 'drag';
@@ -0,0 +1,47 @@
1
+ import { EasingFunction } from 'framer-motion';
2
+ export interface TransformProperties {
3
+ x?: string | number;
4
+ y?: string | number;
5
+ z?: string | number;
6
+ translateX?: string | number;
7
+ translateY?: string | number;
8
+ translateZ?: string | number;
9
+ rotate?: string | number;
10
+ rotateX?: string | number;
11
+ rotateY?: string | number;
12
+ rotateZ?: string | number;
13
+ scale?: string | number;
14
+ scaleX?: string | number;
15
+ scaleY?: string | number;
16
+ scaleZ?: string | number;
17
+ skew?: string | number;
18
+ skewX?: string | number;
19
+ skewY?: string | number;
20
+ originX?: string | number;
21
+ originY?: string | number;
22
+ originZ?: string | number;
23
+ perspective?: string | number;
24
+ transformPerspective?: string | number;
25
+ }
26
+ export interface TransformOptions<T> {
27
+ /**
28
+ * Clamp values to within the given range. Defaults to `true`
29
+ *
30
+ * @public
31
+ */
32
+ clamp?: boolean;
33
+ /**
34
+ * Easing functions to use on the interpolations between each value in the input and output ranges.
35
+ *
36
+ * If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
37
+ *
38
+ * @public
39
+ */
40
+ ease?: EasingFunction | EasingFunction[];
41
+ /**
42
+ * Provide a function that can interpolate between any two values in the provided range.
43
+ *
44
+ * @public
45
+ */
46
+ mixer?: (from: T, to: T) => (v: number) => any;
47
+ }
@@ -1,2 +1,2 @@
1
1
  import { MotionEventNames } from '../types';
2
- export declare function dispatchPointerEvent(element: Element, name: MotionEventNames, event: any): void;
2
+ export declare function dispatchPointerEvent(element: HTMLElement, name: MotionEventNames, event: any): void;
@@ -1 +1,2 @@
1
1
  export * from './createContext';
2
+ export * from './motion-value';
@@ -0,0 +1,2 @@
1
+ import { MotionValue } from 'framer-motion/dom';
2
+ export declare function isMotionValue(value: any): value is MotionValue;
@@ -0,0 +1,2 @@
1
+ export type FrameCallback = (timestamp: number, delta: number) => void;
2
+ export declare function useAnimationFrame(callback: FrameCallback): void;
@@ -0,0 +1,5 @@
1
+ export * from './use-transform';
2
+ export * from './use-time';
3
+ export * from './use-motion-template';
4
+ export * from './use-spring';
5
+ export * from './use-scroll';
@@ -0,0 +1,6 @@
1
+ import { MotionValue } from 'framer-motion/dom';
2
+ export declare function useCombineMotionValues<T>(combineValues: () => T): {
3
+ subscribe: (values: MotionValue[]) => void;
4
+ unsubscribe: () => void;
5
+ value: MotionValue<T>;
6
+ };
@@ -0,0 +1,2 @@
1
+ import { MotionValue } from 'framer-motion/dom';
2
+ export declare function useComputed<T>(computed: () => T): MotionValue<T>;
@@ -0,0 +1,21 @@
1
+ import { MotionValue } from 'framer-motion/dom';
2
+ /**
3
+ * 将多个motion值组合成一个新的motion值,使用模板字符串语法
4
+ *
5
+ * ```vue
6
+ * <script setup>
7
+ * import { useSpring, motionValue, useMotionTemplate } from 'motion-v'
8
+ *
9
+ * const shadowX = useSpring(0)
10
+ * const shadowY = motionValue(0)
11
+ * const shadow = useMotionTemplate`drop-shadow(${shadowX}px ${shadowY}px 20px rgba(0,0,0,0.3))`
12
+ * </script>
13
+ *
14
+ * <template>
15
+ * <Motion :style="{ filter: shadow }" />
16
+ * </template>
17
+ * ```
18
+ *
19
+ * @public
20
+ */
21
+ export declare function useMotionTemplate(fragments: TemplateStringsArray, ...values: Array<MotionValue | number | string>): MotionValue<string>;
@@ -0,0 +1,3 @@
1
+ import { MotionValue } from 'framer-motion/dom';
2
+ import { MotionValueEventCallbacks } from '../types';
3
+ export declare function useMotionValueEvent<V, EventName extends keyof MotionValueEventCallbacks<V>>(value: MotionValue<V>, event: EventName, callback: MotionValueEventCallbacks<V>[EventName]): VoidFunction;