react-ui-animate 2.0.0-rc.7 → 3.0.0-rc.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 (222) hide show
  1. package/.vscode/settings.json +3 -3
  2. package/LICENSE +21 -21
  3. package/README.md +115 -115
  4. package/dist/animation/animationType.d.ts +15 -15
  5. package/dist/animation/core/animation/Animation.d.ts +16 -0
  6. package/dist/animation/core/animation/FluidValue.d.ts +21 -0
  7. package/dist/animation/core/animation/RequestAnimationFrame.d.ts +8 -0
  8. package/dist/animation/core/animation/SpringAnimation.d.ts +41 -0
  9. package/dist/animation/core/animation/TimingAnimation.d.ts +35 -0
  10. package/dist/animation/core/animation/TransitionValue.d.ts +21 -0
  11. package/dist/animation/core/controllers/Animation.d.ts +16 -0
  12. package/dist/animation/core/controllers/FluidValue.d.ts +32 -0
  13. package/dist/animation/core/controllers/RequestAnimationFrame.d.ts +8 -0
  14. package/dist/animation/core/controllers/SpringAnimation.d.ts +41 -0
  15. package/dist/animation/core/controllers/TimingAnimation.d.ts +35 -0
  16. package/dist/animation/core/easing/Bezier.d.ts +8 -0
  17. package/dist/animation/core/easing/Easing.d.ts +40 -0
  18. package/dist/animation/core/helpers/camelCaseToKebabCase.d.ts +8 -0
  19. package/dist/animation/core/helpers/camelToDash.d.ts +7 -0
  20. package/dist/animation/core/helpers/canInterpolate.d.ts +11 -0
  21. package/dist/animation/core/helpers/getAnimatableObject.d.ts +22 -0
  22. package/dist/animation/core/helpers/getCleanProps.d.ts +10 -0
  23. package/dist/animation/core/helpers/getCssValue.d.ts +8 -0
  24. package/dist/animation/core/helpers/getNonAnimatableStyle.d.ts +6 -0
  25. package/dist/animation/core/helpers/index.d.ts +5 -0
  26. package/dist/animation/core/helpers/isDefined.d.ts +12 -0
  27. package/dist/animation/core/helpers/isFluidValue.d.ts +6 -0
  28. package/dist/animation/core/index.d.ts +11 -0
  29. package/dist/animation/core/interpolation/Colors.d.ts +25 -0
  30. package/dist/animation/core/interpolation/Interpolation.d.ts +80 -0
  31. package/dist/animation/core/interpolation/__tests__/Colors.test.d.ts +1 -0
  32. package/dist/animation/core/react/Tags.d.ts +3 -0
  33. package/dist/animation/core/react/TransformStyles.d.ts +8 -0
  34. package/dist/animation/core/react/animated.d.ts +29 -0
  35. package/dist/animation/core/react/combineRefs.d.ts +2 -0
  36. package/dist/animation/core/react/fluid.d.ts +6 -0
  37. package/dist/animation/core/react/functions/camelToDash.d.ts +7 -0
  38. package/dist/animation/core/react/functions/getAnimatableObject.d.ts +22 -0
  39. package/dist/animation/core/react/functions/getCleanProps.d.ts +4 -0
  40. package/dist/animation/core/react/functions/getCssValue.d.ts +8 -0
  41. package/dist/animation/core/react/functions/getNonAnimatableStyle.d.ts +6 -0
  42. package/dist/animation/core/react/functions/index.d.ts +7 -0
  43. package/dist/animation/core/react/functions/isDefined.d.ts +6 -0
  44. package/dist/animation/core/react/functions/isTransitionValue.d.ts +6 -0
  45. package/dist/animation/core/react/helpers/camelToDash.d.ts +7 -0
  46. package/dist/animation/core/react/helpers/canInterpolate.d.ts +7 -0
  47. package/dist/animation/core/react/helpers/getAnimatableObject.d.ts +22 -0
  48. package/dist/animation/core/react/helpers/getCleanProps.d.ts +4 -0
  49. package/dist/animation/core/react/helpers/getCssValue.d.ts +8 -0
  50. package/dist/animation/core/react/helpers/getNonAnimatableStyle.d.ts +6 -0
  51. package/dist/animation/core/react/helpers/index.d.ts +7 -0
  52. package/dist/animation/core/react/helpers/isDefined.d.ts +6 -0
  53. package/dist/animation/core/react/helpers/isFluidValue.d.ts +6 -0
  54. package/dist/animation/core/react/helpers/isTransitionValue.d.ts +6 -0
  55. package/dist/animation/core/react/makeFluid.d.ts +30 -0
  56. package/dist/animation/core/react/transforms.d.ts +6 -0
  57. package/dist/animation/core/react/useFluidValue.d.ts +9 -0
  58. package/dist/animation/core/react/useMount.d.ts +20 -0
  59. package/dist/animation/core/react/useMounts.d.ts +26 -0
  60. package/dist/animation/core/react/useTransition.d.ts +9 -0
  61. package/dist/animation/core/react/useTransitions.d.ts +11 -0
  62. package/dist/animation/core/types/animation.d.ts +54 -0
  63. package/dist/animation/core/types/common.d.ts +4 -0
  64. package/dist/animation/core/types/fluid.d.ts +19 -0
  65. package/dist/animation/core/types/index.d.ts +2 -0
  66. package/dist/animation/getInitialConfig.d.ts +3 -3
  67. package/dist/animation/index.d.ts +6 -6
  68. package/dist/animation/interpolation.d.ts +21 -21
  69. package/dist/animation/lib/animationType.d.ts +15 -0
  70. package/dist/animation/lib/getInitialConfig.d.ts +3 -0
  71. package/dist/animation/lib/index.d.ts +5 -0
  72. package/dist/animation/lib/interpolation.d.ts +20 -0
  73. package/dist/animation/lib/modules/AnimatedBlock.d.ts +8 -0
  74. package/dist/animation/lib/modules/AnimatedImage.d.ts +8 -0
  75. package/dist/animation/lib/modules/AnimatedInline.d.ts +8 -0
  76. package/dist/animation/lib/modules/MountedBlock.d.ts +29 -0
  77. package/dist/animation/lib/modules/ScrollableBlock.d.ts +22 -0
  78. package/dist/animation/lib/modules/TransitionBlock.d.ts +18 -0
  79. package/dist/animation/lib/modules/index.d.ts +6 -0
  80. package/dist/animation/lib/useAnimatedValue.d.ts +17 -0
  81. package/dist/animation/lib/useMountedValue.d.ts +14 -0
  82. package/dist/animation/modules/AnimatedBlock.d.ts +8 -8
  83. package/dist/animation/modules/AnimatedImage.d.ts +8 -8
  84. package/dist/animation/modules/AnimatedInline.d.ts +8 -8
  85. package/dist/animation/modules/MountedBlock.d.ts +29 -18
  86. package/dist/animation/modules/ScrollableBlock.d.ts +21 -21
  87. package/dist/animation/modules/TransitionBlock.d.ts +17 -17
  88. package/dist/animation/modules/index.d.ts +6 -6
  89. package/dist/animation/useAnimatedValue.d.ts +22 -22
  90. package/dist/animation/useMountedValue.d.ts +15 -15
  91. package/dist/gestures/controllers/DragGesture.d.ts +17 -17
  92. package/dist/gestures/controllers/Gesture.d.ts +20 -20
  93. package/dist/gestures/controllers/MouseMoveGesture.d.ts +13 -13
  94. package/dist/gestures/controllers/ScrollGesture.d.ts +14 -14
  95. package/dist/gestures/controllers/WheelGesture.d.ts +15 -15
  96. package/dist/gestures/controllers/index.d.ts +4 -4
  97. package/dist/gestures/eventAttacher.d.ts +11 -11
  98. package/dist/gestures/helpers/eventAttacher.d.ts +11 -0
  99. package/dist/gestures/helpers/index.d.ts +1 -0
  100. package/dist/gestures/helpers/math.d.ts +34 -0
  101. package/dist/gestures/helpers/withDefault.d.ts +4 -0
  102. package/dist/gestures/hooks/index.d.ts +5 -5
  103. package/dist/gestures/hooks/useDrag.d.ts +4 -4
  104. package/dist/gestures/hooks/useGesture.d.ts +9 -9
  105. package/dist/gestures/hooks/useMouseMove.d.ts +4 -4
  106. package/dist/gestures/hooks/useRecognizer.d.ts +10 -10
  107. package/dist/gestures/hooks/useScroll.d.ts +4 -4
  108. package/dist/gestures/hooks/useWheel.d.ts +4 -4
  109. package/dist/gestures/index.d.ts +2 -2
  110. package/dist/gestures/math.d.ts +34 -34
  111. package/dist/gestures/types.d.ts +51 -51
  112. package/dist/gestures/withDefault.d.ts +4 -4
  113. package/dist/hooks/index.d.ts +3 -3
  114. package/dist/hooks/useMeasure.d.ts +14 -14
  115. package/dist/hooks/useOutsideClick.d.ts +2 -2
  116. package/dist/hooks/useWindowDimension.d.ts +9 -9
  117. package/dist/index.d.ts +9 -5
  118. package/dist/index.js +2758 -1052
  119. package/dist/index.js.map +1 -1
  120. package/dist/utils/delay.d.ts +5 -5
  121. package/dist/utils/index.d.ts +1 -2
  122. package/dist/utils/isDefined.d.ts +1 -1
  123. package/ecosystem.config.js +12 -0
  124. package/example/README.md +46 -0
  125. package/example/package-lock.json +19597 -0
  126. package/example/package.json +45 -0
  127. package/example/public/favicon.ico +0 -0
  128. package/example/public/index.html +20 -0
  129. package/example/public/logo192.png +0 -0
  130. package/example/public/logo512.png +0 -0
  131. package/example/public/manifest.json +25 -0
  132. package/example/public/robots.txt +3 -0
  133. package/example/src/App.tsx +41 -0
  134. package/example/src/components/Draggable.tsx +46 -0
  135. package/example/src/components/Gestures.tsx +151 -0
  136. package/example/src/components/Interpolation.tsx +21 -0
  137. package/example/src/components/Loop.tsx +48 -0
  138. package/example/src/components/MountedBlock.tsx +25 -0
  139. package/example/src/components/MouseMove.tsx +59 -0
  140. package/example/src/components/MultistageTransition.tsx +34 -0
  141. package/example/src/components/Scroll.tsx +39 -0
  142. package/example/src/components/ScrollableBlock.tsx +27 -0
  143. package/example/src/components/SnapTo.tsx +55 -0
  144. package/example/src/components/TransitionBlock.tsx +37 -0
  145. package/example/src/components/Wheel.tsx +39 -0
  146. package/example/src/components/index.ts +18 -0
  147. package/example/src/components/svgLine.tsx +48 -0
  148. package/example/src/components/useAnimatedValue.tsx +57 -0
  149. package/example/src/components/useMountedValue.tsx +62 -0
  150. package/example/src/index.css +8 -0
  151. package/example/src/index.tsx +16 -0
  152. package/example/tsconfig.json +26 -0
  153. package/package.json +48 -48
  154. package/{rollup.config.js → rollup.config.mjs} +18 -18
  155. package/src/animation/core/controllers/Animation.ts +27 -0
  156. package/src/animation/core/controllers/FluidValue.ts +97 -0
  157. package/src/animation/core/controllers/RequestAnimationFrame.ts +13 -0
  158. package/src/animation/core/controllers/SpringAnimation.ts +218 -0
  159. package/src/animation/core/controllers/TimingAnimation.ts +152 -0
  160. package/src/animation/core/easing/Bezier.ts +146 -0
  161. package/src/animation/core/easing/Easing.ts +132 -0
  162. package/src/animation/core/helpers/camelCaseToKebabCase.ts +10 -0
  163. package/src/animation/core/helpers/getCleanProps.ts +16 -0
  164. package/src/animation/core/helpers/getCssValue.ts +60 -0
  165. package/src/animation/core/helpers/index.ts +5 -0
  166. package/src/animation/core/helpers/isDefined.ts +14 -0
  167. package/src/animation/core/helpers/isFluidValue.ts +11 -0
  168. package/src/animation/core/index.ts +16 -0
  169. package/src/animation/core/interpolation/Colors.ts +232 -0
  170. package/src/animation/core/interpolation/Interpolation.ts +395 -0
  171. package/src/animation/core/interpolation/__tests__/Colors.test.tsx +35 -0
  172. package/src/animation/core/react/fluid.ts +197 -0
  173. package/src/animation/core/react/makeFluid.ts +294 -0
  174. package/src/animation/core/react/transforms.ts +90 -0
  175. package/src/animation/core/react/useFluidValue.ts +43 -0
  176. package/src/animation/core/react/useMount.ts +58 -0
  177. package/src/animation/core/types/animation.d.ts +56 -0
  178. package/src/animation/core/types/common.d.ts +4 -0
  179. package/src/animation/core/types/fluid.d.ts +38 -0
  180. package/src/animation/{animationType.ts → lib/animationType.ts} +17 -17
  181. package/src/animation/{getInitialConfig.ts → lib/getInitialConfig.ts} +61 -61
  182. package/src/animation/lib/index.ts +12 -0
  183. package/src/animation/{interpolation.ts → lib/interpolation.ts} +47 -48
  184. package/src/animation/{modules → lib/modules}/AnimatedBlock.ts +8 -8
  185. package/src/animation/{modules → lib/modules}/AnimatedImage.ts +8 -8
  186. package/src/animation/{modules → lib/modules}/AnimatedInline.ts +8 -8
  187. package/src/animation/lib/modules/MountedBlock.tsx +51 -0
  188. package/src/animation/{modules → lib/modules}/ScrollableBlock.tsx +68 -69
  189. package/src/animation/{modules → lib/modules}/TransitionBlock.tsx +28 -29
  190. package/src/animation/{modules → lib/modules}/index.ts +6 -6
  191. package/src/animation/{useAnimatedValue.ts → lib/useAnimatedValue.ts} +60 -71
  192. package/src/animation/{useMountedValue.ts → lib/useMountedValue.ts} +18 -19
  193. package/src/gestures/controllers/DragGesture.ts +178 -177
  194. package/src/gestures/controllers/Gesture.ts +54 -54
  195. package/src/gestures/controllers/MouseMoveGesture.ts +111 -111
  196. package/src/gestures/controllers/ScrollGesture.ts +107 -107
  197. package/src/gestures/controllers/WheelGesture.ts +123 -123
  198. package/src/gestures/controllers/index.ts +4 -4
  199. package/src/gestures/{eventAttacher.ts → helpers/eventAttacher.ts} +67 -67
  200. package/src/gestures/helpers/index.ts +1 -0
  201. package/src/gestures/{math.ts → helpers/math.ts} +120 -120
  202. package/src/gestures/{withDefault.ts → helpers/withDefault.ts} +3 -3
  203. package/src/gestures/hooks/index.ts +5 -5
  204. package/src/gestures/hooks/useDrag.ts +14 -14
  205. package/src/gestures/hooks/useGesture.ts +38 -38
  206. package/src/gestures/hooks/useMouseMove.ts +11 -11
  207. package/src/gestures/hooks/useRecognizer.ts +59 -59
  208. package/src/gestures/hooks/useScroll.ts +11 -11
  209. package/src/gestures/hooks/useWheel.ts +11 -11
  210. package/src/gestures/{types.ts → types/index.d.ts} +49 -49
  211. package/src/hooks/index.ts +3 -3
  212. package/src/hooks/useMeasure.ts +132 -133
  213. package/src/hooks/useOutsideClick.ts +36 -36
  214. package/src/hooks/useWindowDimension.ts +58 -59
  215. package/src/index.ts +42 -5
  216. package/src/utils/delay.ts +9 -9
  217. package/src/utils/index.ts +1 -2
  218. package/tsconfig.json +24 -25
  219. package/src/animation/index.ts +0 -10
  220. package/src/animation/modules/MountedBlock.tsx +0 -25
  221. package/src/gestures/index.ts +0 -2
  222. package/src/utils/isDefined.ts +0 -4
