react-ui-animate 5.0.0-rc.2 → 5.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.
- package/LICENSE +21 -21
- package/README.md +206 -206
- package/dist/animation/AnimationConfig.d.ts +8 -8
- package/dist/animation/descriptors.d.ts +7 -0
- package/dist/animation/drivers.d.ts +4 -0
- package/dist/animation/helpers.d.ts +3 -0
- package/dist/animation/index.d.ts +4 -3
- package/dist/animation/to.d.ts +9 -0
- package/dist/animation/types.d.ts +33 -26
- package/dist/animation/useMount.d.ts +17 -0
- package/dist/animation/useValue.d.ts +9 -0
- package/dist/gestures/controllers/DragGesture.d.ts +43 -15
- package/dist/gestures/controllers/Gesture.d.ts +11 -19
- package/dist/gestures/controllers/MoveGesture.d.ts +29 -0
- package/dist/gestures/controllers/ScrollGesture.d.ts +26 -12
- package/dist/gestures/controllers/WheelGesture.d.ts +24 -13
- package/dist/gestures/hooks/index.d.ts +4 -5
- package/dist/gestures/hooks/useDrag.d.ts +5 -4
- package/dist/gestures/hooks/useMove.d.ts +8 -0
- package/dist/gestures/hooks/useScroll.d.ts +8 -4
- package/dist/gestures/hooks/useWheel.d.ts +8 -4
- package/dist/gestures/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/useDimension.d.ts +9 -0
- package/dist/hooks/useMeasure.d.ts +5 -7
- package/dist/hooks/useOutsideClick.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +6 -0
- package/package.json +54 -54
- package/dist/animation/Value.d.ts +0 -12
- package/dist/animation/controllers.d.ts +0 -41
- package/dist/animation/hooks/index.d.ts +0 -3
- package/dist/animation/hooks/useAnimatedList.d.ts +0 -24
- package/dist/animation/hooks/useMount.d.ts +0 -12
- package/dist/animation/hooks/useValue.d.ts +0 -15
- package/dist/animation/interpolation/colors.d.ts +0 -25
- package/dist/animation/interpolation/index.d.ts +0 -1
- package/dist/animation/interpolation/interpolateNumbers.d.ts +0 -8
- package/dist/gestures/controllers/MouseMoveGesture.d.ts +0 -13
- 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/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/types/index.d.ts +0 -51
- package/dist/hooks/useWindowDimension.d.ts +0 -9
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,206 +1,206 @@
|
|
|
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 install react-ui-animate
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
yarn add react-ui-animate
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Getting Started
|
|
22
|
-
|
|
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.
|
|
24
|
-
|
|
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);
|
|
41
|
-
|
|
42
|
-
return (
|
|
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);
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
IMMEDIATE (→ 400)
|
|
64
|
-
</button>
|
|
65
|
-
|
|
66
|
-
<animate.div
|
|
67
|
-
style={{
|
|
68
|
-
width,
|
|
69
|
-
height: 100,
|
|
70
|
-
backgroundColor: 'red',
|
|
71
|
-
left: 0,
|
|
72
|
-
top: 0,
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
</>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### 2. useMount
|
|
81
|
-
|
|
82
|
-
Use `useMount` to animate component mount and unmount transitions.
|
|
83
|
-
|
|
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';
|
|
94
|
-
|
|
95
|
-
export const UseMount: React.FC = () => {
|
|
96
|
-
const [open, setOpen] = React.useState(true);
|
|
97
|
-
const mounted = useMount(open, { from: 0, enter: 1, exit: 0 });
|
|
98
|
-
|
|
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
|
-
};
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### 3. Interpolation
|
|
122
|
-
|
|
123
|
-
Interpolate values for complex mappings like color transitions or movement.
|
|
124
|
-
|
|
125
|
-
```tsx
|
|
126
|
-
import React, { useLayoutEffect, useState } from 'react';
|
|
127
|
-
import { animate, useValue, withSpring } from 'react-ui-animate';
|
|
128
|
-
|
|
129
|
-
export const Interpolation: React.FC = () => {
|
|
130
|
-
const [open, setOpen] = useState(false);
|
|
131
|
-
const [x, setX] = useValue(0);
|
|
132
|
-
|
|
133
|
-
useLayoutEffect(() => {
|
|
134
|
-
setX(withSpring(open ? 500 : 0));
|
|
135
|
-
}, [open, setX]);
|
|
136
|
-
|
|
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
|
-
/>
|
|
147
|
-
|
|
148
|
-
<button onClick={() => setOpen((p) => !p)}>ANIMATE ME</button>
|
|
149
|
-
</>
|
|
150
|
-
);
|
|
151
|
-
};
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## API Overview
|
|
157
|
-
|
|
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
|
|
161
|
-
- **`useMount(state, config)`**: Manages mount/unmount transitions. `config` includes `from`, `enter`, and `exit` values.
|
|
162
|
-
|
|
163
|
-
## Gestures
|
|
164
|
-
|
|
165
|
-
`react-ui-animate` also provides hooks for handling gestures:
|
|
166
|
-
|
|
167
|
-
- `useDrag`
|
|
168
|
-
- `
|
|
169
|
-
- `useScroll`
|
|
170
|
-
- `useWheel`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
import
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const [translateX, setTranslateX] = useValue(0);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
setTranslateX(down ?
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
return (
|
|
187
|
-
<animate.div
|
|
188
|
-
{
|
|
189
|
-
style={{
|
|
190
|
-
width: 100,
|
|
191
|
-
height: 100,
|
|
192
|
-
backgroundColor: '#3399ff',
|
|
193
|
-
translateX,
|
|
194
|
-
}}
|
|
195
|
-
/>
|
|
196
|
-
);
|
|
197
|
-
};
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Documentation
|
|
201
|
-
|
|
202
|
-
For detailed documentation and examples, visit the official [react-ui-animate documentation](https://react-ui-animate.js.org/).
|
|
203
|
-
|
|
204
|
-
## License
|
|
205
|
-
|
|
206
|
-
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 install react-ui-animate
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn add react-ui-animate
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
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.
|
|
24
|
+
|
|
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);
|
|
41
|
+
|
|
42
|
+
return (
|
|
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);
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
IMMEDIATE (→ 400)
|
|
64
|
+
</button>
|
|
65
|
+
|
|
66
|
+
<animate.div
|
|
67
|
+
style={{
|
|
68
|
+
width,
|
|
69
|
+
height: 100,
|
|
70
|
+
backgroundColor: 'red',
|
|
71
|
+
left: 0,
|
|
72
|
+
top: 0,
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 2. useMount
|
|
81
|
+
|
|
82
|
+
Use `useMount` to animate component mount and unmount transitions.
|
|
83
|
+
|
|
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';
|
|
94
|
+
|
|
95
|
+
export const UseMount: React.FC = () => {
|
|
96
|
+
const [open, setOpen] = React.useState(true);
|
|
97
|
+
const mounted = useMount(open, { from: 0, enter: 1, exit: 0 });
|
|
98
|
+
|
|
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
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 3. Interpolation
|
|
122
|
+
|
|
123
|
+
Interpolate values for complex mappings like color transitions or movement.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import React, { useLayoutEffect, useState } from 'react';
|
|
127
|
+
import { animate, useValue, withSpring } from 'react-ui-animate';
|
|
128
|
+
|
|
129
|
+
export const Interpolation: React.FC = () => {
|
|
130
|
+
const [open, setOpen] = useState(false);
|
|
131
|
+
const [x, setX] = useValue(0);
|
|
132
|
+
|
|
133
|
+
useLayoutEffect(() => {
|
|
134
|
+
setX(withSpring(open ? 500 : 0));
|
|
135
|
+
}, [open, setX]);
|
|
136
|
+
|
|
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
|
+
/>
|
|
147
|
+
|
|
148
|
+
<button onClick={() => setOpen((p) => !p)}>ANIMATE ME</button>
|
|
149
|
+
</>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## API Overview
|
|
157
|
+
|
|
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.
|
|
162
|
+
|
|
163
|
+
## Gestures
|
|
164
|
+
|
|
165
|
+
`react-ui-animate` also provides hooks for handling gestures:
|
|
166
|
+
|
|
167
|
+
- `useDrag`
|
|
168
|
+
- `useMove`
|
|
169
|
+
- `useScroll`
|
|
170
|
+
- `useWheel`
|
|
171
|
+
|
|
172
|
+
**Example: `useDrag`**
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import React from 'react';
|
|
176
|
+
import { useValue, animate, useDrag, withSpring } from 'react-ui-animate';
|
|
177
|
+
|
|
178
|
+
export const Draggable: React.FC = () => {
|
|
179
|
+
const ref = useRef(null);
|
|
180
|
+
const [translateX, setTranslateX] = useValue(0);
|
|
181
|
+
|
|
182
|
+
useDrag(ref, ({ down, movement }) => {
|
|
183
|
+
setTranslateX(down ? movement.x : withSpring(0));
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<animate.div
|
|
188
|
+
ref={ref}
|
|
189
|
+
style={{
|
|
190
|
+
width: 100,
|
|
191
|
+
height: 100,
|
|
192
|
+
backgroundColor: '#3399ff',
|
|
193
|
+
translateX,
|
|
194
|
+
}}
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Documentation
|
|
201
|
+
|
|
202
|
+
For detailed documentation and examples, visit the official [react-ui-animate documentation](https://react-ui-animate.js.org/).
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
This library is licensed under the MIT License.
|
|
@@ -41,23 +41,23 @@ export declare const AnimationConfig: {
|
|
|
41
41
|
Spring: {
|
|
42
42
|
ELASTIC: {
|
|
43
43
|
mass: number;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
damping: number;
|
|
45
|
+
stiffness: number;
|
|
46
46
|
};
|
|
47
47
|
EASE: {
|
|
48
48
|
mass: number;
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
damping: number;
|
|
50
|
+
stiffness: number;
|
|
51
51
|
};
|
|
52
52
|
STIFF: {
|
|
53
53
|
mass: number;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
damping: number;
|
|
55
|
+
stiffness: number;
|
|
56
56
|
};
|
|
57
57
|
WOBBLE: {
|
|
58
58
|
mass: number;
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
damping: number;
|
|
60
|
+
stiffness: number;
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Callbacks, DecayOptions, Descriptor, SpringOptions, TimingOptions } from './types';
|
|
2
|
+
export declare const withSpring: (to: Descriptor["to"], opts?: SpringOptions & Callbacks) => Descriptor;
|
|
3
|
+
export declare const withTiming: (to: Descriptor["to"], opts?: TimingOptions & Callbacks) => Descriptor;
|
|
4
|
+
export declare const withDecay: (velocity: number, opts?: DecayOptions & Callbacks) => Descriptor;
|
|
5
|
+
export declare const withDelay: (ms: number) => Descriptor;
|
|
6
|
+
export declare const withSequence: (animations: Descriptor[], opts?: Omit<Callbacks, "onChange">) => Descriptor;
|
|
7
|
+
export declare const withLoop: (animation: Descriptor, iterations?: number, opts?: Omit<Callbacks, "onChange">) => Descriptor;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MotionValue } from '@raidipesh78/re-motion';
|
|
2
|
+
import type { Primitive, Descriptor } from './types';
|
|
3
|
+
export declare function buildAnimation(mv: MotionValue<Primitive>, { type, to, options }: Descriptor): import("@raidipesh78/re-motion/dist/drivers/AnimationController").AnimationController;
|
|
4
|
+
export declare function buildParallel(mvMap: Record<string, MotionValue<Primitive>>, step: Descriptor): import("@raidipesh78/re-motion/dist/drivers/AnimationController").AnimationController;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { useValue
|
|
2
|
-
export {
|
|
1
|
+
export { useValue } from './useValue';
|
|
2
|
+
export { useMount } from './useMount';
|
|
3
|
+
export { withDecay, withDelay, withLoop, withSequence, withSpring, withTiming, } from './descriptors';
|
|
3
4
|
export { AnimationConfig } from './AnimationConfig';
|
|
4
|
-
export {
|
|
5
|
+
export { to } from './to';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type ExtrapolateType = 'identity' | 'extend' | 'clamp';
|
|
2
|
+
interface ExtrapolateConfig {
|
|
3
|
+
extrapolate?: ExtrapolateType;
|
|
4
|
+
extrapolateRight?: ExtrapolateType;
|
|
5
|
+
extrapolateLeft?: ExtrapolateType;
|
|
6
|
+
easing?: (t: number) => number;
|
|
7
|
+
}
|
|
8
|
+
export declare function to(input: number, inRange: number[], outRange: (number | string)[], config?: ExtrapolateConfig): number | string;
|
|
9
|
+
export {};
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
export type Primitive = number | string;
|
|
2
|
-
export interface
|
|
3
|
-
onStart?: (
|
|
4
|
-
onChange?: (
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
export interface Callbacks {
|
|
3
|
+
onStart?: () => void;
|
|
4
|
+
onChange?: (v: number) => void;
|
|
5
|
+
onComplete?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface SpringOptions {
|
|
8
|
+
stiffness?: number;
|
|
9
|
+
damping?: number;
|
|
10
|
+
mass?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TimingOptions {
|
|
13
|
+
duration?: number;
|
|
14
|
+
easing?: (t: number) => number;
|
|
15
|
+
}
|
|
16
|
+
export interface DecayOptions {
|
|
17
|
+
velocity?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SequenceOptions {
|
|
20
|
+
animations?: Descriptor[];
|
|
21
|
+
}
|
|
22
|
+
export interface DelayOptions {
|
|
23
|
+
delay?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface LoopOptions {
|
|
26
|
+
iterations?: number;
|
|
27
|
+
animation?: Descriptor;
|
|
28
|
+
}
|
|
29
|
+
export type DriverType = 'spring' | 'timing' | 'decay' | 'delay' | 'sequence' | 'loop';
|
|
30
|
+
export interface Descriptor {
|
|
31
|
+
type: DriverType;
|
|
32
|
+
to?: Primitive | Primitive[] | Record<string, Primitive>;
|
|
33
|
+
options?: SpringOptions & TimingOptions & DecayOptions & SequenceOptions & DelayOptions & LoopOptions & Callbacks;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MotionValue } from '@raidipesh78/re-motion';
|
|
2
|
+
import type { Primitive, Descriptor } from './types';
|
|
3
|
+
type ConfigSingle<T extends Primitive> = {
|
|
4
|
+
from?: T;
|
|
5
|
+
enter?: T | Descriptor;
|
|
6
|
+
exit?: T | Descriptor;
|
|
7
|
+
};
|
|
8
|
+
type ConfigMulti<I extends Record<string, Primitive>> = {
|
|
9
|
+
from: I;
|
|
10
|
+
enter?: I | Descriptor;
|
|
11
|
+
exit?: I | Descriptor;
|
|
12
|
+
};
|
|
13
|
+
export declare function useMount<T extends Primitive = number>(isOpen: boolean, config?: ConfigSingle<T>): (fn: (value: MotionValue<T>, mounted: boolean) => React.ReactNode) => React.ReactNode;
|
|
14
|
+
export declare function useMount<I extends Record<string, Primitive>>(isOpen: boolean, config: ConfigMulti<I>): (fn: (values: {
|
|
15
|
+
[K in keyof I]: MotionValue<I[K]>;
|
|
16
|
+
}, mounted: boolean) => React.ReactNode) => React.ReactNode;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MotionValue } from '@raidipesh78/re-motion';
|
|
2
|
+
import type { Primitive, Descriptor } from './types';
|
|
3
|
+
type Widen<T> = T extends number ? number : T extends string ? string : T;
|
|
4
|
+
type ValueReturn<T> = T extends Primitive ? MotionValue<Widen<T>> : T extends Primitive[] ? MotionValue<Widen<Primitive>>[] : {
|
|
5
|
+
[K in keyof T]: MotionValue<Widen<T[K]>>;
|
|
6
|
+
};
|
|
7
|
+
type Base = Primitive | Primitive[] | Record<string, Primitive>;
|
|
8
|
+
export declare function useValue<T extends Base>(initial: T): [ValueReturn<T>, (to: Base | Descriptor) => void];
|
|
9
|
+
export {};
|