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
@@ -1,2 +1,2 @@
1
- export * from "./hooks";
2
- export * from "./math";
1
+ export * from './hooks';
2
+ export * from './math';
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { Easing } from "@raidipesh78/re-motion";
2
- export * from "./animation";
3
- export * from "./gestures";
4
- export * from "./hooks";
1
+ export { Easing, makeAnimatedComponent } from '@raidipesh78/re-motion';
2
+ export { delay } from './utils';
3
+ export * from './animation';
4
+ export * from './gestures';
5
+ export * from './hooks';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @param { number } ms - number of milliseconds to delay code execution
3
+ * @returns Promise
4
+ */
5
+ export function delay(ms: number) {
6
+ return new Promise((resolve) => {
7
+ setTimeout(() => resolve(null), ms);
8
+ });
9
+ }
@@ -1 +1,2 @@
1
- export * from "./isDefined";
1
+ export * from './isDefined';
2
+ export * from './delay';
@@ -1,47 +0,0 @@
1
- import * as React from "react";
2
- import { TransitionValue } from "@raidipesh78/re-motion";
3
- import { UseAnimatedValueConfig } from "./useAnimatedValue";
4
- import { InnerUseMountedValueConfig } from "./useMountedValue";
5
- /**
6
- * Make any component animatable
7
- */
8
- export declare function makeAnimatedComponent(WrappedComponent: React.ElementType<any>): React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
9
- /**
10
- * AnimatedBlock : Animated Div
11
- */
12
- export declare const AnimatedBlock: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
13
- /**
14
- * AnimatedInline : Animated Span
15
- */
16
- export declare const AnimatedInline: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
17
- /**
18
- * AnimatedImage : Animated Image
19
- */
20
- export declare const AnimatedImage: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
21
- interface ScrollableBlockProps {
22
- children?: (animation: any) => React.ReactNode;
23
- direction?: "single" | "both";
24
- threshold?: number;
25
- animationConfig?: UseAnimatedValueConfig;
26
- }
27
- /**
28
- * ScrollableBlock
29
- * Used to animate element when enter into viewport
30
- * Render props pattern with children accepts animation node
31
- * animated value goes from 0 to 1 when appear on viewport & vice versa.
32
- */
33
- export declare const ScrollableBlock: React.FC<ScrollableBlockProps>;
34
- interface MountedBlockProps {
35
- state: boolean;
36
- children: (animation: {
37
- value: TransitionValue;
38
- }) => React.ReactNode;
39
- config?: InnerUseMountedValueConfig;
40
- }
41
- /**
42
- * MountedBlock handles mounting and unmounting of a component
43
- * @props - state: boolean, config: InnerUseMountedValueConfig
44
- * @children - (animation: { value: TransitionValue }) => React.ReactNode
45
- */
46
- export declare const MountedBlock: ({ state, children, config, }: MountedBlockProps) => JSX.Element;
47
- export {};
@@ -1,105 +0,0 @@
1
- import * as React from "react";
2
- import {
3
- makeAnimatedComponent as animated,
4
- TransitionValue,
5
- } from "@raidipesh78/re-motion";
6
- import { useAnimatedValue, UseAnimatedValueConfig } from "./useAnimatedValue";
7
- import { useMountedValue, InnerUseMountedValueConfig } from "./useMountedValue";
8
-
9
- /**
10
- * Make any component animatable
11
- */
12
- export function makeAnimatedComponent(
13
- WrappedComponent: React.ElementType<any>
14
- ) {
15
- return animated(WrappedComponent);
16
- }
17
-
18
- /**
19
- * AnimatedBlock : Animated Div
20
- */
21
- export const AnimatedBlock = animated("div");
22
- /**
23
- * AnimatedInline : Animated Span
24
- */
25
- export const AnimatedInline = animated("span");
26
- /**
27
- * AnimatedImage : Animated Image
28
- */
29
- export const AnimatedImage = animated("img");
30
- interface ScrollableBlockProps {
31
- children?: (animation: any) => React.ReactNode;
32
- direction?: "single" | "both";
33
- threshold?: number;
34
- animationConfig?: UseAnimatedValueConfig;
35
- }
36
-
37
- /**
38
- * ScrollableBlock
39
- * Used to animate element when enter into viewport
40
- * Render props pattern with children accepts animation node
41
- * animated value goes from 0 to 1 when appear on viewport & vice versa.
42
- */
43
- export const ScrollableBlock: React.FC<ScrollableBlockProps> = (props) => {
44
- const {
45
- children,
46
- direction = "single",
47
- animationConfig,
48
- threshold = 0.2,
49
- } = props;
50
- const scrollableBlockRef = React.useRef<HTMLDivElement>(null);
51
- const animation = useAnimatedValue(0, animationConfig); // 0: not intersecting | 1: intersecting
52
-
53
- React.useEffect(() => {
54
- const _scrollableBlock = scrollableBlockRef.current;
55
-
56
- const observer = new IntersectionObserver(
57
- function ([entry]) {
58
- const { isIntersecting } = entry;
59
-
60
- if (isIntersecting) {
61
- animation.value = 1;
62
- } else {
63
- if (direction === "both") animation.value = 0;
64
- }
65
- },
66
- {
67
- root: null, // FOR VIEWPORT ONLY
68
- threshold,
69
- }
70
- );
71
-
72
- if (_scrollableBlock) {
73
- observer.observe(_scrollableBlock);
74
- }
75
-
76
- return () => {
77
- if (_scrollableBlock) {
78
- observer.unobserve(_scrollableBlock);
79
- }
80
- };
81
- }, []);
82
-
83
- return <div ref={scrollableBlockRef}>{children && children(animation)}</div>;
84
- };
85
-
86
- interface MountedBlockProps {
87
- state: boolean;
88
- children: (animation: { value: TransitionValue }) => React.ReactNode;
89
- config?: InnerUseMountedValueConfig;
90
- }
91
-
92
- /**
93
- * MountedBlock handles mounting and unmounting of a component
94
- * @props - state: boolean, config: InnerUseMountedValueConfig
95
- * @children - (animation: { value: TransitionValue }) => React.ReactNode
96
- */
97
- export const MountedBlock = ({
98
- state,
99
- children,
100
- config,
101
- }: MountedBlockProps) => {
102
- const open = useMountedValue(state, { from: 0, enter: 1, exit: 0, config });
103
-
104
- return <>{open((animation, mounted) => mounted && children(animation))}</>;
105
- };