react-ui-animate 5.0.0-rc.13 → 5.0.0-rc.2

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 (49) hide show
  1. package/README.md +6 -6
  2. package/dist/animation/{Config.d.ts → AnimationConfig.d.ts} +9 -9
  3. package/dist/animation/Value.d.ts +12 -0
  4. package/dist/animation/controllers.d.ts +41 -0
  5. package/dist/animation/hooks/index.d.ts +3 -2
  6. package/dist/animation/hooks/useAnimatedList.d.ts +24 -0
  7. package/dist/animation/hooks/useMount.d.ts +10 -14
  8. package/dist/animation/hooks/useValue.d.ts +13 -7
  9. package/dist/animation/index.d.ts +4 -5
  10. package/dist/animation/interpolation/colors.d.ts +25 -0
  11. package/dist/animation/interpolation/index.d.ts +1 -0
  12. package/dist/animation/interpolation/interpolateNumbers.d.ts +8 -0
  13. package/dist/animation/types.d.ts +26 -41
  14. package/dist/gestures/controllers/DragGesture.d.ts +15 -45
  15. package/dist/gestures/controllers/Gesture.d.ts +19 -12
  16. package/dist/gestures/controllers/MouseMoveGesture.d.ts +13 -0
  17. package/dist/gestures/controllers/ScrollGesture.d.ts +12 -27
  18. package/dist/gestures/controllers/WheelGesture.d.ts +13 -26
  19. package/dist/gestures/controllers/index.d.ts +4 -0
  20. package/dist/gestures/helpers/eventAttacher.d.ts +11 -0
  21. package/dist/gestures/helpers/index.d.ts +1 -0
  22. package/dist/gestures/helpers/math.d.ts +34 -0
  23. package/dist/gestures/helpers/withDefault.d.ts +4 -0
  24. package/dist/gestures/hooks/index.d.ts +5 -4
  25. package/dist/gestures/hooks/useDrag.d.ts +4 -5
  26. package/dist/gestures/hooks/useGesture.d.ts +9 -0
  27. package/dist/gestures/hooks/useMouseMove.d.ts +4 -0
  28. package/dist/gestures/hooks/useRecognizer.d.ts +9 -12
  29. package/dist/gestures/hooks/useScroll.d.ts +4 -8
  30. package/dist/gestures/hooks/useWheel.d.ts +4 -8
  31. package/dist/gestures/types/index.d.ts +51 -0
  32. package/dist/hooks/index.d.ts +3 -1
  33. package/dist/hooks/useMeasure.d.ts +14 -0
  34. package/dist/hooks/useOutsideClick.d.ts +1 -1
  35. package/dist/hooks/useWindowDimension.d.ts +9 -0
  36. package/dist/index.d.ts +5 -5
  37. package/dist/index.js +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/package.json +5 -14
  40. package/dist/animation/descriptors.d.ts +0 -7
  41. package/dist/animation/drivers.d.ts +0 -4
  42. package/dist/animation/helpers.d.ts +0 -3
  43. package/dist/animation/modules/Mount.d.ts +0 -17
  44. package/dist/animation/modules/index.d.ts +0 -1
  45. package/dist/animation/to.d.ts +0 -9
  46. package/dist/gestures/controllers/MoveGesture.d.ts +0 -30
  47. package/dist/gestures/hooks/useMove.d.ts +0 -8
  48. package/dist/gestures/index.d.ts +0 -1
  49. package/dist/utils/index.d.ts +0 -4
