react-ui-animate 1.4.6 → 2.0.0-rc.3

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 (64) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/animation/animationType.d.ts +15 -0
  3. package/dist/animation/getInitialConfig.d.ts +3 -3
  4. package/dist/animation/index.d.ts +6 -4
  5. package/dist/animation/interpolation.d.ts +3 -11
  6. package/dist/animation/modules/AnimatedBlock.d.ts +8 -0
  7. package/dist/animation/modules/AnimatedImage.d.ts +8 -0
  8. package/dist/animation/modules/AnimatedInline.d.ts +8 -0
  9. package/dist/animation/modules/MountedBlock.d.ts +18 -0
  10. package/dist/animation/modules/ScrollableBlock.d.ts +22 -0
  11. package/dist/animation/modules/TransitionBlock.d.ts +18 -0
  12. package/dist/animation/modules/index.d.ts +6 -0
  13. package/dist/animation/useAnimatedValue.d.ts +17 -25
  14. package/dist/animation/useMountedValue.d.ts +9 -17
  15. package/dist/gestures/controllers/MouseMoveGesture.d.ts +2 -2
  16. package/dist/gestures/controllers/ScrollGesture.d.ts +2 -2
  17. package/dist/gestures/controllers/WheelGesture.d.ts +2 -2
  18. package/dist/gestures/controllers/index.d.ts +4 -4
  19. package/dist/gestures/eventAttacher.d.ts +1 -1
  20. package/dist/gestures/hooks/index.d.ts +5 -5
  21. package/dist/gestures/hooks/useDrag.d.ts +1 -1
  22. package/dist/gestures/hooks/useGesture.d.ts +1 -1
  23. package/dist/gestures/hooks/useMouseMove.d.ts +1 -1
  24. package/dist/gestures/hooks/useRecognizer.d.ts +1 -1
  25. package/dist/gestures/hooks/useScroll.d.ts +1 -1
  26. package/dist/gestures/hooks/useWheel.d.ts +1 -1
  27. package/dist/gestures/index.d.ts +2 -2
  28. package/dist/index.d.ts +5 -4
  29. package/dist/index.js +234 -216
  30. package/dist/index.js.map +1 -1
  31. package/dist/utils/delay.d.ts +5 -0
  32. package/dist/utils/index.d.ts +2 -1
  33. package/package.json +2 -2
  34. package/src/animation/animationType.ts +17 -0
  35. package/src/animation/getInitialConfig.ts +46 -16
  36. package/src/animation/index.ts +10 -4
  37. package/src/animation/interpolation.ts +5 -38
  38. package/src/animation/modules/AnimatedBlock.ts +8 -0
  39. package/src/animation/modules/AnimatedImage.ts +8 -0
  40. package/src/animation/modules/AnimatedInline.ts +8 -0
  41. package/src/animation/modules/MountedBlock.tsx +25 -0
  42. package/src/animation/modules/ScrollableBlock.tsx +62 -0
  43. package/src/animation/modules/TransitionBlock.tsx +26 -0
  44. package/src/animation/modules/index.ts +6 -0
  45. package/src/animation/useAnimatedValue.ts +31 -92
  46. package/src/animation/useMountedValue.ts +29 -44
  47. package/src/gestures/controllers/MouseMoveGesture.ts +8 -8
  48. package/src/gestures/controllers/ScrollGesture.ts +7 -7
  49. package/src/gestures/controllers/WheelGesture.ts +6 -6
  50. package/src/gestures/controllers/index.ts +4 -4
  51. package/src/gestures/eventAttacher.ts +15 -15
  52. package/src/gestures/hooks/index.ts +5 -5
  53. package/src/gestures/hooks/useDrag.ts +5 -5
  54. package/src/gestures/hooks/useGesture.ts +8 -8
  55. package/src/gestures/hooks/useMouseMove.ts +5 -5
  56. package/src/gestures/hooks/useRecognizer.ts +2 -2
  57. package/src/gestures/hooks/useScroll.ts +5 -5
  58. package/src/gestures/hooks/useWheel.ts +5 -5
  59. package/src/gestures/index.ts +2 -2
  60. package/src/index.ts +5 -4
  61. package/src/utils/delay.ts +9 -0
  62. package/src/utils/index.ts +2 -1
  63. package/dist/animation/modules.d.ts +0 -47
  64. package/src/animation/modules.tsx +0 -105
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { TransitionValue } from '@raidipesh78/re-motion';
3
+ import { useMountedValue, UseMountedValueConfig } from '../useMountedValue';
4
+
5
+ interface MountedBlockProps {
6
+ state: boolean;
7
+ children: (animation: { value: TransitionValue }) => React.ReactNode;
8
+ config: UseMountedValueConfig;
9
+ }
10
+
11
+ /**
12
+ * MountedBlock - Higher order component which handles mounting and unmounting of a component.
13
+ * @prop { boolean } state - Boolean indicating the component should mount or unmount.
14
+ * @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
15
+ * @prop { UseMountedValueConfig } config - Animation configuration.
16
+ */
17
+ export const MountedBlock = ({
18
+ state,
19
+ children,
20
+ config,
21
+ }: MountedBlockProps) => {
22
+ const open = useMountedValue(state, config);
23
+
24
+ return <>{open((animation, mounted) => mounted && children(animation))}</>;
25
+ };
@@ -0,0 +1,62 @@
1
+ import * as React from 'react';
2
+ import { TransitionValue } from '@raidipesh78/re-motion';
3
+ import { useAnimatedValue, UseAnimatedValueConfig } from '../useAnimatedValue';
4
+
5
+ interface ScrollableBlockProps {
6
+ children?: (animation: { value: TransitionValue }) => React.ReactNode;
7
+ direction?: 'single' | 'both';
8
+ threshold?: number;
9
+ animationConfig?: UseAnimatedValueConfig;
10
+ }
11
+
12
+ /**
13
+ * ScrollableBlock - Higher order component to handle the entrance or exit animation
14
+ * of a component when it enters or exit the viewport. Accepts child as a function with
15
+ * `AnimatedValue` as its first argument which can be interpolated on input range [0, 1]
16
+ * @prop { function } children - child as a function with `AnimatedValue` as its first argument.
17
+ * @prop { 'single' | 'both' } direction - single applies animation on enter once, both applies on enter and exit.
18
+ * @prop { number } threshold - should be in range 0 to 1 which equivalent to `IntersectionObserver` threshold.
19
+ * @prop { UseAnimatedValueConfig } animationConfig - Animation config
20
+ */
21
+ export const ScrollableBlock = (props: ScrollableBlockProps) => {
22
+ const {
23
+ children,
24
+ direction = 'single',
25
+ animationConfig,
26
+ threshold = 0.2,
27
+ } = props;
28
+ const scrollableBlockRef = React.useRef<HTMLDivElement>(null);
29
+ const animation = useAnimatedValue(0, animationConfig); // 0: not intersecting | 1: intersecting
30
+
31
+ React.useEffect(() => {
32
+ const _scrollableBlock = scrollableBlockRef.current;
33
+
34
+ const observer = new IntersectionObserver(
35
+ function ([entry]) {
36
+ const { isIntersecting } = entry;
37
+
38
+ if (isIntersecting) {
39
+ animation.value = 1;
40
+ } else {
41
+ if (direction === 'both') animation.value = 0;
42
+ }
43
+ },
44
+ {
45
+ root: null, // FOR VIEWPORT ONLY
46
+ threshold,
47
+ }
48
+ );
49
+
50
+ if (_scrollableBlock) {
51
+ observer.observe(_scrollableBlock);
52
+ }
53
+
54
+ return () => {
55
+ if (_scrollableBlock) {
56
+ observer.unobserve(_scrollableBlock);
57
+ }
58
+ };
59
+ }, []);
60
+
61
+ return <div ref={scrollableBlockRef}>{children && children(animation)}</div>;
62
+ };
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { TransitionValue } from '@raidipesh78/re-motion';
3
+ import { bin } from '../../gestures/math';
4
+ import { useAnimatedValue, UseAnimatedValueConfig } from '../useAnimatedValue';
5
+
6
+ interface TransitionBlockProps {
7
+ state: boolean;
8
+ children: (animation: { value: TransitionValue }) => React.ReactNode;
9
+ config?: UseAnimatedValueConfig;
10
+ }
11
+
12
+ /**
13
+ * TransitionBlock - Higher order component which animates on state change.
14
+ * @prop { boolean } state - Boolean indicating the current state of animation, usually `false = 0 and true = 1`.
15
+ * @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
16
+ * @prop { UseAnimatedValueConfig } config - Animation configuration.
17
+ */
18
+ export const TransitionBlock = ({
19
+ state,
20
+ children,
21
+ config,
22
+ }: TransitionBlockProps) => {
23
+ const amv = useAnimatedValue(bin(state), config);
24
+
25
+ return <>{children(amv)}</>;
26
+ };
@@ -0,0 +1,6 @@
1
+ export * from './AnimatedBlock';
2
+ export * from './AnimatedInline';
3
+ export * from './AnimatedImage';
4
+ export * from './MountedBlock';
5
+ export * from './ScrollableBlock';
6
+ export * from './TransitionBlock';
@@ -1,131 +1,70 @@
1
- import * as React from "react";
2
- import {
3
- useTransition,
4
- TransitionValue,
5
- ResultType,
6
- } from "@raidipesh78/re-motion";
7
- import { InitialConfigType, getInitialConfig } from "./getInitialConfig";
1
+ import { useTransition, UseTransitionConfig } from '@raidipesh78/re-motion';
2
+ import { AnimationConfigUtils } from './animationType';
8
3
 
