react-ui-animate 5.0.0-rc.14 → 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/{Config.d.ts → AnimationConfig.d.ts} +1 -1
- package/dist/animation/index.d.ts +5 -5
- package/dist/animation/types.d.ts +0 -8
- package/dist/animation/{hooks/useMount.d.ts → useMount.d.ts} +4 -3
- package/dist/animation/{hooks/useValue.d.ts → useValue.d.ts} +2 -2
- package/dist/gestures/controllers/DragGesture.d.ts +3 -5
- package/dist/gestures/controllers/Gesture.d.ts +1 -2
- package/dist/gestures/controllers/MoveGesture.d.ts +2 -3
- package/dist/gestures/controllers/ScrollGesture.d.ts +2 -3
- package/dist/gestures/controllers/WheelGesture.d.ts +1 -3
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useDimension.d.ts +9 -0
- package/dist/hooks/useMeasure.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/package.json +54 -63
- package/dist/animation/hooks/index.d.ts +0 -2
- package/dist/animation/modules/Mount.d.ts +0 -17
- package/dist/animation/modules/index.d.ts +0 -1
- package/dist/gestures/hooks/useRecognizer.d.ts +0 -13
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` — 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.
|
|
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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { useValue } from './useValue';
|
|
2
|
+
export { useMount } from './useMount';
|
|
3
|
+
export { withDecay, withDelay, withLoop, withSequence, withSpring, withTiming, } from './descriptors';
|
|
4
|
+
export { AnimationConfig } from './AnimationConfig';
|
|
5
|
+
export { to } from './to';
|
|
@@ -15,7 +15,6 @@ export interface TimingOptions {
|
|
|
15
15
|
}
|
|
16
16
|
export interface DecayOptions {
|
|
17
17
|
velocity?: number;
|
|
18
|
-
clamp?: [number, number];
|
|
19
18
|
}
|
|
20
19
|
export interface SequenceOptions {
|
|
21
20
|
animations?: Descriptor[];
|
|
@@ -33,10 +32,3 @@ export interface Descriptor {
|
|
|
33
32
|
to?: Primitive | Primitive[] | Record<string, Primitive>;
|
|
34
33
|
options?: SpringOptions & TimingOptions & DecayOptions & SequenceOptions & DelayOptions & LoopOptions & Callbacks;
|
|
35
34
|
}
|
|
36
|
-
export interface Controls {
|
|
37
|
-
start(): void;
|
|
38
|
-
pause(): void;
|
|
39
|
-
resume(): void;
|
|
40
|
-
cancel(): void;
|
|
41
|
-
reset(): void;
|
|
42
|
-
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MotionValue } from '@raidipesh78/re-motion';
|
|
2
|
-
import type { Primitive, Descriptor } from '
|
|
3
|
-
|
|
2
|
+
import type { Primitive, Descriptor } from './types';
|
|
3
|
+
type ConfigSingle<T extends Primitive> = {
|
|
4
4
|
from?: T;
|
|
5
5
|
enter?: T | Descriptor;
|
|
6
6
|
exit?: T | Descriptor;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type ConfigMulti<I extends Record<string, Primitive>> = {
|
|
9
9
|
from: I;
|
|
10
10
|
enter?: I | Descriptor;
|
|
11
11
|
exit?: I | Descriptor;
|
|
@@ -14,3 +14,4 @@ export declare function useMount<T extends Primitive = number>(isOpen: boolean,
|
|
|
14
14
|
export declare function useMount<I extends Record<string, Primitive>>(isOpen: boolean, config: ConfigMulti<I>): (fn: (values: {
|
|
15
15
|
[K in keyof I]: MotionValue<I[K]>;
|
|
16
16
|
}, mounted: boolean) => React.ReactNode) => React.ReactNode;
|
|
17
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MotionValue } from '@raidipesh78/re-motion';
|
|
2
|
-
import type { Primitive, Descriptor
|
|
2
|
+
import type { Primitive, Descriptor } from './types';
|
|
3
3
|
type Widen<T> = T extends number ? number : T extends string ? string : T;
|
|
4
4
|
type ValueReturn<T> = T extends Primitive ? MotionValue<Widen<T>> : T extends Primitive[] ? MotionValue<Widen<Primitive>>[] : {
|
|
5
5
|
[K in keyof T]: MotionValue<Widen<T[K]>>;
|
|
6
6
|
};
|
|
7
7
|
type Base = Primitive | Primitive[] | Record<string, Primitive>;
|
|
8
|
-
export declare function useValue<T extends Base>(initial: T): [ValueReturn<T>, (to: Base | Descriptor) => void
|
|
8
|
+
export declare function useValue<T extends Base>(initial: T): [ValueReturn<T>, (to: Base | Descriptor) => void];
|
|
9
9
|
export {};
|
|
@@ -32,16 +32,14 @@ export declare class DragGesture extends Gesture<DragEvent> {
|
|
|
32
32
|
private velocity;
|
|
33
33
|
private start;
|
|
34
34
|
private offset;
|
|
35
|
-
private pointerCaptured;
|
|
36
35
|
private activePointerId;
|
|
37
|
-
private
|
|
38
|
-
private activeEl;
|
|
36
|
+
private attachedEl;
|
|
39
37
|
private pointerDownPos;
|
|
40
38
|
private thresholdPassed;
|
|
41
39
|
constructor(config?: DragConfig);
|
|
42
|
-
attach(
|
|
40
|
+
attach(element: HTMLElement): () => void;
|
|
43
41
|
private onDown;
|
|
44
42
|
private onMove;
|
|
45
43
|
private onUp;
|
|
46
|
-
cancel
|
|
44
|
+
private cancel;
|
|
47
45
|
}
|
|
@@ -7,7 +7,6 @@ export declare abstract class Gesture<E> {
|
|
|
7
7
|
onEnd(listener: Listener<E>): this;
|
|
8
8
|
protected emitChange(event: E): void;
|
|
9
9
|
protected emitEnd(event: E): void;
|
|
10
|
-
abstract attach(
|
|
11
|
-
abstract cancel(): void;
|
|
10
|
+
abstract attach(element: HTMLElement): () => void;
|
|
12
11
|
}
|
|
13
12
|
export {};
|
|
@@ -16,15 +16,14 @@ export interface MoveEvent {
|
|
|
16
16
|
cancel?: () => void;
|
|
17
17
|
}
|
|
18
18
|
export declare class MoveGesture extends Gesture<MoveEvent> {
|
|
19
|
-
private attachedEls;
|
|
20
19
|
private prev;
|
|
21
20
|
private lastTime;
|
|
21
|
+
private attachedEl;
|
|
22
22
|
private movement;
|
|
23
23
|
private offset;
|
|
24
24
|
private velocity;
|
|
25
25
|
private startPos;
|
|
26
|
-
attach(
|
|
27
|
-
cancel(): void;
|
|
26
|
+
attach(element: HTMLElement | Window): () => void;
|
|
28
27
|
private onMove;
|
|
29
28
|
private onLeave;
|
|
30
29
|
}
|
|
@@ -16,14 +16,13 @@ export interface ScrollEvent {
|
|
|
16
16
|
cancel?: () => void;
|
|
17
17
|
}
|
|
18
18
|
export declare class ScrollGesture extends Gesture<ScrollEvent> {
|
|
19
|
-
private
|
|
19
|
+
private attachedEl;
|
|
20
20
|
private movement;
|
|
21
21
|
private offset;
|
|
22
22
|
private velocity;
|
|
23
23
|
private prevScroll;
|
|
24
24
|
private lastTime;
|
|
25
25
|
private endTimeout?;
|
|
26
|
-
attach(
|
|
27
|
-
cancel(): void;
|
|
26
|
+
attach(element: HTMLElement | Window): () => void;
|
|
28
27
|
private onScroll;
|
|
29
28
|
}
|
|
@@ -16,13 +16,11 @@ export interface WheelEvent {
|
|
|
16
16
|
cancel?: () => void;
|
|
17
17
|
}
|
|
18
18
|
export declare class WheelGesture extends Gesture<WheelEvent> {
|
|
19
|
-
private attachedEls;
|
|
20
19
|
private movement;
|
|
21
20
|
private offset;
|
|
22
21
|
private velocity;
|
|
23
22
|
private lastTime;
|
|
24
23
|
private endTimeout?;
|
|
25
|
-
attach(
|
|
26
|
-
cancel(): void;
|
|
24
|
+
attach(element: HTMLElement | Window): () => void;
|
|
27
25
|
private onWheel;
|
|
28
26
|
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DependencyList } from 'react';
|
|
2
|
+
type DimensionType = {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
innerWidth: number;
|
|
6
|
+
innerHeight: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function useDimension(callback: (event: DimensionType) => void, deps?: DependencyList): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RefObject, DependencyList } from 'react';
|
|
2
|
+
type MeasurementValue = number | number[];
|
|
3
|
+
interface MeasurementType {
|
|
4
|
+
left: MeasurementValue;
|
|
5
|
+
top: MeasurementValue;
|
|
6
|
+
width: MeasurementValue;
|
|
7
|
+
height: MeasurementValue;
|
|
8
|
+
vLeft: MeasurementValue;
|
|
9
|
+
vTop: MeasurementValue;
|
|
10
|
+
}
|
|
11
|
+
export declare function useMeasure(refs: RefObject<HTMLElement>[], callback: (m: MeasurementType) => void, deps?: DependencyList): void;
|
|
12
|
+
export {};
|