package/README.md CHANGED
@@ -157,7 +157,7 @@ export const Interpolation: React.FC = () => {
157
157
 
158
158
  - **`useValue(initial)`**: Initializes an animated value.
159
159
  - **`animate`**: JSX wrapper for animatable elements (`animate.div`, `animate.span`, etc.).
160
- - **Modifiers**: `withSpring`, `withTiming`, `withDecay`, `withSequence` — functions to define animation behavior.
160
+ - **Modifiers**: `withSpring`, `withTiming`, `withDecay`, `withSequence`, `withEase` — functions to define animation behavior.
161
161
  - **`useMount(state, config)`**: Manages mount/unmount transitions. `config` includes `from`, `enter`, and `exit` values.
162
162
 
163
163
  ## Gestures
@@ -165,9 +165,10 @@ export const Interpolation: React.FC = () => {
165
165
  `react-ui-animate` also provides hooks for handling gestures:
166
166
 
167
167
  - `useDrag`
168
- - `useMove`
168
+ - `useMouseMove`
169
169
  - `useScroll`
170
170
  - `useWheel`
171
+ - `useGesture`
171
172
 
172
173
  **Example: `useDrag`**
173
174
 
@@ -176,16 +177,15 @@ import React from 'react';
176
177
  import { useValue, animate, useDrag, withSpring } from 'react-ui-animate';
177
178
 
178
179
  export const Draggable: React.FC = () => {
179
- const ref = useRef(null);
180
180
  const [translateX, setTranslateX] = useValue(0);
181
181
 
182
- useDrag(ref, ({ down, movement }) => {
183
- setTranslateX(down ? movement.x : withSpring(0));
182
+ const bind = useDrag(({ down, movementX }) => {
183
+ setTranslateX(down ? movementX : withSpring(0));
184
184
  });
185
185
 
186
186
  return (
187
187
  <animate.div
188
- ref={ref}
188
+ {...bind()}
189
189
  style={{
190
190
  width: 100,
191
191
  height: 100,
@@ -1,5 +1,5 @@
1
1
  import { Easing } from '@raidipesh78/re-motion';
2
- export declare const Config: {
2
+ export declare const AnimationConfig: {
3
3
  Timing: {
4
4
  BOUNCE: {
5
5
  duration: number;
@@ -41,23 +41,23 @@ export declare const Config: {
41
41
  Spring: {
42
42
  ELASTIC: {
43
43
  mass: number;
44
- damping: number;
45
- stiffness: number;
44
+ friction: number;
45
+ tension: number;
46
46
  };
47
47
  EASE: {
48
48
  mass: number;
49
- damping: number;
50
- stiffness: number;
49
+ friction: number;
50
+ tension: number;
51
51
  };
52
52
  STIFF: {
53
53
  mass: number;
54
- damping: number;
55
- stiffness: number;
54
+ friction: number;
55
+ tension: number;
56
56
  };
57
57
  WOBBLE: {
58
58
  mass: number;
59
- damping: number;
60
- stiffness: number;
59
+ friction: number;
60
+ tension: number;
61
61
  };
62
62
  };
63
63
  };
@@ -0,0 +1,12 @@
1
+ import { MotionValue } from '@raidipesh78/re-motion';
2
+ import { ToValue } from './types';
3
+ export declare class Value<V extends number | string> {
4
+ private animation;
5
+ private unsubscribe?;
6
+ constructor(initial: V);
7
+ set(u: MotionValue<V> | ToValue<V>): void;
8
+ private buildDriver;
9
+ get value(): MotionValue<V>;
10
+ get current(): V;
11
+ destroy(): void;
12
+ }
@@ -0,0 +1,41 @@
1
+ import { DriverConfig, Primitive } from './types';
2
+ interface WithSpringOptions {
3
+ mass?: number;
4
+ tension?: number;
5
+ friction?: number;
6
+ onStart?: () => void;
7
+ onChange?: (v: number | string) => void;
8
+ onRest?: () => void;
9
+ }
10
+ export declare const withSpring: (to: Primitive, options?: WithSpringOptions) => DriverConfig;
11
+ export declare const withEase: (to: Primitive, options?: WithSpringOptions) => DriverConfig;
12
+ interface WithTimingOptions {
13
+ duration?: number;
14
+ easing?: (t: number) => number;
15
+ onStart?: () => void;
16
+ onChange?: (v: number | string) => void;
17
+ onRest?: () => void;
18
+ }
19
+ export declare const withTiming: (to: Primitive, options?: WithTimingOptions) => DriverConfig;
20
+ interface WithDecayOptions {
21
+ velocity: number;
22
+ onStart?: () => void;
23
+ onChange?: (v: number | string) => void;
24
+ onRest?: () => void;
25
+ clamp?: [number, number];
26
+ }
27
+ export declare const withDecay: (options: WithDecayOptions) => DriverConfig;
28
+ interface WithSequenceOptions {
29
+ onStart?: () => void;
30
+ onChange?: (v: number | string) => void;
31
+ onRest?: () => void;
32
+ }
33
+ export declare const withSequence: (steps: DriverConfig[], options?: WithSequenceOptions) => DriverConfig;
34
+ export declare const withDelay: (delay: number) => DriverConfig;
35
+ interface WithLoopOptions {
36
+ onStart?: () => void;
37
+ onChange?: (v: number | string) => void;
38
+ onRest?: () => void;
39
+ }
40
+ export declare const withLoop: (controller: DriverConfig, iterations: number, options?: WithLoopOptions) => DriverConfig;
41
+ export {};
@@ -1,2 +1,3 @@
1
- export { useValue } from './useValue';
2
- export { useMount } from './useMount';
1
+ export * from './useValue';
2
+ export * from './useMount';
3
+ export * from './useAnimatedList';
@@ -0,0 +1,24 @@
1
+ import { MotionValue } from '@raidipesh78/re-motion';
2
+ import type { ToValue } from '../types';
3
+ export declare function useAnimatedList<T>(items: T[], getKey: (item: T) => string, config?: {
4
+ from?: number;
5
+ enter?: ToValue<number>;
6
+ exit?: ToValue<number>;
7
+ }): Array<{
8
+ key: string;
9
+ item: T;
10
+ animation: MotionValue<number>;
11
+ }>;
12
+ export declare function useAnimatedList<T, I extends Record<string, number>>(items: T[], getKey: (item: T) => string, config: {
13
+ from: I;
14
+ enter?: Partial<{
15
+ [K in keyof I]: ToValue<I[K]>;
16
+ }>;
17
+ exit?: Partial<{
18
+ [K in keyof I]: ToValue<I[K]>;
19
+ }>;
20
+ }): Array<{
21
+ key: string;
22
+ item: T;
23
+ animation: Record<keyof I, MotionValue<number>>;
24
+ }>;
@@ -1,16 +1,12 @@
1
1
  import { MotionValue } from '@raidipesh78/re-motion';
2
- import type { Primitive, Descriptor } from '../types';
3
- export type ConfigSingle<T extends Primitive> = {
4
- from?: T;
5
- enter?: T | Descriptor;
6
- exit?: T | Descriptor;
7
- };
8
- export type ConfigMulti<I extends Record<string, Primitive>> = {
2
+ import type { ToValue } from '../types';
3
+ export declare function useMount(isOpen: boolean, config?: {
4
+ from?: number;
5
+ enter?: ToValue<number>;
6
+ exit?: ToValue<number>;
7
+ }): (fn: (value: MotionValue<number>, mounted: boolean) => React.ReactNode) => React.ReactNode;
8
+ export declare function useMount<I extends Record<string, number>>(isOpen: boolean, config: {
9
9
  from: I;
10
- enter?: I | Descriptor;
11
- exit?: I | Descriptor;
12
- };
13
- export declare function useMount<T extends Primitive = number>(isOpen: boolean, config?: ConfigSingle<T>): (fn: (value: MotionValue<T>, mounted: boolean) => React.ReactNode) => React.ReactNode;
14
- export declare function useMount<I extends Record<string, Primitive>>(isOpen: boolean, config: ConfigMulti<I>): (fn: (values: {
15
- [K in keyof I]: MotionValue<I[K]>;
16
- }, mounted: boolean) => React.ReactNode) => React.ReactNode;
10
+ enter?: Partial<Record<keyof I, ToValue<number>>>;
11
+ exit?: Partial<Record<keyof I, ToValue<number>>>;
12
+ }): (fn: (values: Record<keyof I, MotionValue<number>>, mounted: boolean) => React.ReactNode) => React.ReactNode;
@@ -1,9 +1,15 @@
1
1
  import { MotionValue } from '@raidipesh78/re-motion';
2
- import type { Primitive, Descriptor, Controls } from '../types';
3
- type Widen<T> = T extends number ? number : T extends string ? string : T;
4
- type ValueReturn<T> = T extends Primitive ? MotionValue<Widen<T>> : T extends Primitive[] ? MotionValue<Widen<Primitive>>[] : {
5
- [K in keyof T]: MotionValue<Widen<T[K]>>;
6
- };
7
- type Base = Primitive | Primitive[] | Record<string, Primitive>;
8
- export declare function useValue<T extends Base>(initial: T): [ValueReturn<T>, (to: Base | Descriptor) => void, Controls];
2
+ import { Primitive, ToValue } from '../types';
3
+ type Input<V extends Primitive> = V | V[] | Record<string, V>;
4
+ type Output<V extends Primitive, I extends Input<V>> = I extends V ? MotionValue<V> : I extends V[] ? {
5
+ [K in keyof I]: MotionValue<V>;
6
+ } : I extends Record<string, V> ? {
7
+ [K in keyof I]: MotionValue<V>;
8
+ } : never;
9
+ type SetterParam<V extends Primitive, I extends Input<V>> = I extends V ? MotionValue<V> | ToValue<V> : I extends V[] ? Partial<{
10
+ [K in keyof I]: MotionValue<V> | ToValue<V>;
11
+ }> : I extends Record<string, V> ? Partial<{
12
+ [K in keyof I]: MotionValue<V> | ToValue<V>;
13
+ }> : never;
14
+ export declare function useValue<V extends Primitive, I extends Input<V>>(initial: I): [Output<V, I>, (to: SetterParam<V, I>) => void];
9
15
  export {};
@@ -1,5 +1,4 @@
1
- export * from './hooks';
2
- export * from './modules';
3
- export * from './descriptors';
4
- export * from './Config';
5
- export * from './to';
1
+ export { useValue, useMount, useAnimatedList } from './hooks';
2
+ export { withSpring, withTiming, withSequence, withDelay, withDecay, withLoop, withEase, } from './controllers';
3
+ export { AnimationConfig } from './AnimationConfig';
4
+ export { interpolateNumbers } from './interpolation';
@@ -0,0 +1,25 @@
1
+ export declare const COLOR_NUMBER_REGEX: RegExp;
2
+ export declare const HEX_NAME_COLOR: RegExp;
3
+ interface classNameType {
4
+ [name: string]: string;
5
+ }
6
+ export declare const colorNames: classNameType;
7
+ export declare function hexToRgba(hex: string): {
8
+ r: number;
9
+ g: number;
10
+ b: number;
11
+ a: number;
12
+ };
13
+ export declare function rgbaToHex(rgba: {
14
+ r: number;
15
+ g: number;
16
+ b: number;
17
+ a: number;
18
+ }): string;
19
+ export declare function processColor(color: number | string): {
20
+ r: number;
21
+ g: number;
22
+ b: number;
23
+ a: number;
24
+ };
25
+ export {};
@@ -0,0 +1 @@
1
+ export { interpolateNumbers } from './interpolateNumbers';
@@ -0,0 +1,8 @@
1
+ type ExtrapolateType = 'identity' | 'extend' | 'clamp';
2
+ type ExtrapolateConfig = {
3
+ extrapolate?: ExtrapolateType;
4
+ extrapolateLeft?: ExtrapolateType;
5
+ extrapolateRight?: ExtrapolateType;
6
+ };
7
+ export declare function interpolateNumbers(value: number, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig): any;
8
+ export {};
@@ -1,42 +1,27 @@
1
1
  export type Primitive = number | string;
2
- export interface Callbacks {
3
- onStart?: () => void;
4
- onChange?: (v: number) => void;
5
- onComplete?: () => void;
6
- }
7
- export interface SpringOptions {
8
- stiffness?: number;
9
- damping?: number;
10
- mass?: number;
11
- }
12
- export interface TimingOptions {
13
- duration?: number;
14
- easing?: (t: number) => number;
15
- }
16
- export interface DecayOptions {
17
- velocity?: number;
18
- clamp?: [number, number];
19
- }
20
- export interface SequenceOptions {
21
- animations?: Descriptor[];
22
- }
23
- export interface DelayOptions {
24
- delay?: number;
25
- }
26
- export interface LoopOptions {
27
- iterations?: number;
28
- animation?: Descriptor;
29
- }
30
- export type DriverType = 'spring' | 'timing' | 'decay' | 'delay' | 'sequence' | 'loop';
31
- export interface Descriptor {
32
- type: DriverType;
33
- to?: Primitive | Primitive[] | Record<string, Primitive>;
34
- options?: SpringOptions & TimingOptions & DecayOptions & SequenceOptions & DelayOptions & LoopOptions & Callbacks;
35
- }
36
- export interface Controls {
37
- start(): void;
38
- pause(): void;
39
- resume(): void;
40
- cancel(): void;
41
- reset(): void;
42
- }
2
+ export interface WithCallbacks {
3
+ onStart?: (value: number | string) => void;
4
+ onChange?: (value: number | string) => void;
5
+ onRest?: (value: number | string) => void;
6
+ }
7
+ export type DriverConfig = {
8
+ type: 'spring' | 'timing' | 'decay' | 'sequence' | 'delay' | 'loop';
9
+ to?: Primitive;
10
+ options?: {
11
+ controller?: DriverConfig;
12
+ iterations?: number;
13
+ delay?: number;
14
+ duration?: number;
15
+ easing?: (t: number) => number;
16
+ stiffness?: number;
17
+ damping?: number;
18
+ mass?: number;
19
+ velocity?: number;
20
+ clamp?: [number, number];
21
+ steps?: DriverConfig[];
22
+ onStart?: () => void;
23
+ onChange?: (v: string | number) => void;
24
+ onComplete?: () => void;
25
+ };
26
+ };
27
+ export type ToValue<V> = DriverConfig | V;
@@ -1,47 +1,17 @@
1
1
  import { Gesture } from './Gesture';
2
- export interface DragEvent {
3
- down: boolean;
4
- movement: {
5
- x: number;
6
- y: number;
7
- };
8
- offset: {
9
- x: number;
10
- y: number;
11
- };
12
- velocity: {
13
- x: number;
14
- y: number;
15
- };
16
- event: PointerEvent;
17
- cancel: () => void;
18
- }
19
- export interface DragConfig {
20
- threshold?: number;
21
- axis?: 'x' | 'y';
22
- initial?: () => {
23
- x: number;
24
- y: number;
25
- };
26
- }
27
- export declare class DragGesture extends Gesture<DragEvent> {
28
- private config;
29
- private prev;
30
- private lastTime;
31
- private movement;
32
- private velocity;
33
- private start;
34
- private offset;
35
- private pointerCaptured;
36
- private activePointerId;
37
- private attachedEls;
38
- private activeEl;
39
- private pointerDownPos;
40
- private thresholdPassed;
41
- constructor(config?: DragConfig);
42
- attach(elements: HTMLElement | HTMLElement[] | Window): () => void;
43
- private onDown;
44
- private onMove;
45
- private onUp;
46
- cancel(): void;
2
+ import type { Vector2 } from '../types';
3
+ export declare class DragGesture extends Gesture {
4
+ movementStart: Vector2;
5
+ initialMovement: Vector2;
6
+ movement: Vector2;
7
+ previousMovement: Vector2;
8
+ translation: Vector2;
9
+ offset: Vector2;
10
+ velocity: Vector2;
11
+ _initEvents(): void;
12
+ _cancelEvents(): void;
13
+ _handleCallback(): void;
14
+ pointerDown(e: any): void;
15
+ pointerMove(e: any): void;
16
+ pointerUp(): void;
47
17
  }
@@ -1,13 +1,20 @@
1
- type Listener<E> = (event: E) => void;
2
- export declare abstract class Gesture<E> {
3
- static readonly VELOCITY_LIMIT = 20;
4
- private changeListeners;
5
- private endListeners;
6
- onChange(listener: Listener<E>): this;
7
- onEnd(listener: Listener<E>): this;
8
- protected emitChange(event: E): void;
9
- protected emitEnd(event: E): void;
10
- abstract attach(elements: HTMLElement | HTMLElement | Window): () => void;
11
- abstract cancel(): void;
1
+ export declare class Gesture {
2
+ currentIndex?: number;
3
+ lastTimeStamp: number;
4
+ isActive: boolean;
5
+ targetElement?: HTMLElement;
6
+ targetElements: Array<HTMLElement>;
7
+ config?: any;
8
+ callback?: <T>(event: T) => void;
9
+ _subscribe?: (eventKeys?: Array<string>) => void;
10
+ static _VELOCITY_LIMIT: number;
11
+ _initEvents(): void;
12
+ _cancelEvents(): void;
13
+ applyCallback(callback: <T>(event: T) => void): void;
14
+ applyGesture({ targetElement, targetElements, callback, config, }: {
15
+ targetElement?: any;
16
+ targetElements?: any;
17
+ callback: <T>(event: T) => void;
18
+ config?: any;
19
+ }): () => void | undefined;
12
20
  }
13
- export {};
@@ -0,0 +1,13 @@
1
+ import { Vector2 } from '../types';
2
+ import { Gesture } from './Gesture';
3
+ export declare class MouseMoveGesture extends Gesture {
4
+ event?: MouseEvent;
5
+ isActiveID?: any;
6
+ movement: Vector2;
7
+ previousMovement: Vector2;
8
+ velocity: Vector2;
9
+ direction: Vector2;
10
+ _initEvents(): void;
11
+ _handleCallback(): void;
12
+ onMouseMove(e: MouseEvent): void;
13
+ }
@@ -1,29 +1,14 @@
1
+ import { Vector2 } from '../types';
1
2
  import { Gesture } from './Gesture';
2
- export interface ScrollEvent {
3
- movement: {
4
- x: number;
5
- y: number;
6
- };
7
- offset: {
8
- x: number;
9
- y: number;
10
- };
11
- velocity: {
12
- x: number;
13
- y: number;
14
- };
15
- event: Event;
16
- cancel?: () => void;
17
- }
18
- export declare class ScrollGesture extends Gesture<ScrollEvent> {
19
- private attachedEls;
20
- private movement;
21
- private offset;
22
- private velocity;
23
- private prevScroll;
24
- private lastTime;
25
- private endTimeout?;
26
- attach(elements: HTMLElement | HTMLElement[] | Window): () => void;
27
- cancel(): void;
28
- private onScroll;
3
+ export declare class ScrollGesture extends Gesture {
4
+ isActiveID?: any;
5
+ movement: Vector2;
6
+ previousMovement: Vector2;
7
+ direction: Vector2;
8
+ velocity: Vector2;
9
+ _initEvents(): void;
10
+ _handleCallback(): void;
11
+ onScroll({ x, y }: Vector2): void;
12
+ scrollListener(): void;
13
+ scrollElementListener(): void;
29
14
  }
@@ -1,28 +1,15 @@
1
+ import { Vector2 } from '../types';
1
2
  import { Gesture } from './Gesture';
2
- export interface WheelEvent {
3
- movement: {
4
- x: number;
5
- y: number;
6
- };
7
- offset: {
8
- x: number;
9
- y: number;
10
- };
11
- velocity: {
12
- x: number;
13
- y: number;
14
- };
15
- event: globalThis.WheelEvent;
16
- cancel?: () => void;
17
- }
18
- export declare class WheelGesture extends Gesture<WheelEvent> {
19
- private attachedEls;
20
- private movement;
21
- private offset;
22
- private velocity;
23
- private lastTime;
24
- private endTimeout?;
25
- attach(elements: HTMLElement | HTMLElement[] | Window): () => void;
26
- cancel(): void;
27
- private onWheel;
3
+ export declare class WheelGesture extends Gesture {
4
+ isActiveID?: any;
5
+ movement: Vector2;
6
+ previousMovement: Vector2;
7
+ direction: Vector2;
8
+ velocity: Vector2;
9
+ delta: Vector2;
10
+ offset: Vector2;
11
+ translation: Vector2;
12
+ _initEvents(): void;
13
+ _handleCallback(): void;
14
+ onWheel(event: WheelEvent): void;
28
15
  }
@@ -0,0 +1,4 @@
1
+ export * from './DragGesture';
2
+ export * from './MouseMoveGesture';
3
+ export * from './ScrollGesture';
4
+ export * from './WheelGesture';
@@ -0,0 +1,11 @@
1
+ type MouseEventType = 'click' | 'dblclick' | 'mousedown' | 'mousemove' | 'mouseup' | 'touchstart' | 'touchmove' | 'touchend' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'mouseover' | 'scroll' | 'wheel' | 'contextmenu';
2
+ type DomTargetTypes = Array<Window | Document | HTMLElement>;
3
+ /**
4
+ * Attach multiple document / window event / HTMLElement
5
+ */
6
+ export declare function attachEvents(domTargets: DomTargetTypes, events: Array<[
7
+ event: MouseEventType,
8
+ callback: (e: any) => void,
9
+ capture?: any
10
+ ]>): (eventKeys?: Array<string>) => void;
11
+ export {};
@@ -0,0 +1 @@
1
+ export * from './math';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * bin(booleanValue)
3
+ * returns 1 if booleanValue == true and 0 if booleanValue == false
4
+ */
5
+ export declare function bin(bool: boolean): 1 | 0;
6
+ /**
7
+ * mix(progress, a, b)
8
+ * linear interpolation between a and b
9
+ */
10
+ export declare function mix(perc: number, val1: number, val2: number): number;
11
+ /**
12
+ * clamp(value, min, max)
13
+ * clamps value for min and max bounds
14
+ */
15
+ export declare function clamp(value: number, lowerbound: number, upperbound: number): number;
16
+ /**
17
+ * rubberClamp(value, min, max, constant?)
18
+ * constant is optional : default 0.15
19
+ * clamps the value for min and max value and
20
+ * extends beyond min and max values with constant
21
+ * factor to create elastic rubber band effect
22
+ */
23
+ export declare function rubberClamp(value: number, lowerbound: number, upperbound: number, constant?: number): number;
24
+ /**
25
+ * snapTo(value, velocity, snapPoints[])
26
+ * Calculates the final snapPoint according to given current value,
27
+ * velocity and snapPoints array
28
+ */
29
+ export declare function snapTo(value: number, velocity: number, snapPoints: Array<number>): number;
30
+ /**
31
+ * move(array, moveIndex, toIndex)
32
+ * move array item from moveIndex to toIndex without array modification
33
+ */
34
+ export declare function move(array: Array<any>, moveIndex: number, toIndex: number): any[];
@@ -0,0 +1,4 @@
1
+ export declare const withDefault: (x: number, y: number) => {
2
+ x: number;
3
+ y: number;
4
+ };
@@ -1,4 +1,5 @@
1
- export { useDrag } from './useDrag';
2
- export { useMove } from './useMove';
3
- export { useScroll } from './useScroll';
4
- export { useWheel } from './useWheel';
1
+ export * from './useDrag';
2
+ export * from './useMouseMove';
3
+ export * from './useScroll';
4
+ export * from './useWheel';
5
+ export * from './useGesture';
@@ -1,5 +1,4 @@
1
- import { RefObject } from 'react';
2
- import { type DragConfig, type DragEvent } from '../controllers/DragGesture';
3
- export declare function useDrag<T extends HTMLElement>(refs: RefObject<T> | Array<RefObject<T>>, onDrag: (e: DragEvent & {
4
- index: number;
5
- }) => void, config?: DragConfig): void;
1
+ import { DragEventType, UseDragConfig } from '../types';
2
+ export declare function useDrag(callback: (event: DragEventType) => void, config?: UseDragConfig): (index?: number) => {
3
+ ref: any;
4
+ };
@@ -0,0 +1,9 @@
1
+ import { DragEventType, WheelEventType, ScrollEventType, MouseMoveEventType } from '../types';
2
+ export declare function useGesture({ onDrag, onWheel, onScroll, onMouseMove, }: {
3
+ onDrag?: (event: DragEventType) => void;
4
+ onWheel?: (event: WheelEventType) => void;
5
+ onScroll?: (event: ScrollEventType) => void;
6
+ onMouseMove?: (event: MouseMoveEventType) => void;
7
+ }): (index?: number) => {
8
+ ref: any;
9
+ };
@@ -0,0 +1,4 @@
1
+ import { MouseMoveEventType } from '../types';
2
+ export declare function useMouseMove(callback: (event: MouseMoveEventType) => void): (index?: number) => {
3
+ ref: any;
4
+ };