@@ -1,3 +1,3 @@
1
- {
2
- "compile-hero.disable-compile-files-on-did-save-code": false
3
- }
1
+ {
2
+ "compile-hero.disable-compile-files-on-did-save-code": false
3
+ }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Dipesh Rai
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Dipesh Rai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,115 +1,115 @@
1
- # React UI Animate
2
-
3
- [![npm version](https://badge.fury.io/js/react-ui-animate.svg)](https://badge.fury.io/js/react-ui-animate)
4
-
5
- > React library for gestures and animation
6
-
7
- ### Install
8
-
9
- Install with npm:
10
-
11
- ```sh
12
- npm i react-ui-animate
13
- ```
14
-
15
- or
16
- Install with yarn:
17
-
18
- ```sh
19
- yarn add react-ui-animate
20
- ```
21
-
22
- ### Getting Started
23
-
24
- `react-ui-animate` provides lots of easy to use APIs to create smooth animations and gestures.
25
-
26
- ```javascript
27
- import { AnimatedBlock, useAnimatedValue } from "react-ui-animate";
28
-
29
- export default function () {
30
- const opacity = useAnimatedValue(0); // It initializes opacity object with value 0.
31
-
32
- return (
33
- <div>
34
- {/* AnimatedBlock component can read useAnimatedValue() */}
35
- <AnimatedBlock
36
- style={{
37
- opacity: opacity.value, // using opacity with value property
38
- width: 100,
39
- padding: 20,
40
- background: "#39F",
41
- }}
42
- >
43
- ANIMATED
44
- </AnimatedBlock>
45
-
46
- {/* Assigning value to 1 auto animates from initialized value 0 to 1 smoothly */}
47
- <button onClick={() => (opacity.value = 1)}>Animate Me</button>
48
- </div>
49
- );
50
- }
51
- ```
52
-
53
- Animates opacity from 0 to 1.
54
-
55
- #### `useAnimatedValue()`
56
-
57
- `useAnimatedValue()` is very flexible and powerful hook that lets you define animated values. It accepts a value and returns a node with same value on `value` property. Whenever `value` property is assigned to another value, it auto animates from one value to another.
58
-
59
- ```javascript
60
- const opacity = useAnimatedValue(0); // initialize with 0 opacity
61
-
62
- ...
63
- style={{
64
- opacity: opacity.value // access with `.value`
65
- }}
66
- ...
67
-
68
- ...
69
- onClick={() => opacity.value = 1} // Assignment
70
- ...
71
- ```
72
-
73
- #### `AnimatedBlock`
74
-
75
- `AnimatedBlock` is a `div` component which can accept the animation node from `useAnimatedValue()` hook.
76
-
77
- ```javascript
78
- const width = useAnimatedValue(100);
79
-
80
- <AnimatedBlock
81
- style={{
82
- width: width.value,
83
- height: 100,
84
- backgroundColor: "#39f",
85
- }}
86
- />;
87
- ```
88
-
89
- #### `interpolate`
90
-
91
- The `interpolate()` function allows animated node value to map from input ranges to different output ranges. By default, it will extrapolate the curve beyond the ranges given, but you can also have it clamp the output value.
92
-
93
- ```javascript
94
- import { useAnimatedValue, AnimatedBlock, interpolate } from "react-ui-animate";
95
-
96
- const width = useAnimatedValue(100);
97
-
98
- <AnimatedBlock
99
- style={{
100
- width: width.value,
101
- height: 100,
102
- backgroundColor: interpolate(width.value, [100, 200], ["red", "blue"]),
103
- }}
104
- />;
105
- ```
106
-
107
- `backgroundColor` is interpolated from input range `[100, 200]` to output range `["red", "blue"]`. So, when the width changes from 100 to 200, `backgroundColor` will change from `red` to `blue`.
108
-
109
- ## Documentation
110
-
111
- The official documentation are now published at http://react-ui-animate.js.org/
112
-
113
- ## License
114
-
115
- MIT
1
+ # React UI Animate
2
+
3
+ [![npm version](https://badge.fury.io/js/react-ui-animate.svg)](https://badge.fury.io/js/react-ui-animate)
4
+
5
+ > React library for gestures and animation
6
+
7
+ ### Install
8
+
9
+ Install with npm:
10
+
11
+ ```sh
12
+ npm i react-ui-animate
13
+ ```
14
+
15
+ or
16
+ Install with yarn:
17
+
18
+ ```sh
19
+ yarn add react-ui-animate
20
+ ```
21
+
22
+ ### Getting Started
23
+
24
+ `react-ui-animate` provides lots of easy to use APIs to create smooth animations and gestures.
25
+
26
+ ```javascript
27
+ import { AnimatedBlock, useAnimatedValue } from "react-ui-animate";
28
+
29
+ export default function () {
30
+ const opacity = useAnimatedValue(0); // It initializes opacity object with value 0.
31
+
32
+ return (
33
+ <div>
34
+ {/* AnimatedBlock component can read useAnimatedValue() */}
35
+ <AnimatedBlock
36
+ style={{
37
+ opacity: opacity.value, // using opacity with value property
38
+ width: 100,
39
+ padding: 20,
40
+ background: "#39F",
41
+ }}
42
+ >
43
+ ANIMATED
44
+ </AnimatedBlock>
45
+
46
+ {/* Assigning value to 1 auto animates from initialized value 0 to 1 smoothly */}
47
+ <button onClick={() => (opacity.value = 1)}>Animate Me</button>
48
+ </div>
49
+ );
50
+ }
51
+ ```
52
+
53
+ Animates opacity from 0 to 1.
54
+
55
+ #### `useAnimatedValue()`
56
+
57
+ `useAnimatedValue()` is very flexible and powerful hook that lets you define animated values. It accepts a value and returns a node with same value on `value` property. Whenever `value` property is assigned to another value, it auto animates from one value to another.
58
+
59
+ ```javascript
60
+ const opacity = useAnimatedValue(0); // initialize with 0 opacity
61
+
62
+ ...
63
+ style={{
64
+ opacity: opacity.value // access with `.value`
65
+ }}
66
+ ...
67
+
68
+ ...
69
+ onClick={() => opacity.value = 1} // Assignment
70
+ ...
71
+ ```
72
+
73
+ #### `AnimatedBlock`
74
+
75
+ `AnimatedBlock` is a `div` component which can accept the animation node from `useAnimatedValue()` hook.
76
+
77
+ ```javascript
78
+ const width = useAnimatedValue(100);
79
+
80
+ <AnimatedBlock
81
+ style={{
82
+ width: width.value,
83
+ height: 100,
84
+ backgroundColor: "#39f",
85
+ }}
86
+ />;
87
+ ```
88
+
89
+ #### `interpolate`
90
+
91
+ The `interpolate()` function allows animated node value to map from input ranges to different output ranges. By default, it will extrapolate the curve beyond the ranges given, but you can also have it clamp the output value.
92
+
93
+ ```javascript
94
+ import { useAnimatedValue, AnimatedBlock, interpolate } from "react-ui-animate";
95
+
96
+ const width = useAnimatedValue(100);
97
+
98
+ <AnimatedBlock
99
+ style={{
100
+ width: width.value,
101
+ height: 100,
102
+ backgroundColor: interpolate(width.value, [100, 200], ["red", "blue"]),
103
+ }}
104
+ />;
105
+ ```
106
+
107
+ `backgroundColor` is interpolated from input range `[100, 200]` to output range `["red", "blue"]`. So, when the width changes from 100 to 200, `backgroundColor` will change from `red` to `blue`.
108
+
109
+ ## Documentation
110
+
111
+ The official documentation are now published at http://react-ui-animate.js.org/
112
+
113
+ ## License
114
+
115
+ MIT
@@ -1,15 +1,15 @@
1
- export declare const AnimationConfigUtils: {
2
- ELASTIC: import("@raidipesh78/re-motion").TransitionValueConfig;
3
- BOUNCE: import("@raidipesh78/re-motion").TransitionValueConfig;
4
- EASE: import("@raidipesh78/re-motion").TransitionValueConfig;
5
- STIFF: import("@raidipesh78/re-motion").TransitionValueConfig;
6
- WOOBLE: import("@raidipesh78/re-motion").TransitionValueConfig;
7
- EASE_IN: import("@raidipesh78/re-motion").TransitionValueConfig;
8
- EASE_OUT: import("@raidipesh78/re-motion").TransitionValueConfig;
9
- EASE_IN_OUT: import("@raidipesh78/re-motion").TransitionValueConfig;
10
- POWER1: import("@raidipesh78/re-motion").TransitionValueConfig;
11
- POWER2: import("@raidipesh78/re-motion").TransitionValueConfig;
12
- POWER3: import("@raidipesh78/re-motion").TransitionValueConfig;
13
- POWER4: import("@raidipesh78/re-motion").TransitionValueConfig;
14
- LINEAR: import("@raidipesh78/re-motion").TransitionValueConfig;
15
- };
1
+ export declare const AnimationConfigUtils: {
2
+ ELASTIC: import("./core").FluidValueConfig;
3
+ BOUNCE: import("./core").FluidValueConfig;
4
+ EASE: import("./core").FluidValueConfig;
5
+ STIFF: import("./core").FluidValueConfig;
6
+ WOOBLE: import("./core").FluidValueConfig;
7
+ EASE_IN: import("./core").FluidValueConfig;
8
+ EASE_OUT: import("./core").FluidValueConfig;
9
+ EASE_IN_OUT: import("./core").FluidValueConfig;
10
+ POWER1: import("./core").FluidValueConfig;
11
+ POWER2: import("./core").FluidValueConfig;
12
+ POWER3: import("./core").FluidValueConfig;
13
+ POWER4: import("./core").FluidValueConfig;
14
+ LINEAR: import("./core").FluidValueConfig;
15
+ };
@@ -0,0 +1,16 @@
1
+ import { ResultType } from '../types/animation';
2
+ /**
3
+ * Base Animation class
4
+ */
5
+ export declare class Animation {
6
+ _active: boolean;
7
+ _onEnd: any;
8
+ /**
9
+ * it is necessary to add _onRest function as well
10
+ * because _onEnd is always re-assigned with onUpdate callback
11
+ * so that _onRest function is not fired, so we have to duplicate it
12
+ */
13
+ _onRest?: any;
14
+ _debounceOnEnd(result: ResultType): void;
15
+ stop(): void;
16
+ }
@@ -0,0 +1,21 @@
1
+ import type { Length, ResultType, SubscribeFn, FluidValueConfig, OnUpdateFn, AssignValue } from '../types/animation';
2
+ import { Fn } from '../types/common';
3
+ export declare class FluidValue {
4
+ _subscribe: SubscribeFn;
5
+ _value: Length;
6
+ _config?: FluidValueConfig;
7
+ _currentValue: {
8
+ current: Length;
9
+ };
10
+ _subscriptions: Map<{
11
+ uuid: number;
12
+ property: string;
13
+ }, OnUpdateFn>;
14
+ get: () => Length;
15
+ constructor(initialValue: Length, config?: FluidValueConfig);
16
+ /**
17
+ * Animates from initial value to updated value, determines the transition type `multistage`
18
+ * or `singlestage` according to updatedValue
19
+ */
20
+ setValue(updatedValue: AssignValue, config?: FluidValueConfig, callback?: Fn<ResultType, void>): void;
21
+ }
@@ -0,0 +1,8 @@
1
+ export declare const RequestAnimationFrame: {
2
+ current: (cb: any) => number;
3
+ inject(injected: any): void;
4
+ };
5
+ export declare const CancelAnimationFrame: {
6
+ current: (id: any) => void;
7
+ inject(injected: any): void;
8
+ };
@@ -0,0 +1,41 @@
1
+ import { Animation } from './Animation';
2
+ import type { FluidValueConfig, ResultType } from '../types/animation';
3
+ /**
4
+ * Class implementing spring based animation
5
+ */
6
+ export declare class SpringAnimation extends Animation {
7
+ _overshootClamping: boolean;
8
+ _restDisplacementThreshold: number;
9
+ _restSpeedThreshold: number;
10
+ _initialVelocity?: number;
11
+ _lastVelocity: number;
12
+ _startPosition: number;
13
+ _lastPosition: number;
14
+ _position: number;
15
+ _fromValue: number;
16
+ _toValue: any;
17
+ _mass: number;
18
+ _tension: number;
19
+ _friction: number;
20
+ _lastTime: number;
21
+ _onFrame: (value: number) => void;
22
+ _animationFrame: any;
23
+ _timeout: any;
24
+ _delay: number;
25
+ _onRest?: (value: ResultType) => void;
26
+ _onChange?: (value: number) => void;
27
+ constructor({ initialPosition, config, }: {
28
+ initialPosition: number;
29
+ config?: Omit<FluidValueConfig, 'duration' | 'easing'>;
30
+ });
31
+ onChange(value: number): void;
32
+ onUpdate(): void;
33
+ stop(): void;
34
+ set(toValue: number): void;
35
+ start({ toValue, onFrame, previousAnimation, onEnd, }: {
36
+ toValue: number;
37
+ onFrame: (value: number) => void;
38
+ previousAnimation?: SpringAnimation;
39
+ onEnd?: (result: ResultType) => void;
40
+ }): void;
41
+ }
@@ -0,0 +1,35 @@
1
+ import { Animation } from './Animation';
2
+ import type { FluidValueConfig, ResultType } from '../types/animation';
3
+ /**
4
+ * Class implementing timing based animation
5
+ */
6
+ export declare class TimingAnimation extends Animation {
7
+ _startTime: number;
8
+ _fromValue: number;
9
+ _toValue: any;
10
+ _duration: number;
11
+ _easing: (value: number) => number;
12
+ _onFrame: (value: number) => void;
13
+ _animationFrame: any;
14
+ _timeout: any;
15
+ _lastPosition: number;
16
+ _position: number;
17
+ _delay: number;
18
+ _tempDuration: number;
19
+ _onRest?: (value: ResultType) => void;
20
+ _onChange?: (value: number) => void;
21
+ constructor({ initialPosition, config, }: {
22
+ initialPosition: number;
23
+ config?: Omit<FluidValueConfig, 'mass' | 'friction' | 'tension'>;
24
+ });
25
+ onChange(value: number): void;
26
+ onUpdate(): void;
27
+ stop(): void;
28
+ set(toValue: number): void;
29
+ start({ toValue, onFrame, previousAnimation, onEnd, }: {
30
+ toValue: number;
31
+ onFrame: (value: number) => void;
32
+ previousAnimation?: TimingAnimation;
33
+ onEnd?: (result: ResultType) => void;
34
+ }): void;
35
+ }
@@ -0,0 +1,21 @@
1
+ import type { Length, ResultType, SubscribeFn, TransitionValueConfig, OnUpdateFn, AssignValue } from '../types/animation';
2
+ import { Fn } from '../types/common';
3
+ export declare class TransitionValue {
4
+ _subscribe: SubscribeFn;
5
+ _value: Length;
6
+ _config?: TransitionValueConfig;
7
+ _currentValue: {
8
+ current: Length;
9
+ };
10
+ _subscriptions: Map<{
11
+ uuid: number;
12
+ property: string;
13
+ }, OnUpdateFn>;
14
+ get: () => Length;
15
+ constructor(initialValue: Length, config?: TransitionValueConfig);
16
+ /**
17
+ * Animates from initial value to updated value, determines the transition type `multistage`
18
+ * or `singlestage` according to updatedValue
19
+ */
20
+ setValue(updatedValue: AssignValue, config?: TransitionValueConfig, callback?: Fn<ResultType, void>): void;
21
+ }
@@ -0,0 +1,16 @@
1
+ import type { ResultType } from '../types/animation';
2
+ /**
3
+ * Base Animation class
4
+ */
5
+ export declare class Animation {
6
+ _active: boolean;
7
+ _onEnd: any;
8
+ /**
9
+ * it is necessary to add _onRest function as well
10
+ * because _onEnd is always re-assigned with onUpdate callback
11
+ * so that _onRest function is not fired, so we have to duplicate it
12
+ */
13
+ _onRest?: any;
14
+ _debounceOnEnd(result: ResultType): void;
15
+ stop(): void;
16
+ }
@@ -0,0 +1,32 @@
1
+ import type { Length, ResultType, SubscribeFn, FluidValueConfig, OnUpdateFn, AssignValue } from '../types/animation';
2
+ import type { Fn } from '../types/common';
3
+ /**
4
+ * Represents a fluid value that can animate between states.
5
+ */
6
+ export declare class FluidValue {
7
+ _subscribe: SubscribeFn;
8
+ _value: Length;
9
+ _config?: FluidValueConfig;
10
+ _currentValue: {
11
+ current: Length;
12
+ };
13
+ _subscriptions: Map<{
14
+ uuid: number;
15
+ property: string;
16
+ }, OnUpdateFn>;
17
+ get: () => Length;
18
+ /**
19
+ * Creates a new FluidValue instance.
20
+ * @param initialValue - The initial value of the fluid value.
21
+ * @param config - Optional configuration for the fluid value.
22
+ */
23
+ constructor(initialValue: Length, config?: FluidValueConfig);
24
+ /**
25
+ * Animates from the current value to the updated value.
26
+ * Determines whether to perform a multi-stage or single-stage transition.
27
+ * @param updatedValue - The value to animate to, or a function that defines a multi-stage transition.
28
+ * @param config - Optional configuration for the animation.
29
+ * @param callback - Optional callback to be called after the animation ends.
30
+ */
31
+ setValue(updatedValue: AssignValue, config?: FluidValueConfig, callback?: Fn<ResultType, void>): void;
32
+ }
@@ -0,0 +1,8 @@
1
+ export declare const RequestAnimationFrame: {
2
+ current: (cb: any) => number;
3
+ inject(injected: any): void;
4
+ };
5
+ export declare const CancelAnimationFrame: {
6
+ current: (id: any) => void;
7
+ inject(injected: any): void;
8
+ };
@@ -0,0 +1,41 @@
1
+ import { Animation } from './Animation';
2
+ import type { FluidValueConfig, ResultType } from '../types/animation';
3
+ /**
4
+ * Class implementing spring based animation
5
+ */
6
+ export declare class SpringAnimation extends Animation {
7
+ _overshootClamping: boolean;
8
+ _restDisplacementThreshold: number;
9
+ _restSpeedThreshold: number;
10
+ _initialVelocity?: number;
11
+ _lastVelocity: number;
12
+ _startPosition: number;
13
+ _lastPosition: number;
14
+ _position: number;
15
+ _fromValue: number;
16
+ _toValue: any;
17
+ _mass: number;
18
+ _tension: number;
19
+ _friction: number;
20
+ _lastTime: number;
21
+ _onFrame: (value: number) => void;
22
+ _animationFrame: any;
23
+ _timeout: any;
24
+ _delay: number;
25
+ _onRest?: (value: ResultType) => void;
26
+ _onChange?: (value: number) => void;
27
+ constructor({ initialPosition, config, }: {
28
+ initialPosition: number;
29
+ config?: Omit<FluidValueConfig, 'duration' | 'easing'>;
30
+ });
31
+ onChange(value: number): void;
32
+ onUpdate(): void;
33
+ stop(): void;
34
+ set(toValue: number): void;
35
+ start({ toValue, onFrame, previousAnimation, onEnd, }: {
36
+ toValue: number;
37
+ onFrame: (value: number) => void;
38
+ previousAnimation?: SpringAnimation;
39
+ onEnd?: (result: ResultType) => void;
40
+ }): void;
41
+ }
@@ -0,0 +1,35 @@
1
+ import { Animation } from './Animation';
2
+ import type { FluidValueConfig, ResultType } from '../types/animation';
3
+ /**
4
+ * Class implementing timing based animation
5
+ */
6
+ export declare class TimingAnimation extends Animation {
7
+ _startTime: number;
8
+ _fromValue: number;
9
+ _toValue: any;
10
+ _duration: number;
11
+ _easing: (value: number) => number;
12
+ _onFrame: (value: number) => void;
13
+ _animationFrame: any;
14
+ _timeout: any;
15
+ _lastPosition: number;
16
+ _position: number;
17
+ _delay: number;
18
+ _tempDuration: number;
19
+ _onRest?: (value: ResultType) => void;
20
+ _onChange?: (value: number) => void;
21
+ constructor({ initialPosition, config, }: {
22
+ initialPosition: number;
23
+ config?: Omit<FluidValueConfig, 'mass' | 'friction' | 'tension'>;
24
+ });
25
+ onChange(value: number): void;
26
+ onUpdate(): void;
27
+ stop(): void;
28
+ set(toValue: number): void;
29
+ start({ toValue, onFrame, previousAnimation, onEnd, }: {
30
+ toValue: number;
31
+ onFrame: (value: number) => void;
32
+ previousAnimation?: TimingAnimation;
33
+ onEnd?: (result: ResultType) => void;
34
+ }): void;
35
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * https://github.com/gre/bezier-easing
3
+ * BezierEasing - use bezier curve for transition easing function
4
+ * by Gaëtan Renaudeau 2014 - 2015 – MIT License
5
+ */
6
+ declare function LinearEasing(x: number): number;
7
+ declare function bezier(mX1: number, mY1: number, mX2: number, mY2: number): typeof LinearEasing;
8
+ export { bezier };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * This class implements common easing functions. The math is pretty obscure,
3
+ * but this cool website has nice visual illustrations of what they represent:
4
+ * http://xaedes.de/dev/transitions/
5
+ */
6
+ export declare class Easing {
7
+ static step0(n: number): 0 | 1;
8
+ static step1(n: number): 0 | 1;
9
+ static linear(t: number): number;
10
+ static ease(t: number): number;
11
+ static quad(t: number): number;
12
+ static cubic(t: number): number;
13
+ static poly(n: number): (t: number) => number;
14
+ static sin(t: number): number;
15
+ static circle(t: number): number;
16
+ static exp(t: number): number;
17
+ /**
18
+ * A simple elastic interaction, similar to a spring. Default bounciness
19
+ * is 1, which overshoots a little bit once. 0 bounciness doesn't overshoot
20
+ * at all, and bounciness of N > 1 will overshoot about N times.
21
+ *
22
+ * Wolfram Plots:
23
+ *
24
+ * http://tiny.cc/elastic_b_1 (default bounciness = 1)
25
+ * http://tiny.cc/elastic_b_3 (bounciness = 3)
26
+ */
27
+ static elastic(bounciness?: number): (t: number) => number;
28
+ static back(s: number): (t: number) => number;
29
+ static bounce(t: number): number;
30
+ static bezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number;
31
+ static in(easing: (t: number) => number): (t: number) => number;
32
+ /**
33
+ * Runs an easing function backwards.
34
+ */
35
+ static out(easing: (t: number) => number): (t: number) => number;
36
+ /**
37
+ * Makes any easing function symmetrical.
38
+ */
39
+ static inOut(easing: (t: number) => number): (t: number) => number;
40
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts a camelCase string to kebab-case.
3
+ * e.g. backgroundColor -> background-color
4
+ *
5
+ * @param str - The camelCase string to convert.
6
+ * @returns The converted kebab-case string.
7
+ */
8
+ export declare function camelCaseToKebabCase(str: string): string;