react-ui-animate 3.3.2 → 4.0.0-alpha.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.
- package/LICENSE +21 -21
- package/README.md +209 -209
- package/dist/animation/animationType.d.ts +14 -14
- package/dist/animation/index.d.ts +1 -1
- package/dist/animation/interpolation.d.ts +3 -4
- package/dist/animation/modules/MountedBlock.d.ts +7 -13
- package/dist/animation/modules/ScrollableBlock.d.ts +2 -2
- package/dist/animation/modules/TransitionBlock.d.ts +2 -2
- package/dist/animation/modules/index.d.ts +0 -3
- package/dist/animation/useAnimatedValue.d.ts +7 -8
- package/dist/animation/withFunctions.d.ts +41 -41
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +52 -52
- package/dist/animation/modules/AnimatedBlock.d.ts +0 -8
- package/dist/animation/modules/AnimatedImage.d.ts +0 -8
- package/dist/animation/modules/AnimatedInline.d.ts +0 -8
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,209 +1,209 @@
|
|
|
1
|
-
# React UI Animate
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/react-ui-animate)
|
|
4
|
-
|
|
5
|
-
> Create smooth animations and interactive gestures in React applications effortlessly.
|
|
6
|
-
|
|
7
|
-
### Install
|
|
8
|
-
|
|
9
|
-
You can install react-ui-animate via npm or yarn:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm i react-ui-animate
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
yarn add react-ui-animate
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Getting Started
|
|
20
|
-
|
|
21
|
-
The `react-ui-animate` library provides a straightforward way to add animations and gestures to your React components. Here’s how you can get started quickly:
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
export default function () {
|
|
27
|
-
// Initialize an animated opacity value
|
|
28
|
-
const opacity = useAnimatedValue(0);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div>
|
|
32
|
-
{/*
|
|
33
|
-
<
|
|
34
|
-
style={{
|
|
35
|
-
opacity: opacity.value, // using opacity with value property
|
|
36
|
-
width: 100,
|
|
37
|
-
padding: 20,
|
|
38
|
-
background: '#39F',
|
|
39
|
-
}}
|
|
40
|
-
>
|
|
41
|
-
ANIMATED
|
|
42
|
-
</
|
|
43
|
-
|
|
44
|
-
{/* Clicking the button changes the opacity smoothly to 1 */}
|
|
45
|
-
<button onClick={() => (opacity.value = 1)}>Animate Me</button>
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
In this example, clicking the "Animate Me" button smoothly changes the opacity of the animated block from 0 to 1.
|
|
52
|
-
|
|
53
|
-
### Key Features
|
|
54
|
-
|
|
55
|
-
#### `useAnimatedValue()`
|
|
56
|
-
|
|
57
|
-
The `useAnimatedValue()` hook is central to creating animations. It initializes an animated value and allows you to seamlessly update it to create dynamic effects.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
const opacity = useAnimatedValue(0); // Start with opacity set to 0
|
|
61
|
-
|
|
62
|
-
// Use in style
|
|
63
|
-
style={{
|
|
64
|
-
opacity: opacity.value, // Access the animated opacity value
|
|
65
|
-
}}
|
|
66
|
-
|
|
67
|
-
// Update the value on user interaction
|
|
68
|
-
onClick={() => (opacity.value = 1)} // Changes the opacity to 1
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
#### `
|
|
72
|
-
|
|
73
|
-
`
|
|
74
|
-
|
|
75
|
-
```javascript
|
|
76
|
-
const width = useAnimatedValue(100); // Start with a width of 100
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
style={{
|
|
80
|
-
width: width.value,
|
|
81
|
-
height: 100,
|
|
82
|
-
backgroundColor: '#39f',
|
|
83
|
-
}}
|
|
84
|
-
/>;
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
#### `interpolate`
|
|
88
|
-
|
|
89
|
-
The `interpolate()` function is useful for mapping values from one range to another, enabling more complex animations.
|
|
90
|
-
|
|
91
|
-
```javascript
|
|
92
|
-
import { useAnimatedValue,
|
|
93
|
-
|
|
94
|
-
const width = useAnimatedValue(100); // Start with a width of 100
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
style={{
|
|
98
|
-
width: width.value,
|
|
99
|
-
height: 100,
|
|
100
|
-
backgroundColor: interpolate(width.value, [100, 200], ['red', 'blue']),
|
|
101
|
-
}}
|
|
102
|
-
/>;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
In this example, as the width changes from 100 to 200, the background color smoothly transitions from red to blue.
|
|
106
|
-
|
|
107
|
-
#### Dynamic Animations and Sequence Transitions
|
|
108
|
-
|
|
109
|
-
You can dynamically modify animation configurations by assigning values to an animated value using various animation functions.
|
|
110
|
-
|
|
111
|
-
To apply a spring animation and update the value to `10`:
|
|
112
|
-
|
|
113
|
-
```jsx
|
|
114
|
-
x.value = withSpring(10);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
To apply a timing animation with a duration of 5000 milliseconds:
|
|
118
|
-
|
|
119
|
-
```jsx
|
|
120
|
-
x.value = withTiming(10, { duration: 5000 });
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
To create sequential transitions using the `withSequence` function with dynamic modifiers like `withSpring` and `withTiming`:
|
|
124
|
-
|
|
125
|
-
```jsx
|
|
126
|
-
x.value = withSequence([withSpring(50), withTiming(100), 200]);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
To delay an animation using the withDelay function:
|
|
130
|
-
|
|
131
|
-
```jsx
|
|
132
|
-
x.value = withDelay(1000, withSpring(100));
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
In this example, a spring animation to `100` will be applied after a 1-second delay.
|
|
136
|
-
|
|
137
|
-
#### `useMountedValue()`
|
|
138
|
-
|
|
139
|
-
The `useMountedValue()` hook facilitates managing the mounting and unmounting of a component with animations.
|
|
140
|
-
|
|
141
|
-
```jsx
|
|
142
|
-
import { useMountedValue } from 'react-ui-animate';
|
|
143
|
-
|
|
144
|
-
export default function App() {
|
|
145
|
-
const [visible, setVisible] = useState(false);
|
|
146
|
-
|
|
147
|
-
const open = useMountedValue(visible, {
|
|
148
|
-
from: 0,
|
|
149
|
-
enter: 1,
|
|
150
|
-
exit: 0,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
return open((animation, mounted) => mounted && <
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
In this example,
|
|
158
|
-
|
|
159
|
-
1. A state variable `visible` determines whether the component is visible.
|
|
160
|
-
2. The `useMountedValue` hook takes `visible` as an argument and provides animation states for mounting and unmounting.
|
|
161
|
-
3. The `open` function, returned by `useMountedValue`, is used to conditionally render `
|
|
162
|
-
|
|
163
|
-
### Gestures
|
|
164
|
-
|
|
165
|
-
The `react-ui-animate` library also provides several hooks for handling different types of gestures:
|
|
166
|
-
|
|
167
|
-
1. `useDrag`: Handles drag gestures on elements.
|
|
168
|
-
2. `useMouseMove`: Handles mouse movements.
|
|
169
|
-
3. `useScroll`: Handles scrolling of the document.
|
|
170
|
-
4. `useWheel`: Handles wheel rotation gestures.
|
|
171
|
-
5. `useGesture`: Handles combinations of various gestures.
|
|
172
|
-
|
|
173
|
-
**Example**: `useDrag`
|
|
174
|
-
|
|
175
|
-
Here’s an example of using the useDrag hook to enable drag gestures:
|
|
176
|
-
|
|
177
|
-
```jsx
|
|
178
|
-
import { useAnimatedValue,
|
|
179
|
-
|
|
180
|
-
export const Draggable = () => {
|
|
181
|
-
const translateX = useAnimatedValue(0);
|
|
182
|
-
|
|
183
|
-
const bind = useDrag(function ({ down, movementX }) {
|
|
184
|
-
translateX.value = down ? movementX : 0;
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<
|
|
189
|
-
{...bind()}
|
|
190
|
-
style={{
|
|
191
|
-
width: 100,
|
|
192
|
-
height: 100,
|
|
193
|
-
backgroundColor: '#3399ff',
|
|
194
|
-
translateX: translateX.value, // Use translateX with animated value
|
|
195
|
-
}}
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
In this example, the blue block can be dragged horizontally by clicking and dragging.
|
|
202
|
-
|
|
203
|
-
## Documentation
|
|
204
|
-
|
|
205
|
-
For detailed documentation and examples, visit the official [react-ui-animate documentation](http://react-ui-animate.js.org/).
|
|
206
|
-
|
|
207
|
-
## License
|
|
208
|
-
|
|
209
|
-
This library is licensed under the MIT License.
|
|
1
|
+
# React UI Animate
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/react-ui-animate)
|
|
4
|
+
|
|
5
|
+
> Create smooth animations and interactive gestures in React applications effortlessly.
|
|
6
|
+
|
|
7
|
+
### Install
|
|
8
|
+
|
|
9
|
+
You can install react-ui-animate via npm or yarn:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i react-ui-animate
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn add react-ui-animate
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Getting Started
|
|
20
|
+
|
|
21
|
+
The `react-ui-animate` library provides a straightforward way to add animations and gestures to your React components. Here’s how you can get started quickly:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { animate.div, useAnimatedValue } from 'react-ui-animate';
|
|
25
|
+
|
|
26
|
+
export default function () {
|
|
27
|
+
// Initialize an animated opacity value
|
|
28
|
+
const opacity = useAnimatedValue(0);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
{/* animate.div component uses the animated opacity value */}
|
|
33
|
+
<animate.div
|
|
34
|
+
style={{
|
|
35
|
+
opacity: opacity.value, // using opacity with value property
|
|
36
|
+
width: 100,
|
|
37
|
+
padding: 20,
|
|
38
|
+
background: '#39F',
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
ANIMATED
|
|
42
|
+
</animate.div>
|
|
43
|
+
|
|
44
|
+
{/* Clicking the button changes the opacity smoothly to 1 */}
|
|
45
|
+
<button onClick={() => (opacity.value = 1)}>Animate Me</button>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In this example, clicking the "Animate Me" button smoothly changes the opacity of the animated block from 0 to 1.
|
|
52
|
+
|
|
53
|
+
### Key Features
|
|
54
|
+
|
|
55
|
+
#### `useAnimatedValue()`
|
|
56
|
+
|
|
57
|
+
The `useAnimatedValue()` hook is central to creating animations. It initializes an animated value and allows you to seamlessly update it to create dynamic effects.
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
const opacity = useAnimatedValue(0); // Start with opacity set to 0
|
|
61
|
+
|
|
62
|
+
// Use in style
|
|
63
|
+
style={{
|
|
64
|
+
opacity: opacity.value, // Access the animated opacity value
|
|
65
|
+
}}
|
|
66
|
+
|
|
67
|
+
// Update the value on user interaction
|
|
68
|
+
onClick={() => (opacity.value = 1)} // Changes the opacity to 1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### `animate.div`
|
|
72
|
+
|
|
73
|
+
`animate.div` is a special component designed to work with `useAnimatedValue()`. It simplifies animating elements by directly using animated values.
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
const width = useAnimatedValue(100); // Start with a width of 100
|
|
77
|
+
|
|
78
|
+
<animate.div
|
|
79
|
+
style={{
|
|
80
|
+
width: width.value,
|
|
81
|
+
height: 100,
|
|
82
|
+
backgroundColor: '#39f',
|
|
83
|
+
}}
|
|
84
|
+
/>;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### `interpolate`
|
|
88
|
+
|
|
89
|
+
The `interpolate()` function is useful for mapping values from one range to another, enabling more complex animations.
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
import { useAnimatedValue, animate.div, interpolate } from 'react-ui-animate';
|
|
93
|
+
|
|
94
|
+
const width = useAnimatedValue(100); // Start with a width of 100
|
|
95
|
+
|
|
96
|
+
<animate.div
|
|
97
|
+
style={{
|
|
98
|
+
width: width.value,
|
|
99
|
+
height: 100,
|
|
100
|
+
backgroundColor: interpolate(width.value, [100, 200], ['red', 'blue']),
|
|
101
|
+
}}
|
|
102
|
+
/>;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
In this example, as the width changes from 100 to 200, the background color smoothly transitions from red to blue.
|
|
106
|
+
|
|
107
|
+
#### Dynamic Animations and Sequence Transitions
|
|
108
|
+
|
|
109
|
+
You can dynamically modify animation configurations by assigning values to an animated value using various animation functions.
|
|
110
|
+
|
|
111
|
+
To apply a spring animation and update the value to `10`:
|
|
112
|
+
|
|
113
|
+
```jsx
|
|
114
|
+
x.value = withSpring(10);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
To apply a timing animation with a duration of 5000 milliseconds:
|
|
118
|
+
|
|
119
|
+
```jsx
|
|
120
|
+
x.value = withTiming(10, { duration: 5000 });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
To create sequential transitions using the `withSequence` function with dynamic modifiers like `withSpring` and `withTiming`:
|
|
124
|
+
|
|
125
|
+
```jsx
|
|
126
|
+
x.value = withSequence([withSpring(50), withTiming(100), 200]);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
To delay an animation using the withDelay function:
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
x.value = withDelay(1000, withSpring(100));
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
In this example, a spring animation to `100` will be applied after a 1-second delay.
|
|
136
|
+
|
|
137
|
+
#### `useMountedValue()`
|
|
138
|
+
|
|
139
|
+
The `useMountedValue()` hook facilitates managing the mounting and unmounting of a component with animations.
|
|
140
|
+
|
|
141
|
+
```jsx
|
|
142
|
+
import { useMountedValue } from 'react-ui-animate';
|
|
143
|
+
|
|
144
|
+
export default function App() {
|
|
145
|
+
const [visible, setVisible] = useState(false);
|
|
146
|
+
|
|
147
|
+
const open = useMountedValue(visible, {
|
|
148
|
+
from: 0,
|
|
149
|
+
enter: 1,
|
|
150
|
+
exit: 0,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return open((animation, mounted) => mounted && <animate.div />);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
In this example,
|
|
158
|
+
|
|
159
|
+
1. A state variable `visible` determines whether the component is visible.
|
|
160
|
+
2. The `useMountedValue` hook takes `visible` as an argument and provides animation states for mounting and unmounting.
|
|
161
|
+
3. The `open` function, returned by `useMountedValue`, is used to conditionally render `animate.div` based on the `mounted` boolean and apply the transition animation.
|
|
162
|
+
|
|
163
|
+
### Gestures
|
|
164
|
+
|
|
165
|
+
The `react-ui-animate` library also provides several hooks for handling different types of gestures:
|
|
166
|
+
|
|
167
|
+
1. `useDrag`: Handles drag gestures on elements.
|
|
168
|
+
2. `useMouseMove`: Handles mouse movements.
|
|
169
|
+
3. `useScroll`: Handles scrolling of the document.
|
|
170
|
+
4. `useWheel`: Handles wheel rotation gestures.
|
|
171
|
+
5. `useGesture`: Handles combinations of various gestures.
|
|
172
|
+
|
|
173
|
+
**Example**: `useDrag`
|
|
174
|
+
|
|
175
|
+
Here’s an example of using the useDrag hook to enable drag gestures:
|
|
176
|
+
|
|
177
|
+
```jsx
|
|
178
|
+
import { useAnimatedValue, animate.div, useDrag } from 'react-ui-animate';
|
|
179
|
+
|
|
180
|
+
export const Draggable = () => {
|
|
181
|
+
const translateX = useAnimatedValue(0);
|
|
182
|
+
|
|
183
|
+
const bind = useDrag(function ({ down, movementX }) {
|
|
184
|
+
translateX.value = down ? movementX : 0;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<animate.div
|
|
189
|
+
{...bind()}
|
|
190
|
+
style={{
|
|
191
|
+
width: 100,
|
|
192
|
+
height: 100,
|
|
193
|
+
backgroundColor: '#3399ff',
|
|
194
|
+
translateX: translateX.value, // Use translateX with animated value
|
|
195
|
+
}}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
In this example, the blue block can be dragged horizontally by clicking and dragging.
|
|
202
|
+
|
|
203
|
+
## Documentation
|
|
204
|
+
|
|
205
|
+
For detailed documentation and examples, visit the official [react-ui-animate documentation](http://react-ui-animate.js.org/).
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
This library is licensed under the MIT License.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UseFluidValueConfig } from '@raidipesh78/re-motion';
|
|
2
2
|
export declare const AnimationConfigUtils: {
|
|
3
|
-
ELASTIC:
|
|
4
|
-
BOUNCE:
|
|
5
|
-
EASE:
|
|
6
|
-
STIFF:
|
|
7
|
-
WOOBLE:
|
|
8
|
-
EASE_IN:
|
|
9
|
-
EASE_OUT:
|
|
10
|
-
EASE_IN_OUT:
|
|
11
|
-
POWER1:
|
|
12
|
-
POWER2:
|
|
13
|
-
POWER3:
|
|
14
|
-
POWER4:
|
|
15
|
-
LINEAR:
|
|
3
|
+
ELASTIC: UseFluidValueConfig;
|
|
4
|
+
BOUNCE: UseFluidValueConfig;
|
|
5
|
+
EASE: UseFluidValueConfig;
|
|
6
|
+
STIFF: UseFluidValueConfig;
|
|
7
|
+
WOOBLE: UseFluidValueConfig;
|
|
8
|
+
EASE_IN: UseFluidValueConfig;
|
|
9
|
+
EASE_OUT: UseFluidValueConfig;
|
|
10
|
+
EASE_IN_OUT: UseFluidValueConfig;
|
|
11
|
+
POWER1: UseFluidValueConfig;
|
|
12
|
+
POWER2: UseFluidValueConfig;
|
|
13
|
+
POWER3: UseFluidValueConfig;
|
|
14
|
+
POWER4: UseFluidValueConfig;
|
|
15
|
+
LINEAR: UseFluidValueConfig;
|
|
16
16
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { interpolate, bInterpolate } from './interpolation';
|
|
2
|
-
export {
|
|
2
|
+
export { MountedBlock, ScrollableBlock, TransitionBlock } from './modules';
|
|
3
3
|
export { useAnimatedValue, UseAnimatedValueConfig } from './useAnimatedValue';
|
|
4
4
|
export { useMountedValue, UseMountedValueConfig } from './useMountedValue';
|
|
5
5
|
export { AnimationConfigUtils } from './animationType';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ExtrapolateConfig
|
|
2
|
-
import { ValueType } from './useAnimatedValue';
|
|
1
|
+
import { ExtrapolateConfig } from '@raidipesh78/re-motion';
|
|
3
2
|
/**
|
|
4
3
|
* Maps the input range to the given output range using the specified extrapolation configuration.
|
|
5
4
|
* The function ensures that the value is either a number or a FluidValue.
|
|
@@ -11,7 +10,7 @@ import { ValueType } from './useAnimatedValue';
|
|
|
11
10
|
* @returns - The interpolated value, which will be a number or FluidValue.
|
|
12
11
|
* @throws - Will throw an error if the value is not a number or FluidValue.
|
|
13
12
|
*/
|
|
14
|
-
export declare function interpolate(value:
|
|
13
|
+
export declare function interpolate(value: any, inputRange: number[], outputRange: number[] | string[], extrapolateConfig?: ExtrapolateConfig): import("@raidipesh78/re-motion/dist/fluids/FluidInterpolation").FluidInterpolation;
|
|
15
14
|
/**
|
|
16
15
|
* A shorthand function for interpolate that maps the input range [0, 1] to the given [minOutput, maxOutput].
|
|
17
16
|
* The function ensures that the value is either a number or a FluidValue.
|
|
@@ -23,4 +22,4 @@ export declare function interpolate(value: FluidValue | ValueType | number, inpu
|
|
|
23
22
|
* @returns - The interpolated value, which will be a number or FluidValue.
|
|
24
23
|
* @throws - Will throw an error if the value is not a number or FluidValue.
|
|
25
24
|
*/
|
|
26
|
-
export declare function bInterpolate(value:
|
|
25
|
+
export declare function bInterpolate(value: any, minOutput: number | string, maxOutput: number | string, extrapolateConfig?: ExtrapolateConfig): import("@raidipesh78/re-motion/dist/fluids/FluidInterpolation").FluidInterpolation;
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
interface MountedValueConfig extends FluidValueConfig {
|
|
5
|
-
}
|
|
6
|
-
type AssignValue = {
|
|
7
|
-
toValue?: Length;
|
|
8
|
-
config?: MountedValueConfig;
|
|
9
|
-
};
|
|
2
|
+
import { UseFluidValueConfig } from '@raidipesh78/re-motion';
|
|
3
|
+
import type { UpdateValue } from '../useAnimatedValue';
|
|
10
4
|
interface MountedBlockProps {
|
|
11
5
|
state: boolean;
|
|
12
6
|
children: (animation: {
|
|
13
|
-
value:
|
|
7
|
+
value: any;
|
|
14
8
|
}) => React.ReactNode;
|
|
15
9
|
from?: number;
|
|
16
|
-
enter?: number |
|
|
17
|
-
exit?: number |
|
|
18
|
-
config?:
|
|
10
|
+
enter?: number | UpdateValue;
|
|
11
|
+
exit?: number | UpdateValue;
|
|
12
|
+
config?: UseFluidValueConfig;
|
|
19
13
|
}
|
|
20
14
|
/**
|
|
21
15
|
* MountedBlock - Higher order component which handles mounting and unmounting of a component.
|
|
@@ -24,7 +18,7 @@ interface MountedBlockProps {
|
|
|
24
18
|
* @param { number } } from - Number that dictates the beginning state for animation.
|
|
25
19
|
* @param { number | { toValue: number, config: MountedValueConfig } } enter - Number that dictates the entry state for animation.
|
|
26
20
|
* @param { number | { toValue: number, config: MountedValueConfig } } exit - Number that dictates the exit state for animation.
|
|
27
|
-
* @param {
|
|
21
|
+
* @param { UseFluidValueConfig } config - Animation configuration for overall animation.
|
|
28
22
|
*/
|
|
29
23
|
export declare const MountedBlock: ({ state, children, from, enter, exit, config, }: MountedBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
24
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { UseAnimatedValueConfig
|
|
2
|
+
import { UseAnimatedValueConfig } from '../useAnimatedValue';
|
|
3
3
|
interface ScrollableBlockProps {
|
|
4
4
|
children?: (animation: {
|
|
5
|
-
value:
|
|
5
|
+
value: any;
|
|
6
6
|
}) => React.ReactNode;
|
|
7
7
|
direction?: 'single' | 'both';
|
|
8
8
|
threshold?: number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { UseAnimatedValueConfig
|
|
2
|
+
import { UseAnimatedValueConfig } from '../useAnimatedValue';
|
|
3
3
|
interface TransitionBlockProps {
|
|
4
4
|
state: boolean;
|
|
5
5
|
children: (animation: {
|
|
6
|
-
value:
|
|
6
|
+
value: any;
|
|
7
7
|
}) => React.ReactNode;
|
|
8
8
|
config?: UseAnimatedValueConfig;
|
|
9
9
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface UseAnimatedValueConfig extends FluidValueConfig {
|
|
1
|
+
import { UseFluidValueConfig } from '@raidipesh78/re-motion';
|
|
2
|
+
export interface UseAnimatedValueConfig extends UseFluidValueConfig {
|
|
4
3
|
}
|
|
5
4
|
type AssignValue = {
|
|
6
|
-
toValue?:
|
|
5
|
+
toValue?: number;
|
|
7
6
|
config?: UseAnimatedValueConfig;
|
|
8
7
|
};
|
|
9
|
-
export type
|
|
8
|
+
export type UpdateValue = AssignValue | ((update: (next: AssignValue) => Promise<any>) => void);
|
|
10
9
|
/**
|
|
11
10
|
* `useAnimatedValue` returns an animation value with `.value` and `.currentValue` property which is
|
|
12
11
|
* initialized when passed to argument (`initialValue`). The retured value persist until the lifetime of
|
|
@@ -15,8 +14,8 @@ export type ValueType = Length | AssignValue | ((update: (next: AssignValue) =>
|
|
|
15
14
|
* @param { string | number } initialValue - Initial value
|
|
16
15
|
* @param { UseAnimatedValueConfig } config - Animation configuration object.
|
|
17
16
|
*/
|
|
18
|
-
export declare function useAnimatedValue(initialValue:
|
|
19
|
-
value:
|
|
20
|
-
currentValue: number
|
|
17
|
+
export declare function useAnimatedValue(initialValue: number, config?: UseAnimatedValueConfig): {
|
|
18
|
+
value: any;
|
|
19
|
+
currentValue: number;
|
|
21
20
|
};
|
|
22
21
|
export {};
|