9
4
  // useAnimatedValue value type
10
- type AnimatedValueType = number | string;
5
+ type Length = number | string;
6
+ type AnimatedValueType = Length;
11
7
 
12
- /**
13
- * getValue checks for type of initialValue and throws error
14
- * for type other than AnimatedValueType
15
- */
16
- const getValue = (value: AnimatedValueType) => {
17
- if (typeof value === "number" || typeof value === "string") {
18
- return value;
19
- } else {
20
- throw new Error(
21
- "Invalid Value! Animated value only accepts string or number."
22
- );
23
- }
24
- };
25
-
26
- // General config type
27
- export interface GenericAnimationConfig {
28
- duration?: number;
29
- mass?: number;
30
- friction?: number;
31
- tension?: number;
32
- easing?: (t: number) => number;
33
- delay?: number;
34
- }
35
-
36
- export interface UseAnimatedValueConfig extends GenericAnimationConfig {
37
- animationType?: InitialConfigType;
38
- onAnimationEnd?: (value: ResultType) => void;
39
- listener?: (value: number) => void;
40
- immediate?: boolean;
41
- }
42
-
43
- export type ValueReturnType =
44
- | TransitionValue
45
- | number
46
- | string
47
- | { toValue: number | string; immediate?: boolean };
8
+ export interface UseAnimatedValueConfig extends UseTransitionConfig {}
48
9
 
