react-ui-animate 5.0.0-rc.1 → 5.0.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +206 -206
  3. package/package.json +63 -54
  4. package/dist/animation/AnimationConfig.d.ts +0 -63
  5. package/dist/animation/Value.d.ts +0 -12
  6. package/dist/animation/controllers.d.ts +0 -41
  7. package/dist/animation/hooks/index.d.ts +0 -3
  8. package/dist/animation/hooks/useAnimatedList.d.ts +0 -24
  9. package/dist/animation/hooks/useMount.d.ts +0 -12
  10. package/dist/animation/hooks/useValue.d.ts +0 -15
  11. package/dist/animation/index.d.ts +0 -4
  12. package/dist/animation/interpolation/colors.d.ts +0 -25
  13. package/dist/animation/interpolation/index.d.ts +0 -1
  14. package/dist/animation/interpolation/interpolateNumbers.d.ts +0 -8
  15. package/dist/animation/types.d.ts +0 -27
  16. package/dist/gestures/controllers/DragGesture.d.ts +0 -17
  17. package/dist/gestures/controllers/Gesture.d.ts +0 -20
  18. package/dist/gestures/controllers/MouseMoveGesture.d.ts +0 -13
  19. package/dist/gestures/controllers/ScrollGesture.d.ts +0 -14
  20. package/dist/gestures/controllers/WheelGesture.d.ts +0 -15
  21. package/dist/gestures/controllers/index.d.ts +0 -4
  22. package/dist/gestures/helpers/eventAttacher.d.ts +0 -11
  23. package/dist/gestures/helpers/index.d.ts +0 -1
  24. package/dist/gestures/helpers/math.d.ts +0 -34
  25. package/dist/gestures/helpers/withDefault.d.ts +0 -4
  26. package/dist/gestures/hooks/index.d.ts +0 -5
  27. package/dist/gestures/hooks/useDrag.d.ts +0 -4
  28. package/dist/gestures/hooks/useGesture.d.ts +0 -9
  29. package/dist/gestures/hooks/useMouseMove.d.ts +0 -4
  30. package/dist/gestures/hooks/useRecognizer.d.ts +0 -10
  31. package/dist/gestures/hooks/useScroll.d.ts +0 -4
  32. package/dist/gestures/hooks/useWheel.d.ts +0 -4
  33. package/dist/gestures/types/index.d.ts +0 -51
  34. package/dist/hooks/index.d.ts +0 -3
  35. package/dist/hooks/useMeasure.d.ts +0 -14
  36. package/dist/hooks/useOutsideClick.d.ts +0 -2
  37. package/dist/hooks/useWindowDimension.d.ts +0 -9
  38. package/dist/index.d.ts +0 -5
  39. package/dist/index.js +0 -2
  40. package/dist/index.js.map +0 -1
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
- [![npm version](https://badge.fury.io/js/react-ui-animate.svg)](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`, `withEase` — 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
- - `useMouseMove`
169
- - `useScroll`
170
- - `useWheel`
171
- - `useGesture`
172
-
173
- **Example: `useDrag`**
174
-
175
- ```tsx
176
- import React from 'react';
177
- import { useValue, animate, useDrag, withSpring } from 'react-ui-animate';
178
-
179
- export const Draggable: React.FC = () => {
180
- const [translateX, setTranslateX] = useValue(0);
181
-
182
- const bind = useDrag(({ down, movementX }) => {
183
- setTranslateX(down ? movementX : withSpring(0));
184
- });
185
-
186
- return (
187
- <animate.div
188
- {...bind()}
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
+ [![npm version](https://badge.fury.io/js/react-ui-animate.svg)](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.
package/package.json CHANGED
@@ -1,54 +1,63 @@
1
- {
2
- "name": "react-ui-animate",
3
- "version": "5.0.0-rc.1",
4
- "description": "React library for gestures and animation",
5
- "main": "dist/index.js",
6
- "peerDependencies": {
7
- "react": ">=16.8.0 || >=17.0.0 || >=18.0.0"
8
- },
9
- "dependencies": {
10
- "@raidipesh78/re-motion": "^5.0.0"
11
- },
12
- "devDependencies": {
13
- "@rollup/plugin-terser": "^0.4.4",
14
- "@types/jest": "^29.5.12",
15
- "@types/node": "^20.14.9",
16
- "@types/react": "^18.3.3",
17
- "@types/react-dom": "^18.3.0",
18
- "@types/resize-observer-browser": "^0.1.11",
19
- "babel-core": "^5.8.38",
20
- "babel-runtime": "^6.26.0",
21
- "react": "^18.3.1",
22
- "react-dom": "^18.3.1",
23
- "rimraf": "^6.0.1",
24
- "rollup": "^4.18.0",
25
- "rollup-plugin-typescript2": "^0.36.0",
26
- "typescript": "^5.5.2"
27
- },
28
- "scripts": {
29
- "clean": "rimraf -rf dist",
30
- "build": "npm run clean && rollup -c",
31
- "start": "npm run clean && rollup -c -w",
32
- "test": "echo \"Error: no test specified\" && exit 1",
33
- "version:minor": "npm version --no-git-tag-version minor",
34
- "version:major": "npm version --no-git-tag-version major",
35
- "version:patch": "npm version --no-git-tag-version patch",
36
- "publish:next": "npm publish --tag next",
37
- "publish:latest": "npm publish --tag latest"
38
- },
39
- "repository": {
40
- "type": "git",
41
- "url": "git+https://github.com/dipeshrai123/react-ui-animate.git"
42
- },
43
- "keywords": [
44
- "gesture",
45
- "animation",
46
- "react-ui-animate"
47
- ],
48
- "author": "Dipesh Rai",
49
- "license": "MIT",
50
- "bugs": {
51
- "url": "https://github.com/dipeshrai123/react-ui-animate/issues"
52
- },
53
- "homepage": "https://github.com/dipeshrai123/react-ui-animate#readme"
54
- }
1
+ {
2
+ "name": "react-ui-animate",
3
+ "version": "5.0.0-rc.11",
4
+ "description": "React library for gestures and animation",
5
+ "main": "dist/index.js",
6
+ "peerDependencies": {
7
+ "react": ">=16.8.0 || >=17.0.0 || >=18.0.0"
8
+ },
9
+ "dependencies": {
10
+ "@raidipesh78/re-motion": "^5.2.3"
11
+ },
12
+ "devDependencies": {
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",
19
+ "@types/jest": "^29.5.12",
20
+ "@types/node": "^20.14.9",
21
+ "@types/react": "^18.3.3",
22
+ "@types/react-dom": "^18.3.0",
23
+ "@types/resize-observer-browser": "^0.1.11",
24
+ "babel-core": "^5.8.38",
25
+ "babel-runtime": "^6.26.0",
26
+ "react": "^18.3.1",
27
+ "react-dom": "^18.3.1",
28
+ "rimraf": "^6.0.1",
29
+ "rollup": "^4.18.0",
30
+ "rollup-plugin-typescript2": "^0.36.0",
31
+ "semantic-release": "^24.2.6",
32
+ "typescript": "^5.5.2"
33
+ },
34
+ "scripts": {
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",
39
+ "test": "echo \"Error: no test specified\" && exit 1",
40
+ "version:minor": "npm version minor",
41
+ "version:major": "npm version major",
42
+ "version:patch": "npm version patch",
43
+ "version:rc": "npm version prerelease --preid=rc",
44
+ "version:prepatch": "npm version prepatch --preid=rc",
45
+ "publish:next": "npm publish --tag next",
46
+ "publish:latest": "npm publish --tag latest"
47
+ },
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/dipeshrai123/react-ui-animate.git"
51
+ },
52
+ "keywords": [
53
+ "gesture",
54
+ "animation",
55
+ "react-ui-animate"
56
+ ],
57
+ "author": "Dipesh Rai",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/dipeshrai123/react-ui-animate/issues"
61
+ },
62
+ "homepage": "https://github.com/dipeshrai123/react-ui-animate#readme"
63
+ }
@@ -1,63 +0,0 @@
1
- import { Easing } from '@raidipesh78/re-motion';
2
- export declare const AnimationConfig: {
3
- Timing: {
4
- BOUNCE: {
5
- duration: number;
6
- easing: typeof Easing.bounce;
7
- };
8
- EASE_IN: {
9
- duration: number;
10
- easing: (t: number) => number;
11
- };
12
- EASE_OUT: {
13
- duration: number;
14
- easing: (t: number) => number;
15
- };
16
- EASE_IN_OUT: {
17
- duration: number;
18
- easing: (t: number) => number;
19
- };
20
- POWER1: {
21
- duration: number;
22
- easing: (t: number) => number;
23
- };
24
- POWER2: {
25
- duration: number;
26
- easing: (t: number) => number;
27
- };
28
- POWER3: {
29
- duration: number;
30
- easing: (t: number) => number;
31
- };
32
- POWER4: {
33
- duration: number;
34
- easing: (t: number) => number;
35
- };
36
- LINEAR: {
37
- duration: number;
38
- easing: typeof Easing.linear;
39
- };
40
- };
41
- Spring: {
42
- ELASTIC: {
43
- mass: number;
44
- friction: number;
45
- tension: number;
46
- };
47
- EASE: {
48
- mass: number;
49
- friction: number;
50
- tension: number;
51
- };
52
- STIFF: {
53
- mass: number;
54
- friction: number;
55
- tension: number;
56
- };
57
- WOBBLE: {
58
- mass: number;
59
- friction: number;
60
- tension: number;
61
- };
62
- };
63
- };
@@ -1,12 +0,0 @@
1
- import { MotionValue } from '@raidipesh78/re-motion';
2
- import { ToValue } from './types';
3
- export declare class Value<V extends number | string> {
4
- private animation;
5
- private unsubscribe?;
6
- constructor(initial: V);
7
- set(u: MotionValue<V> | ToValue<V>): void;
8
- private buildDriver;
9
- get value(): MotionValue<V>;
10
- get current(): V;
11
- destroy(): void;
12
- }