react-ui-animate 4.1.2 → 4.3.0-rc.1
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/.releaserc.json +33 -0
- package/README.md +136 -139
- package/package.json +18 -7
- package/dist/animation/controllers/index.d.ts +0 -8
- package/dist/animation/controllers/withConfig.d.ts +0 -5
- package/dist/animation/controllers/withDecay.d.ts +0 -7
- package/dist/animation/controllers/withDelay.d.ts +0 -6
- package/dist/animation/controllers/withEase.d.ts +0 -6
- package/dist/animation/controllers/withLoop.d.ts +0 -2
- package/dist/animation/controllers/withSequence.d.ts +0 -2
- package/dist/animation/controllers/withSpring.d.ts +0 -7
- package/dist/animation/controllers/withTiming.d.ts +0 -7
- package/dist/animation/core/FluidArrayController.d.ts +0 -7
- package/dist/animation/core/FluidController.d.ts +0 -34
- package/dist/animation/core/useFluidValue.d.ts +0 -3
- package/dist/animation/core/useFluidValues.d.ts +0 -3
- package/dist/animation/core/useMount.d.ts +0 -18
- package/dist/animation/helpers/animationType.d.ts +0 -59
- package/dist/animation/helpers/getToValue.d.ts +0 -2
- package/dist/animation/helpers/index.d.ts +0 -3
- package/dist/animation/helpers/isDefined.d.ts +0 -1
- package/dist/animation/hooks/index.d.ts +0 -3
- package/dist/animation/hooks/useMount.d.ts +0 -15
- package/dist/animation/hooks/useValue.d.ts +0 -17
- package/dist/animation/hooks/useValues.d.ts +0 -8
- package/dist/animation/index.d.ts +0 -5
- package/dist/animation/interpolation/colors.d.ts +0 -25
- package/dist/animation/interpolation/index.d.ts +0 -1
- package/dist/animation/interpolation/interpolate.d.ts +0 -11
- package/dist/animation/interpolation/interpolateNumbers.d.ts +0 -8
- package/dist/animation/modules/MountedBlock.d.ts +0 -20
- package/dist/animation/modules/ScrollableBlock.d.ts +0 -22
- package/dist/animation/modules/TransitionBlock.d.ts +0 -18
- package/dist/animation/modules/index.d.ts +0 -3
- package/dist/gestures/controllers/DragGesture.d.ts +0 -17
- package/dist/gestures/controllers/Gesture.d.ts +0 -20
- package/dist/gestures/controllers/MouseMoveGesture.d.ts +0 -13
- package/dist/gestures/controllers/ScrollGesture.d.ts +0 -14
- package/dist/gestures/controllers/WheelGesture.d.ts +0 -15
- package/dist/gestures/controllers/index.d.ts +0 -4
- package/dist/gestures/helpers/eventAttacher.d.ts +0 -11
- package/dist/gestures/helpers/index.d.ts +0 -1
- package/dist/gestures/helpers/math.d.ts +0 -34
- package/dist/gestures/helpers/withDefault.d.ts +0 -4
- package/dist/gestures/hooks/index.d.ts +0 -5
- package/dist/gestures/hooks/useDrag.d.ts +0 -4
- package/dist/gestures/hooks/useGesture.d.ts +0 -9
- package/dist/gestures/hooks/useMouseMove.d.ts +0 -4
- package/dist/gestures/hooks/useRecognizer.d.ts +0 -10
- package/dist/gestures/hooks/useScroll.d.ts +0 -4
- package/dist/gestures/hooks/useWheel.d.ts +0 -4
- package/dist/gestures/types/index.d.ts +0 -51
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/useMeasure.d.ts +0 -14
- package/dist/hooks/useOutsideClick.d.ts +0 -2
- package/dist/hooks/useWindowDimension.d.ts +0 -9
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/.releaserc.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": [
|
|
3
|
+
{ "name": "main", "channel": "latest" },
|
|
4
|
+
{ "name": "next", "prerelease": "rc" }
|
|
5
|
+
],
|
|
6
|
+
"plugins": [
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/commit-analyzer",
|
|
9
|
+
{
|
|
10
|
+
"preset": "angular",
|
|
11
|
+
"releaseRules": [
|
|
12
|
+
{ "type": "chore", "release": false },
|
|
13
|
+
{ "type": "docs", "release": false }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"@semantic-release/release-notes-generator",
|
|
18
|
+
[
|
|
19
|
+
"@semantic-release/npm",
|
|
20
|
+
{
|
|
21
|
+
"npmPublish": true
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"@semantic-release/git",
|
|
26
|
+
{
|
|
27
|
+
"assets": ["package.json", "CHANGELOG.md"],
|
|
28
|
+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"@semantic-release/github"
|
|
32
|
+
]
|
|
33
|
+
}
|
package/README.md
CHANGED
|
@@ -6,203 +6,200 @@
|
|
|
6
6
|
|
|
7
7
|
### Install
|
|
8
8
|
|
|
9
|
-
You can install react-ui-animate via npm or yarn
|
|
9
|
+
You can install `react-ui-animate` via `npm` or `yarn`:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm
|
|
12
|
+
npm install react-ui-animate
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
yarn add react-ui-animate
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
---
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## Getting Started
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
import { animate, useValue } from 'react-ui-animate';
|
|
23
|
+
The `react-ui-animate` library provides a straightforward way to add animations and gestures to your React components. Below are some common use cases.
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
### 1. useValue
|
|
26
|
+
|
|
27
|
+
Use `useValue` to initialize and update an animated value.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import React from 'react';
|
|
31
|
+
import {
|
|
32
|
+
animate,
|
|
33
|
+
useValue,
|
|
34
|
+
withSpring,
|
|
35
|
+
withTiming,
|
|
36
|
+
withSequence,
|
|
37
|
+
} from 'react-ui-animate';
|
|
38
|
+
|
|
39
|
+
export const UseValue: React.FC = () => {
|
|
40
|
+
const [width, setWidth] = useValue(100);
|
|
29
41
|
|
|
30
42
|
return (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
<>
|
|
44
|
+
<button
|
|
45
|
+
onClick={() => {
|
|
46
|
+
setWidth(withSequence([withTiming(100), withSpring(0)]));
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
SEQUENCE (100 → 0)
|
|
50
|
+
</button>
|
|
51
|
+
<button
|
|
52
|
+
onClick={() => {
|
|
53
|
+
setWidth(withSpring(200));
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
SPRING (→ 200)
|
|
57
|
+
</button>
|
|
58
|
+
<button
|
|
59
|
+
onClick={() => {
|
|
60
|
+
setWidth(400);
|
|
39
61
|
}}
|
|
40
62
|
>
|
|
41
|
-
|
|
42
|
-
</
|
|
63
|
+
IMMEDIATE (→ 400)
|
|
64
|
+
</button>
|
|
43
65
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
<animate.div
|
|
67
|
+
style={{
|
|
68
|
+
width,
|
|
69
|
+
height: 100,
|
|
70
|
+
backgroundColor: 'red',
|
|
71
|
+
left: 0,
|
|
72
|
+
top: 0,
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
</>
|
|
47
76
|
);
|
|
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
|
-
#### `useValue()`
|
|
56
|
-
|
|
57
|
-
The `useValue()` 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 = useValue(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 `useValue()`. It simplifies animating elements by directly using animated values.
|
|
74
|
-
|
|
75
|
-
```javascript
|
|
76
|
-
const width = useValue(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 { useValue, animate, interpolate } from 'react-ui-animate';
|
|
93
|
-
|
|
94
|
-
const width = useValue(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);
|
|
77
|
+
};
|
|
115
78
|
```
|
|
116
79
|
|
|
117
|
-
|
|
80
|
+
### 2. useMount
|
|
118
81
|
|
|
119
|
-
|
|
120
|
-
x.value = withTiming(10, { duration: 5000 });
|
|
121
|
-
```
|
|
82
|
+
Use `useMount` to animate component mount and unmount transitions.
|
|
122
83
|
|
|
123
|
-
|
|
84
|
+
```tsx
|
|
85
|
+
import React from 'react';
|
|
86
|
+
import {
|
|
87
|
+
animate,
|
|
88
|
+
useMount,
|
|
89
|
+
withDecay,
|
|
90
|
+
withSequence,
|
|
91
|
+
withSpring,
|
|
92
|
+
withTiming,
|
|
93
|
+
} from 'react-ui-animate';
|
|
124
94
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
95
|
+
export const UseMount: React.FC = () => {
|
|
96
|
+
const [open, setOpen] = React.useState(true);
|
|
97
|
+
const mounted = useMount(open, { from: 0, enter: 1, exit: 0 });
|
|
128
98
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
99
|
+
return (
|
|
100
|
+
<>
|
|
101
|
+
{mounted(
|
|
102
|
+
(animation, isMounted) =>
|
|
103
|
+
isMounted && (
|
|
104
|
+
<animate.div
|
|
105
|
+
style={{
|
|
106
|
+
width: 100,
|
|
107
|
+
height: 100,
|
|
108
|
+
backgroundColor: 'teal',
|
|
109
|
+
opacity: animation,
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
)}
|
|
114
|
+
|
|
115
|
+
<button onClick={() => setOpen((prev) => !prev)}>ANIMATE ME</button>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
133
119
|
```
|
|
134
120
|
|
|
135
|
-
|
|
121
|
+
### 3. Interpolation
|
|
136
122
|
|
|
137
|
-
|
|
123
|
+
Interpolate values for complex mappings like color transitions or movement.
|
|
138
124
|
|
|
139
|
-
|
|
125
|
+
```tsx
|
|
126
|
+
import React, { useLayoutEffect, useState } from 'react';
|
|
127
|
+
import { animate, useValue, withSpring } from 'react-ui-animate';
|
|
140
128
|
|
|
141
|
-
|
|
142
|
-
|
|
129
|
+
export const Interpolation: React.FC = () => {
|
|
130
|
+
const [open, setOpen] = useState(false);
|
|
131
|
+
const [x, setX] = useValue(0);
|
|
143
132
|
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
useLayoutEffect(() => {
|
|
134
|
+
setX(withSpring(open ? 500 : 0));
|
|
135
|
+
}, [open, setX]);
|
|
146
136
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
return (
|
|
138
|
+
<>
|
|
139
|
+
<animate.div
|
|
140
|
+
style={{
|
|
141
|
+
width: 100,
|
|
142
|
+
height: 100,
|
|
143
|
+
backgroundColor: x.to([0, 500], ['red', 'blue']),
|
|
144
|
+
translateX: x,
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
152
147
|
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
<button onClick={() => setOpen((p) => !p)}>ANIMATE ME</button>
|
|
149
|
+
</>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
155
152
|
```
|
|
156
153
|
|
|
157
|
-
|
|
154
|
+
---
|
|
158
155
|
|
|
159
|
-
|
|
160
|
-
2. The `useMount` hook takes `visible` as an argument and provides animation states for mounting and unmounting.
|
|
161
|
-
3. The `open` function, returned by `useMount`, is used to conditionally render `animate.div` based on the `mounted` boolean and apply the transition animation.
|
|
156
|
+
## API Overview
|
|
162
157
|
|
|
163
|
-
|
|
158
|
+
- **`useValue(initial)`**: Initializes an animated value.
|
|
159
|
+
- **`animate`**: JSX wrapper for animatable elements (`animate.div`, `animate.span`, etc.).
|
|
160
|
+
- **Modifiers**: `withSpring`, `withTiming`, `withDecay`, `withSequence` — functions to define animation behavior.
|
|
161
|
+
- **`useMount(state, config)`**: Manages mount/unmount transitions. `config` includes `from`, `enter`, and `exit` values.
|
|
164
162
|
|
|
165
|
-
|
|
163
|
+
## Gestures
|
|
166
164
|
|
|
167
|
-
|
|
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.
|
|
165
|
+
`react-ui-animate` also provides hooks for handling gestures:
|
|
172
166
|
|
|
173
|
-
|
|
167
|
+
- `useDrag`
|
|
168
|
+
- `useMove`
|
|
169
|
+
- `useScroll`
|
|
170
|
+
- `useWheel`
|
|
174
171
|
|
|
175
|
-
|
|
172
|
+
**Example: `useDrag`**
|
|
176
173
|
|
|
177
|
-
```
|
|
178
|
-
import
|
|
174
|
+
```tsx
|
|
175
|
+
import React from 'react';
|
|
176
|
+
import { useValue, animate, useDrag, withSpring } from 'react-ui-animate';
|
|
179
177
|
|
|
180
|
-
export const Draggable = () => {
|
|
181
|
-
const
|
|
178
|
+
export const Draggable: React.FC = () => {
|
|
179
|
+
const ref = useRef(null);
|
|
180
|
+
const [translateX, setTranslateX] = useValue(0);
|
|
182
181
|
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
useDrag(ref, ({ down, movement }) => {
|
|
183
|
+
setTranslateX(down ? movement.x : withSpring(0));
|
|
185
184
|
});
|
|
186
185
|
|
|
187
186
|
return (
|
|
188
187
|
<animate.div
|
|
189
|
-
{
|
|
188
|
+
ref={ref}
|
|
190
189
|
style={{
|
|
191
190
|
width: 100,
|
|
192
191
|
height: 100,
|
|
193
192
|
backgroundColor: '#3399ff',
|
|
194
|
-
translateX
|
|
193
|
+
translateX,
|
|
195
194
|
}}
|
|
196
195
|
/>
|
|
197
196
|
);
|
|
198
197
|
};
|
|
199
198
|
```
|
|
200
199
|
|
|
201
|
-
In this example, the blue block can be dragged horizontally by clicking and dragging.
|
|
202
|
-
|
|
203
200
|
## Documentation
|
|
204
201
|
|
|
205
|
-
For detailed documentation and examples, visit the official [react-ui-animate documentation](
|
|
202
|
+
For detailed documentation and examples, visit the official [react-ui-animate documentation](https://react-ui-animate.js.org/).
|
|
206
203
|
|
|
207
204
|
## License
|
|
208
205
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-ui-animate",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.3.0-rc.1",
|
|
4
4
|
"description": "React library for gestures and animation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"react": ">=16.8.0 || >=17.0.0 || >=18.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@raidipesh78/re-motion": "^
|
|
10
|
+
"@raidipesh78/re-motion": "^5.2.3"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@rollup/plugin-terser": "^0.4.4",
|
|
14
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
15
|
+
"@semantic-release/git": "^10.0.1",
|
|
16
|
+
"@semantic-release/github": "^11.0.3",
|
|
17
|
+
"@semantic-release/npm": "^12.0.2",
|
|
18
|
+
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
14
19
|
"@types/jest": "^29.5.12",
|
|
15
20
|
"@types/node": "^20.14.9",
|
|
16
21
|
"@types/react": "^18.3.3",
|
|
@@ -20,19 +25,25 @@
|
|
|
20
25
|
"babel-runtime": "^6.26.0",
|
|
21
26
|
"react": "^18.3.1",
|
|
22
27
|
"react-dom": "^18.3.1",
|
|
28
|
+
"rimraf": "^6.0.1",
|
|
23
29
|
"rollup": "^4.18.0",
|
|
24
30
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
31
|
+
"semantic-release": "^24.2.6",
|
|
25
32
|
"typescript": "^5.5.2"
|
|
26
33
|
},
|
|
27
34
|
"scripts": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"start": "
|
|
35
|
+
"clean": "rimraf -rf dist",
|
|
36
|
+
"build": "npm run clean && rollup -c",
|
|
37
|
+
"start": "npm run clean && rollup -c -w",
|
|
38
|
+
"start:dev": "cd example && npm start",
|
|
32
39
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
33
40
|
"version:minor": "npm version --no-git-tag-version minor",
|
|
34
41
|
"version:major": "npm version --no-git-tag-version major",
|
|
35
|
-
"version:patch": "npm version --no-git-tag-version patch"
|
|
42
|
+
"version:patch": "npm version --no-git-tag-version patch",
|
|
43
|
+
"version:rc": "npm version prerelease --no-git-tag-version --preid=rc",
|
|
44
|
+
"version:prepatch": "npm version prepatch --no-git-tag-version --preid=rc",
|
|
45
|
+
"publish:next": "npm publish --tag next",
|
|
46
|
+
"publish:latest": "npm publish --tag latest"
|
|
36
47
|
},
|
|
37
48
|
"repository": {
|
|
38
49
|
"type": "git",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { withConfig } from './withConfig';
|
|
2
|
-
export { withDecay } from './withDecay';
|
|
3
|
-
export { withDelay } from './withDelay';
|
|
4
|
-
export { withEase } from './withEase';
|
|
5
|
-
export { withSequence } from './withSequence';
|
|
6
|
-
export { withSpring } from './withSpring';
|
|
7
|
-
export { withTiming } from './withTiming';
|
|
8
|
-
export { withLoop } from './withLoop';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { UseValueConfig } from '../hooks';
|
|
2
|
-
import type { UpdateValue } from '../core/FluidController';
|
|
3
|
-
export interface WithOnCallbacks extends Pick<UseValueConfig, 'onRest' | 'onStart' | 'onChange'> {
|
|
4
|
-
}
|
|
5
|
-
export declare const withConfig: (toValue: number, config?: UseValueConfig) => UpdateValue;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UseValueConfig } from '../hooks';
|
|
2
|
-
import type { WithOnCallbacks } from './withConfig';
|
|
3
|
-
import type { UpdateValue } from '../core/FluidController';
|
|
4
|
-
interface WithDecayConfig extends Pick<UseValueConfig, 'velocity' | 'deceleration'>, WithOnCallbacks {
|
|
5
|
-
}
|
|
6
|
-
export declare const withDecay: (config?: WithDecayConfig) => UpdateValue;
|
|
7
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type WithOnCallbacks } from './withConfig';
|
|
2
|
-
import type { UpdateValue } from '../core/FluidController';
|
|
3
|
-
interface WithEaseConfig extends WithOnCallbacks {
|
|
4
|
-
}
|
|
5
|
-
export declare const withEase: (toValue: number, config?: WithEaseConfig) => UpdateValue;
|
|
6
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type UseValueConfig } from '../hooks';
|
|
2
|
-
import { type WithOnCallbacks } from './withConfig';
|
|
3
|
-
import type { UpdateValue } from '../core/FluidController';
|
|
4
|
-
interface WithSpringConfig extends Pick<UseValueConfig, 'mass' | 'friction' | 'tension'>, WithOnCallbacks {
|
|
5
|
-
}
|
|
6
|
-
export declare const withSpring: (toValue: number, config?: WithSpringConfig) => UpdateValue;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type UseValueConfig } from '../hooks';
|
|
2
|
-
import { type WithOnCallbacks } from './withConfig';
|
|
3
|
-
import type { UpdateValue } from '../core/FluidController';
|
|
4
|
-
interface WithTimingConfig extends Pick<UseValueConfig, 'duration' | 'easing'>, WithOnCallbacks {
|
|
5
|
-
}
|
|
6
|
-
export declare const withTiming: (toValue: number, config?: WithTimingConfig) => UpdateValue;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UpdateValue, UseFluidValueConfig } from './FluidController';
|
|
2
|
-
export declare class FluidArrayController {
|
|
3
|
-
private fluidControllers;
|
|
4
|
-
constructor(values: number[] | string[], config?: UseFluidValueConfig);
|
|
5
|
-
setFluid(updateValue: Array<UpdateValue | UpdateValue[]>, callback?: () => void): void;
|
|
6
|
-
getFluid(): import("@raidipesh78/re-motion").FluidValue[];
|
|
7
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { FluidValue } from '@raidipesh78/re-motion';
|
|
2
|
-
type Fn<T, U> = (value: T) => U;
|
|
3
|
-
export interface UseFluidValueConfig {
|
|
4
|
-
mass?: number;
|
|
5
|
-
tension?: number;
|
|
6
|
-
friction?: number;
|
|
7
|
-
duration?: number;
|
|
8
|
-
easing?: Fn<number, number>;
|
|
9
|
-
immediate?: boolean;
|
|
10
|
-
delay?: number;
|
|
11
|
-
restDistance?: number;
|
|
12
|
-
onChange?: Fn<number | string, void>;
|
|
13
|
-
onRest?: Fn<number | string, void>;
|
|
14
|
-
onStart?: Fn<number | string, void>;
|
|
15
|
-
decay?: boolean;
|
|
16
|
-
velocity?: number;
|
|
17
|
-
deceleration?: number;
|
|
18
|
-
loop?: number;
|
|
19
|
-
}
|
|
20
|
-
export type UpdateValue = {
|
|
21
|
-
toValue?: number | string;
|
|
22
|
-
config?: UseFluidValueConfig;
|
|
23
|
-
};
|
|
24
|
-
export declare class FluidController {
|
|
25
|
-
private fluid;
|
|
26
|
-
private defaultConfig?;
|
|
27
|
-
private iterationsSoFar;
|
|
28
|
-
constructor(value: number | string, config?: UseFluidValueConfig);
|
|
29
|
-
private getAnimation;
|
|
30
|
-
private runAnimation;
|
|
31
|
-
setFluid(updateValue: UpdateValue | UpdateValue[], callback?: (value: number) => void): void;
|
|
32
|
-
getFluid(): FluidValue;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { FluidValue } from '@raidipesh78/re-motion';
|
|
2
|
-
import { UpdateValue, UseFluidValueConfig } from './FluidController';
|
|
3
|
-
export declare const useFluidValue: <T extends number | string>(value: T, config?: UseFluidValueConfig) => [FluidValue, (updateValue: UpdateValue | UpdateValue[], callback?: () => void) => void];
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { FluidValue } from '@raidipesh78/re-motion';
|
|
2
|
-
import { UpdateValue, UseFluidValueConfig } from './FluidController';
|
|
3
|
-
export declare const useFluidValues: <T extends number[] | string[]>(value: T, config?: UseFluidValueConfig) => [FluidValue[], (updateValue: Array<UpdateValue | UpdateValue[]>, callback?: () => void) => void];
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FluidValue } from '@raidipesh78/re-motion';
|
|
2
|
-
import type { UpdateValue, UseFluidValueConfig } from './FluidController';
|
|
3
|
-
export interface UseMountConfig {
|
|
4
|
-
from: number;
|
|
5
|
-
enter: number | UpdateValue | number[] | UpdateValue[];
|
|
6
|
-
exit: number | UpdateValue | number[] | UpdateValue[];
|
|
7
|
-
config?: UseFluidValueConfig;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* `useMount`
|
|
11
|
-
*
|
|
12
|
-
* applies mounting and unmounting of a component according to state change
|
|
13
|
-
* applying transitions
|
|
14
|
-
*
|
|
15
|
-
* @param state - boolean indicating mount state of a component
|
|
16
|
-
* @param config - the config object `UseMountConfig`
|
|
17
|
-
*/
|
|
18
|
-
export declare const useMount: (state: boolean, config: UseMountConfig) => (callback: (animation: FluidValue, mounted: boolean) => React.ReactNode) => import("react").ReactNode;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Easing } from '@raidipesh78/re-motion';
|
|
2
|
-
export declare const AnimationConfig: {
|
|
3
|
-
ELASTIC: {
|
|
4
|
-
mass: number;
|
|
5
|
-
friction: number;
|
|
6
|
-
tension: number;
|
|
7
|
-
};
|
|
8
|
-
BOUNCE: {
|
|
9
|
-
duration: number;
|
|
10
|
-
easing: typeof Easing.bounce;
|
|
11
|
-
};
|
|
12
|
-
EASE: {
|
|
13
|
-
mass: number;
|
|
14
|
-
friction: number;
|
|
15
|
-
tension: number;
|
|
16
|
-
};
|
|
17
|
-
STIFF: {
|
|
18
|
-
mass: number;
|
|
19
|
-
friction: number;
|
|
20
|
-
tension: number;
|
|
21
|
-
};
|
|
22
|
-
WOOBLE: {
|
|
23
|
-
mass: number;
|
|
24
|
-
friction: number;
|
|
25
|
-
tension: number;
|
|
26
|
-
};
|
|
27
|
-
EASE_IN: {
|
|
28
|
-
duration: number;
|
|
29
|
-
easing: (t: number) => number;
|
|
30
|
-
};
|
|
31
|
-
EASE_OUT: {
|
|
32
|
-
duration: number;
|
|
33
|
-
easing: (t: number) => number;
|
|
34
|
-
};
|
|
35
|
-
EASE_IN_OUT: {
|
|
36
|
-
duration: number;
|
|
37
|
-
easing: (t: number) => number;
|
|
38
|
-
};
|
|
39
|
-
POWER1: {
|
|
40
|
-
duration: number;
|
|
41
|
-
easing: (t: number) => number;
|
|
42
|
-
};
|
|
43
|
-
POWER2: {
|
|
44
|
-
duration: number;
|
|
45
|
-
easing: (t: number) => number;
|
|
46
|
-
};
|
|
47
|
-
POWER3: {
|
|
48
|
-
duration: number;
|
|
49
|
-
easing: (t: number) => number;
|
|
50
|
-
};
|
|
51
|
-
POWER4: {
|
|
52
|
-
duration: number;
|
|
53
|
-
easing: (t: number) => number;
|
|
54
|
-
};
|
|
55
|
-
LINEAR: {
|
|
56
|
-
duration: number;
|
|
57
|
-
easing: typeof Easing.linear;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDefined: <T>(value: T) => value is NonNullable<T>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FluidValue } from '@raidipesh78/re-motion';
|
|
2
|
-
import { UseMountConfig as UseInternalMountConfig } from '../core/useMount';
|
|
3
|
-
export interface UseMountConfig extends UseInternalMountConfig {
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* `useMount` handles mounting and unmounting of a component which captures current state
|
|
7
|
-
* passed as an argument (`state`) and exposes the shadow state which handles the mount and unmount
|
|
8
|
-
* of a component.
|
|
9
|
-
*
|
|
10
|
-
* @param { boolean } state - Boolean indicating the component should mount or unmount.
|
|
11
|
-
* @param { UseMountConfig } config - Animation configuration.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useMount(state: boolean, config: UseMountConfig): (cb: (value: {
|
|
14
|
-
value: FluidValue;
|
|
15
|
-
}, mounted: boolean) => React.ReactNode) => import("react").ReactNode;
|