49
- interface UseAnimatedValueReturn {
50
- value: ValueReturnType;
51
- currentValue: number | string;
52
- }
10
+ type AssignValue = {
11
+ toValue: Length;
12
+ config?: UseAnimatedValueConfig;
13
+ };
14
+ export type ValueType =
15
+ | Length
16
+ | AssignValue
17
+ | ((update: (next: AssignValue) => Promise<any>) => void);
53
18
 
54
19
  /**
55
- * useAnimatedValue for animated transitions
20
+ * `useAnimatedValue` returns an animation value with `.value` and `.currentValue` property which is
21
+ * initialized when passed to argument (`initialValue`). The retured value persist until the lifetime of
22
+ * a component. It doesnot cast any re-renders which can is very good for performance optimization.
23
+ * @param { string | number } initialValue - Initial value
24
+ * @param { UseAnimatedValueConfig } config - Animation configuration object.
56
25
  */
57
26
  export function useAnimatedValue(
58
27
  initialValue: AnimatedValueType,
59
28
  config?: UseAnimatedValueConfig
60
- ): UseAnimatedValueReturn {
61
- const _isInitial = React.useRef(true);
62
- const _initialValue: number | string = getValue(initialValue);
63
-
64
- const animationType = config?.animationType ?? "ease"; // Defines default animation
65
- const onAnimationEnd = config?.onAnimationEnd;
66
- const listener = config?.listener;
67
-
68
- const [animation, setAnimation] = useTransition(_initialValue, {
69
- ...getInitialConfig(animationType),
29
+ ) {
30
+ const [animation, setAnimation] = useTransition(initialValue, {
31
+ ...AnimationConfigUtils.EASE,
70
32
  ...config,
71
- onRest: function (result: any) {
72
- if (result.finished) {
73
- onAnimationEnd && onAnimationEnd(result.value);
74
- }
75
- },
76
- onChange: function (value: number) {
77
- listener && listener(value);
78
- },
79
33
  });
80
34
 
81
- // doesn't fire on initial render
82
- React.useEffect(() => {
83
- if (!_isInitial.current) {
84
- setAnimation({ toValue: _initialValue });
85
- }
86
- _isInitial.current = false;
87
- }, [_initialValue]);
88
-
89
35
  const targetObject: {
90
36
  value: any;
91
- currentValue: string | number;
37
+ currentValue: number | string;
92
38
  } = {
93
39
  value: animation,
94
40
  currentValue: animation.get(),
95
41
  };
96
42
 
97
43
  return new Proxy(targetObject, {
98
- set: function (
99
- _,
100
- key,
101
- value: number | string | { toValue: number | string; immediate?: boolean }
102
- ) {
103
- if (key === "value") {
104
- if (typeof value === "number" || typeof value === "string") {
44
+ set: function (_, key, value: ValueType) {
45
+ if (key === 'value') {
46
+ if (typeof value === 'number' || typeof value === 'string') {
105
47
  setAnimation({ toValue: value });
106
- } else if (typeof value === "object") {
107
- setAnimation({
108
- toValue: value.toValue,
109
- config: { immediate: value.immediate },
110
- });
48
+ } else if (typeof value === 'object' || typeof value === 'function') {
49
+ setAnimation(value);
111
50
  }
112
51
 
113
52
  return true;
114
53
  }
115
54
 
116
- throw new Error("You cannot set any other property to animation node.");
55
+ throw new Error('You cannot set any other property to animation node.');
117
56
  },
118
57
  get: function (_, key) {
119
- if (key === "value") {
58
+ if (key === 'value') {
120
59
  return animation;
121
60
  }
122
61
 
123
- if (key === "currentValue") {
62
+ if (key === 'currentValue') {
124
63
  return animation.get();
125
64
  }
126
65
 
127
66
  throw new Error(
128
- "You cannot access any other property from animation node."
67
+ 'You cannot access any other property from animation node.'
129
68
  );
130
69
  },
131
70
  });
@@ -1,50 +1,42 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
  import {
3
3
  useTransition,
4
4
  TransitionValue,
5
- UseTransitionConfig,
6
- } from "@raidipesh78/re-motion";
5
+ UseMountConfig,
6
+ } from '@raidipesh78/re-motion';
7
7
 
8
- export interface InnerUseMountedValueConfig extends UseTransitionConfig {
9
- enterDuration?: number;
10
- exitDuration?: number;
11
- }
12
-
13
- interface UseMountedValueConfig {
14
- from: number;
15
- enter: number;
16
- exit: number;
17
- config?: InnerUseMountedValueConfig;
18
- }
8
+ export interface UseMountedValueConfig extends UseMountConfig {}
19
9
 
20
10
  /**
21
- * useMountedValue handles mounting and unmounting of a component
22
- * @param state - boolean
23
- * @param config - useTransitionConfig
24
- * @returns mountedValueFunction with a callback with argument ( animationNode, mounted )
11
+ * `useMountedValue` handles mounting and unmounting of a component which captures current state
12
+ * passed as an arugment (`state`) and exposes the shadow state which handles the mount and unmount
13
+ * of a component.
14
+ * @param { boolean } state - Boolean indicating the component should mount or unmount.
15
+ * @param { UseMountedValueConfig } config - Animation configuration.
25
16
  */
26
17
  export function useMountedValue(state: boolean, config: UseMountedValueConfig) {
27
- const [initial, setInitial] = React.useState(true);
18
+ const initial = React.useRef(true);
28
19
  const [mounted, setMounted] = React.useState(state);
29
- const { from, enter, exit, config: _config } = React.useRef(config).current;
30
- const [animation, setAnimation] = useTransition(from, _config);
31
-
32
- const enterDuration = config.config?.enterDuration ?? config.config?.duration;
33
- const exitDuration =
34
- config.config?.exitDuration ?? config.config?.exitDuration;
20
+ const {
21
+ from,
22
+ enter,
23
+ exit,
24
+ config: innerConfig,
25
+ enterConfig,
26
+ exitConfig,
27
+ } = React.useRef(config).current;
28
+ const [animation, setAnimation] = useTransition(from, innerConfig);
35
29
 
36
30
  React.useEffect(() => {
37
31
  if (state) {
38
- setInitial(true);
32
+ initial.current = true;
39
33
  setMounted(true);
40
34
  } else {
41
- setInitial(false);
35
+ initial.current = false;
42
36
  setAnimation(
43
37
  {
44
38
  toValue: exit,
45
- config: {
46
- duration: exitDuration,
47
- },
39
+ config: exitConfig,
48
40
  },
49
41
  function ({ finished }) {
50
42
  if (finished) {
@@ -56,24 +48,17 @@ export function useMountedValue(state: boolean, config: UseMountedValueConfig) {
56
48
  }, [state]);
57
49
 
58
50
  React.useEffect(() => {
59
- if (mounted && initial) {
60
- setAnimation(
61
- {
62
- toValue: enter,
63
- config: {
64
- duration: enterDuration,
65
- },
66
- },
67
- function () {
68
- return;
69
- }
70
- );
51
+ if (mounted && initial.current) {
52
+ setAnimation({
53
+ toValue: enter,
54
+ config: enterConfig,
55
+ });
71
56
  }
72
- }, [mounted, initial]);
57
+ }, [mounted, initial.current]);
73
58
 
74
59
  return function (
75
60
  callback: (
76
- { value }: { value: TransitionValue },
61
+ { value: animation }: { value: TransitionValue },
77
62
  mounted: boolean
78
63
  ) => React.ReactNode
79
64
  ) {
@@ -1,8 +1,8 @@
1
- import { attachEvents } from "../eventAttacher";
2
- import { Vector2 } from "../types";
3
- import { clamp } from "../math";
4
- import { withDefault } from "../withDefault";
5
- import { Gesture } from "./Gesture";
1
+ import { attachEvents } from '../eventAttacher';
2
+ import { Vector2 } from '../types';
3
+ import { clamp } from '../math';
4
+ import { withDefault } from '../withDefault';
5
+ import { Gesture } from './Gesture';
6
6
 
7
7
  export class MouseMoveGesture extends Gesture {
8
8
  event?: MouseEvent;
@@ -18,16 +18,16 @@ export class MouseMoveGesture extends Gesture {
18
18
  if (this.targetElement) {
19
19
  this._subscribe = attachEvents(
20
20
  [this.targetElement],
21
- [["mousemove", this.onMouseMove.bind(this)]]
21
+ [['mousemove', this.onMouseMove.bind(this)]]
22
22
  );
23
23
  } else if (this.targetElements.length > 0) {
24
24
  this._subscribe = attachEvents(this.targetElements, [
25
- ["mousemove", this.onMouseMove.bind(this)],
25
+ ['mousemove', this.onMouseMove.bind(this)],
26
26
  ]);
27
27
  } else {
28
28
  this._subscribe = attachEvents(
29
29
  [window],
30
- [["mousemove", this.onMouseMove.bind(this)]]
30
+ [['mousemove', this.onMouseMove.bind(this)]]
31
31
  );
32
32
  }
33
33
  }
@@ -1,8 +1,8 @@
1
- import { attachEvents } from "../eventAttacher";
2
- import { Vector2 } from "../types";
3
- import { clamp } from "../math";
4
- import { withDefault } from "../withDefault";
5
- import { Gesture } from "./Gesture";
1
+ import { attachEvents } from '../eventAttacher';
2
+ import { Vector2 } from '../types';
3
+ import { clamp } from '../math';
4
+ import { withDefault } from '../withDefault';
5
+ import { Gesture } from './Gesture';
6
6
 
7
7
  export class ScrollGesture extends Gesture {
8
8
  isActiveID?: any;
@@ -17,12 +17,12 @@ export class ScrollGesture extends Gesture {
17
17
  if (this.targetElement) {
18
18
  this._subscribe = attachEvents(
19
19
  [this.targetElement],
20
- [["scroll", this.scrollElementListener.bind(this)]]
20
+ [['scroll', this.scrollElementListener.bind(this)]]
21
21
  );
22
22
  } else {
23
23
  this._subscribe = attachEvents(
24
24
  [window],
25
- [["scroll", this.scrollListener.bind(this)]]
25
+ [['scroll', this.scrollListener.bind(this)]]
26
26
  );
27
27
  }
28
28
  }
@@ -1,8 +1,8 @@
1
- import { attachEvents } from "../eventAttacher";
2
- import { Vector2 } from "../types";
3
- import { clamp } from "../math";
4
- import { withDefault } from "../withDefault";
5
- import { Gesture } from "./Gesture";
1
+ import { attachEvents } from '../eventAttacher';
2
+ import { Vector2 } from '../types';
3
+ import { clamp } from '../math';
4
+ import { withDefault } from '../withDefault';
5
+ import { Gesture } from './Gesture';
6
6
 
7
7
  const LINE_HEIGHT = 40;
8
8
  const PAGE_HEIGHT = 800;
@@ -25,7 +25,7 @@ export class WheelGesture extends Gesture {
25
25
  if (this.targetElement) {
26
26
  this._subscribe = attachEvents(
27
27
  [this.targetElement],
28
- [["wheel", this.onWheel.bind(this)]]
28
+ [['wheel', this.onWheel.bind(this)]]
29
29
  );
30
30
  }
31
31
  }
@@ -1,4 +1,4 @@
1
- export * from "./DragGesture";
2
- export * from "./MouseMoveGesture";
3
- export * from "./ScrollGesture";
4
- export * from "./WheelGesture";
1
+ export * from './DragGesture';
2
+ export * from './MouseMoveGesture';
3
+ export * from './ScrollGesture';
4
+ export * from './WheelGesture';
@@ -1,19 +1,19 @@
1
1
  type MouseEventType =
2
- | "click"
3
- | "dblclick"
4
- | "mousedown"
5
- | "mousemove"
6
- | "mouseup"
7
- | "touchstart"
8
- | "touchmove"
9
- | "touchend"
10
- | "mouseenter"
11
- | "mouseleave"
12
- | "mouseout"
13
- | "mouseover"
14
- | "scroll"
15
- | "wheel"
16
- | "contextmenu";
2
+ | 'click'
3
+ | 'dblclick'
4
+ | 'mousedown'
5
+ | 'mousemove'
6
+ | 'mouseup'
7
+ | 'touchstart'
8
+ | 'touchmove'
9
+ | 'touchend'
10
+ | 'mouseenter'
11
+ | 'mouseleave'
12
+ | 'mouseout'
13
+ | 'mouseover'
14
+ | 'scroll'
15
+ | 'wheel'
16
+ | 'contextmenu';
17
17
 
18
18
  type DomTargetTypes = Array<Window | Document | HTMLElement>;
19
19
 
@@ -1,5 +1,5 @@
1
- export * from "./useDrag";
2
- export * from "./useMouseMove";
3
- export * from "./useScroll";
4
- export * from "./useWheel";
5
- export * from "./useGesture";
1
+ export * from './useDrag';
2
+ export * from './useMouseMove';
3
+ export * from './useScroll';
4
+ export * from './useWheel';
5
+ export * from './useGesture';
@@ -1,8 +1,8 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
 
3
- import { DragEventType, UseDragConfig } from "../types";
4
- import { DragGesture } from "../controllers";
5
- import { useRecognizer } from "./useRecognizer";
3
+ import { DragEventType, UseDragConfig } from '../types';
4
+ import { DragGesture } from '../controllers';
5
+ import { useRecognizer } from './useRecognizer';
6
6
 
7
7
  export function useDrag(
8
8
  callback: (event: DragEventType) => void,
@@ -10,5 +10,5 @@ export function useDrag(
10
10
  ) {
11
11
  const gesture = React.useRef(new DragGesture()).current;
12
12
 
13
- return useRecognizer([["drag", gesture, callback, config]]);
13
+ return useRecognizer([['drag', gesture, callback, config]]);
14
14
  }
@@ -1,17 +1,17 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
  import {
3
3
  DragGesture,
4
4
  MouseMoveGesture,
5
5
  ScrollGesture,
6
6
  WheelGesture,
7
- } from "../controllers";
7
+ } from '../controllers';
8
8
  import {
9
9
  DragEventType,
10
10
  WheelEventType,
11
11
  ScrollEventType,
12
12
  MouseMoveEventType,
13
- } from "../types";
14
- import { useRecognizer } from "./useRecognizer";
13
+ } from '../types';
14
+ import { useRecognizer } from './useRecognizer';
15
15
 
16
16
  export function useGesture({
17
17
  onDrag,
@@ -30,9 +30,9 @@ export function useGesture({
30
30
  const mouseMoveGesture = React.useRef(new MouseMoveGesture()).current;
31
31
 
32
32
  return useRecognizer([
33
- ["drag", dragGesture, onDrag],
34
- ["wheel", wheelGesture, onWheel],
35
- ["scroll", scrollGesture, onScroll],
36
- ["move", mouseMoveGesture, onMouseMove],
33
+ ['drag', dragGesture, onDrag],
34
+ ['wheel', wheelGesture, onWheel],
35
+ ['scroll', scrollGesture, onScroll],
36
+ ['move', mouseMoveGesture, onMouseMove],
37
37
  ]);
38
38
  }
@@ -1,11 +1,11 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
 
3
- import { MouseMoveEventType } from "../types";
4
- import { MouseMoveGesture } from "../controllers";
5
- import { useRecognizer } from "./useRecognizer";
3
+ import { MouseMoveEventType } from '../types';
4
+ import { MouseMoveGesture } from '../controllers';
5
+ import { useRecognizer } from './useRecognizer';
6
6
 
7
7
  export function useMouseMove(callback: (event: MouseMoveEventType) => void) {
8
8
  const gesture = React.useRef(new MouseMoveGesture()).current;
9
9
 
10
- return useRecognizer([["move", gesture, callback]]);
10
+ return useRecognizer([['move', gesture, callback]]);
11
11
  }
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
- import * as React from "react";
2
+ import * as React from 'react';
3
3
 
4
4
  type UseRecognizerHandlerType = Array<
5
5
  [
6
- key: "drag" | "wheel" | "move" | "scroll",
6
+ key: 'drag' | 'wheel' | 'move' | 'scroll',
7
7
  gesture: any,
8
8
  callback: any,
9
9
  config?: any
@@ -1,11 +1,11 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
 
3
- import { ScrollEventType } from "../types";
4
- import { ScrollGesture } from "../controllers";
5
- import { useRecognizer } from "./useRecognizer";
3
+ import { ScrollEventType } from '../types';
4
+ import { ScrollGesture } from '../controllers';
5
+ import { useRecognizer } from './useRecognizer';
6
6
 
7
7
  export function useScroll(callback: (event: ScrollEventType) => void) {
8
8
  const gesture = React.useRef(new ScrollGesture()).current;
9
9
 
10
- return useRecognizer([["scroll", gesture, callback]]);
10
+ return useRecognizer([['scroll', gesture, callback]]);
11
11
  }
@@ -1,11 +1,11 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
 
3
- import { WheelEventType } from "../types";
4
- import { WheelGesture } from "../controllers";
5
- import { useRecognizer } from "./useRecognizer";
3
+ import { WheelEventType } from '../types';
4
+ import { WheelGesture } from '../controllers';
5
+ import { useRecognizer } from './useRecognizer';
6
6
 
7
7
  export function useWheel(callback: (event: WheelEventType) => void) {
8
8
  const gesture = React.useRef(new WheelGesture()).current;
9
9
 
10
- return useRecognizer([["wheel", gesture, callback]]);
10
+ return useRecognizer([['wheel', gesture, callback]]);
11
11
  }