react-ui-animate 2.0.0 → 3.0.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/LICENSE +21 -21
- package/README.md +115 -115
- package/dist/animation/core/controllers/Animation.d.ts +16 -0
- package/dist/animation/core/controllers/FluidValue.d.ts +32 -0
- package/dist/animation/core/controllers/RequestAnimationFrame.d.ts +8 -0
- package/dist/animation/core/controllers/SpringAnimation.d.ts +41 -0
- package/dist/animation/core/controllers/TimingAnimation.d.ts +35 -0
- package/dist/animation/core/easing/Bezier.d.ts +8 -0
- package/dist/animation/core/easing/Easing.d.ts +40 -0
- package/dist/animation/core/helpers/camelCaseToKebabCase.d.ts +8 -0
- package/dist/animation/core/helpers/getCleanProps.d.ts +10 -0
- package/dist/animation/core/helpers/getCssValue.d.ts +8 -0
- package/dist/animation/core/helpers/index.d.ts +5 -0
- package/dist/animation/core/helpers/isDefined.d.ts +12 -0
- package/dist/animation/core/helpers/isFluidValue.d.ts +6 -0
- package/dist/animation/core/index.d.ts +11 -0
- package/dist/animation/core/interpolation/Colors.d.ts +25 -0
- package/dist/animation/core/interpolation/Interpolation.d.ts +80 -0
- package/dist/animation/core/interpolation/__tests__/Colors.test.d.ts +1 -0
- package/dist/animation/core/react/fluid.d.ts +6 -0
- package/dist/animation/core/react/makeFluid.d.ts +30 -0
- package/dist/animation/core/react/transforms.d.ts +6 -0
- package/dist/animation/core/react/useFluidValue.d.ts +9 -0
- package/dist/animation/core/react/useMount.d.ts +20 -0
- package/dist/animation/lib/animationType.d.ts +15 -0
- package/dist/animation/lib/getInitialConfig.d.ts +3 -0
- package/dist/animation/lib/index.d.ts +5 -0
- package/dist/animation/{interpolation.d.ts → lib/interpolation.d.ts} +20 -21
- package/dist/animation/lib/modules/AnimatedBlock.d.ts +8 -0
- package/dist/animation/lib/modules/AnimatedImage.d.ts +8 -0
- package/dist/animation/lib/modules/AnimatedInline.d.ts +8 -0
- package/dist/animation/lib/modules/MountedBlock.d.ts +29 -0
- package/dist/animation/{modules → lib/modules}/ScrollableBlock.d.ts +22 -21
- package/dist/animation/{modules → lib/modules}/TransitionBlock.d.ts +18 -17
- package/dist/animation/{modules → lib/modules}/index.d.ts +6 -6
- package/dist/animation/{useAnimatedValue.d.ts → lib/useAnimatedValue.d.ts} +17 -22
- package/dist/animation/{useMountedValue.d.ts → lib/useMountedValue.d.ts} +14 -15
- package/dist/gestures/controllers/DragGesture.d.ts +17 -17
- package/dist/gestures/controllers/Gesture.d.ts +20 -20
- package/dist/gestures/controllers/MouseMoveGesture.d.ts +13 -13
- package/dist/gestures/controllers/ScrollGesture.d.ts +14 -14
- package/dist/gestures/controllers/WheelGesture.d.ts +15 -15
- package/dist/gestures/controllers/index.d.ts +4 -4
- package/dist/gestures/helpers/eventAttacher.d.ts +11 -0
- package/dist/gestures/helpers/index.d.ts +1 -0
- package/dist/gestures/{math.d.ts → helpers/math.d.ts} +34 -34
- package/dist/gestures/{withDefault.d.ts → helpers/withDefault.d.ts} +4 -4
- package/dist/gestures/hooks/index.d.ts +5 -5
- package/dist/gestures/hooks/useDrag.d.ts +4 -4
- package/dist/gestures/hooks/useGesture.d.ts +9 -9
- package/dist/gestures/hooks/useMouseMove.d.ts +4 -4
- package/dist/gestures/hooks/useRecognizer.d.ts +10 -10
- package/dist/gestures/hooks/useScroll.d.ts +4 -4
- package/dist/gestures/hooks/useWheel.d.ts +4 -4
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/useMeasure.d.ts +14 -14
- package/dist/hooks/useOutsideClick.d.ts +2 -2
- package/dist/hooks/useWindowDimension.d.ts +9 -9
- package/dist/index.d.ts +9 -5
- package/dist/index.js +1 -1191
- package/dist/index.js.map +1 -1
- package/dist/utils/delay.d.ts +5 -5
- package/dist/utils/index.d.ts +1 -2
- package/package.json +49 -48
- package/.vscode/settings.json +0 -3
- package/dist/animation/animationType.d.ts +0 -15
- package/dist/animation/getInitialConfig.d.ts +0 -3
- package/dist/animation/index.d.ts +0 -6
- 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/dist/animation/modules/MountedBlock.d.ts +0 -18
- package/dist/gestures/eventAttacher.d.ts +0 -11
- package/dist/gestures/index.d.ts +0 -2
- package/dist/gestures/types.d.ts +0 -51
- package/dist/utils/isDefined.d.ts +0 -1
- package/rollup.config.js +0 -18
- package/src/animation/animationType.ts +0 -17
- package/src/animation/getInitialConfig.ts +0 -61
- package/src/animation/index.ts +0 -10
- package/src/animation/interpolation.ts +0 -48
- package/src/animation/modules/AnimatedBlock.ts +0 -8
- package/src/animation/modules/AnimatedImage.ts +0 -8
- package/src/animation/modules/AnimatedInline.ts +0 -8
- package/src/animation/modules/MountedBlock.tsx +0 -25
- package/src/animation/modules/ScrollableBlock.tsx +0 -69
- package/src/animation/modules/TransitionBlock.tsx +0 -29
- package/src/animation/modules/index.ts +0 -6
- package/src/animation/useAnimatedValue.ts +0 -71
- package/src/animation/useMountedValue.ts +0 -19
- package/src/gestures/controllers/DragGesture.ts +0 -177
- package/src/gestures/controllers/Gesture.ts +0 -54
- package/src/gestures/controllers/MouseMoveGesture.ts +0 -111
- package/src/gestures/controllers/ScrollGesture.ts +0 -107
- package/src/gestures/controllers/WheelGesture.ts +0 -123
- package/src/gestures/controllers/index.ts +0 -4
- package/src/gestures/eventAttacher.ts +0 -67
- package/src/gestures/hooks/index.ts +0 -5
- package/src/gestures/hooks/useDrag.ts +0 -14
- package/src/gestures/hooks/useGesture.ts +0 -38
- package/src/gestures/hooks/useMouseMove.ts +0 -11
- package/src/gestures/hooks/useRecognizer.ts +0 -59
- package/src/gestures/hooks/useScroll.ts +0 -11
- package/src/gestures/hooks/useWheel.ts +0 -11
- package/src/gestures/index.ts +0 -2
- package/src/gestures/math.ts +0 -120
- package/src/gestures/types.ts +0 -49
- package/src/gestures/withDefault.ts +0 -3
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useMeasure.ts +0 -133
- package/src/hooks/useOutsideClick.ts +0 -36
- package/src/hooks/useWindowDimension.ts +0 -59
- package/src/index.ts +0 -5
- package/src/utils/delay.ts +0 -9
- package/src/utils/index.ts +0 -2
- package/src/utils/isDefined.ts +0 -4
- package/tsconfig.json +0 -25
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,115 +1,115 @@
|
|
|
1
|
-
# React UI Animate
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/react-ui-animate)
|
|
4
|
-
|
|
5
|
-
> React library for gestures and animation
|
|
6
|
-
|
|
7
|
-
### Install
|
|
8
|
-
|
|
9
|
-
Install with npm:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm i react-ui-animate
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
or
|
|
16
|
-
Install with yarn:
|
|
17
|
-
|
|
18
|
-
```sh
|
|
19
|
-
yarn add react-ui-animate
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Getting Started
|
|
23
|
-
|
|
24
|
-
`react-ui-animate` provides lots of easy to use APIs to create smooth animations and gestures.
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
import { AnimatedBlock, useAnimatedValue } from "react-ui-animate";
|
|
28
|
-
|
|
29
|
-
export default function () {
|
|
30
|
-
const opacity = useAnimatedValue(0); // It initializes opacity object with value 0.
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div>
|
|
34
|
-
{/* AnimatedBlock component can read useAnimatedValue() */}
|
|
35
|
-
<AnimatedBlock
|
|
36
|
-
style={{
|
|
37
|
-
opacity: opacity.value, // using opacity with value property
|
|
38
|
-
width: 100,
|
|
39
|
-
padding: 20,
|
|
40
|
-
background: "#39F",
|
|
41
|
-
}}
|
|
42
|
-
>
|
|
43
|
-
ANIMATED
|
|
44
|
-
</AnimatedBlock>
|
|
45
|
-
|
|
46
|
-
{/* Assigning value to 1 auto animates from initialized value 0 to 1 smoothly */}
|
|
47
|
-
<button onClick={() => (opacity.value = 1)}>Animate Me</button>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Animates opacity from 0 to 1.
|
|
54
|
-
|
|
55
|
-
#### `useAnimatedValue()`
|
|
56
|
-
|
|
57
|
-
`useAnimatedValue()` is very flexible and powerful hook that lets you define animated values. It accepts a value and returns a node with same value on `value` property. Whenever `value` property is assigned to another value, it auto animates from one value to another.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
const opacity = useAnimatedValue(0); // initialize with 0 opacity
|
|
61
|
-
|
|
62
|
-
...
|
|
63
|
-
style={{
|
|
64
|
-
opacity: opacity.value // access with `.value`
|
|
65
|
-
}}
|
|
66
|
-
...
|
|
67
|
-
|
|
68
|
-
...
|
|
69
|
-
onClick={() => opacity.value = 1} // Assignment
|
|
70
|
-
...
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
#### `AnimatedBlock`
|
|
74
|
-
|
|
75
|
-
`AnimatedBlock` is a `div` component which can accept the animation node from `useAnimatedValue()` hook.
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
const width = useAnimatedValue(100);
|
|
79
|
-
|
|
80
|
-
<AnimatedBlock
|
|
81
|
-
style={{
|
|
82
|
-
width: width.value,
|
|
83
|
-
height: 100,
|
|
84
|
-
backgroundColor: "#39f",
|
|
85
|
-
}}
|
|
86
|
-
/>;
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
#### `interpolate`
|
|
90
|
-
|
|
91
|
-
The `interpolate()` function allows animated node value to map from input ranges to different output ranges. By default, it will extrapolate the curve beyond the ranges given, but you can also have it clamp the output value.
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
import { useAnimatedValue, AnimatedBlock, interpolate } from "react-ui-animate";
|
|
95
|
-
|
|
96
|
-
const width = useAnimatedValue(100);
|
|
97
|
-
|
|
98
|
-
<AnimatedBlock
|
|
99
|
-
style={{
|
|
100
|
-
width: width.value,
|
|
101
|
-
height: 100,
|
|
102
|
-
backgroundColor: interpolate(width.value, [100, 200], ["red", "blue"]),
|
|
103
|
-
}}
|
|
104
|
-
/>;
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
`backgroundColor` is interpolated from input range `[100, 200]` to output range `["red", "blue"]`. So, when the width changes from 100 to 200, `backgroundColor` will change from `red` to `blue`.
|
|
108
|
-
|
|
109
|
-
## Documentation
|
|
110
|
-
|
|
111
|
-
The official documentation are now published at http://react-ui-animate.js.org/
|
|
112
|
-
|
|
113
|
-
## License
|
|
114
|
-
|
|
115
|
-
MIT
|
|
1
|
+
# React UI Animate
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/react-ui-animate)
|
|
4
|
+
|
|
5
|
+
> React library for gestures and animation
|
|
6
|
+
|
|
7
|
+
### Install
|
|
8
|
+
|
|
9
|
+
Install with npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i react-ui-animate
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or
|
|
16
|
+
Install with yarn:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
yarn add react-ui-animate
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Getting Started
|
|
23
|
+
|
|
24
|
+
`react-ui-animate` provides lots of easy to use APIs to create smooth animations and gestures.
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
import { AnimatedBlock, useAnimatedValue } from "react-ui-animate";
|
|
28
|
+
|
|
29
|
+
export default function () {
|
|
30
|
+
const opacity = useAnimatedValue(0); // It initializes opacity object with value 0.
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div>
|
|
34
|
+
{/* AnimatedBlock component can read useAnimatedValue() */}
|
|
35
|
+
<AnimatedBlock
|
|
36
|
+
style={{
|
|
37
|
+
opacity: opacity.value, // using opacity with value property
|
|
38
|
+
width: 100,
|
|
39
|
+
padding: 20,
|
|
40
|
+
background: "#39F",
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
ANIMATED
|
|
44
|
+
</AnimatedBlock>
|
|
45
|
+
|
|
46
|
+
{/* Assigning value to 1 auto animates from initialized value 0 to 1 smoothly */}
|
|
47
|
+
<button onClick={() => (opacity.value = 1)}>Animate Me</button>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Animates opacity from 0 to 1.
|
|
54
|
+
|
|
55
|
+
#### `useAnimatedValue()`
|
|
56
|
+
|
|
57
|
+
`useAnimatedValue()` is very flexible and powerful hook that lets you define animated values. It accepts a value and returns a node with same value on `value` property. Whenever `value` property is assigned to another value, it auto animates from one value to another.
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
const opacity = useAnimatedValue(0); // initialize with 0 opacity
|
|
61
|
+
|
|
62
|
+
...
|
|
63
|
+
style={{
|
|
64
|
+
opacity: opacity.value // access with `.value`
|
|
65
|
+
}}
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
...
|
|
69
|
+
onClick={() => opacity.value = 1} // Assignment
|
|
70
|
+
...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### `AnimatedBlock`
|
|
74
|
+
|
|
75
|
+
`AnimatedBlock` is a `div` component which can accept the animation node from `useAnimatedValue()` hook.
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
const width = useAnimatedValue(100);
|
|
79
|
+
|
|
80
|
+
<AnimatedBlock
|
|
81
|
+
style={{
|
|
82
|
+
width: width.value,
|
|
83
|
+
height: 100,
|
|
84
|
+
backgroundColor: "#39f",
|
|
85
|
+
}}
|
|
86
|
+
/>;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### `interpolate`
|
|
90
|
+
|
|
91
|
+
The `interpolate()` function allows animated node value to map from input ranges to different output ranges. By default, it will extrapolate the curve beyond the ranges given, but you can also have it clamp the output value.
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
import { useAnimatedValue, AnimatedBlock, interpolate } from "react-ui-animate";
|
|
95
|
+
|
|
96
|
+
const width = useAnimatedValue(100);
|
|
97
|
+
|
|
98
|
+
<AnimatedBlock
|
|
99
|
+
style={{
|
|
100
|
+
width: width.value,
|
|
101
|
+
height: 100,
|
|
102
|
+
backgroundColor: interpolate(width.value, [100, 200], ["red", "blue"]),
|
|
103
|
+
}}
|
|
104
|
+
/>;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`backgroundColor` is interpolated from input range `[100, 200]` to output range `["red", "blue"]`. So, when the width changes from 100 to 200, `backgroundColor` will change from `red` to `blue`.
|
|
108
|
+
|
|
109
|
+
## Documentation
|
|
110
|
+
|
|
111
|
+
The official documentation are now published at http://react-ui-animate.js.org/
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ResultType } from '../types/animation';
|
|
2
|
+
/**
|
|
3
|
+
* Base Animation class
|
|
4
|
+
*/
|
|
5
|
+
export declare class Animation {
|
|
6
|
+
_active: boolean;
|
|
7
|
+
_onEnd: any;
|
|
8
|
+
/**
|
|
9
|
+
* it is necessary to add _onRest function as well
|
|
10
|
+
* because _onEnd is always re-assigned with onUpdate callback
|
|
11
|
+
* so that _onRest function is not fired, so we have to duplicate it
|
|
12
|
+
*/
|
|
13
|
+
_onRest?: any;
|
|
14
|
+
_debounceOnEnd(result: ResultType): void;
|
|
15
|
+
stop(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Length, ResultType, SubscribeFn, FluidValueConfig, OnUpdateFn, AssignValue } from '../types/animation';
|
|
2
|
+
import type { Fn } from '../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a fluid value that can animate between states.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FluidValue {
|
|
7
|
+
_subscribe: SubscribeFn;
|
|
8
|
+
_value: Length;
|
|
9
|
+
_config?: FluidValueConfig;
|
|
10
|
+
_currentValue: {
|
|
11
|
+
current: Length;
|
|
12
|
+
};
|
|
13
|
+
_subscriptions: Map<{
|
|
14
|
+
uuid: number;
|
|
15
|
+
property: string;
|
|
16
|
+
}, OnUpdateFn>;
|
|
17
|
+
get: () => Length;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new FluidValue instance.
|
|
20
|
+
* @param initialValue - The initial value of the fluid value.
|
|
21
|
+
* @param config - Optional configuration for the fluid value.
|
|
22
|
+
*/
|
|
23
|
+
constructor(initialValue: Length, config?: FluidValueConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Animates from the current value to the updated value.
|
|
26
|
+
* Determines whether to perform a multi-stage or single-stage transition.
|
|
27
|
+
* @param updatedValue - The value to animate to, or a function that defines a multi-stage transition.
|
|
28
|
+
* @param config - Optional configuration for the animation.
|
|
29
|
+
* @param callback - Optional callback to be called after the animation ends.
|
|
30
|
+
*/
|
|
31
|
+
setValue(updatedValue: AssignValue, config?: FluidValueConfig, callback?: Fn<ResultType, void>): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Animation } from './Animation';
|
|
2
|
+
import type { FluidValueConfig, ResultType } from '../types/animation';
|
|
3
|
+
/**
|
|
4
|
+
* Class implementing spring based animation
|
|
5
|
+
*/
|
|
6
|
+
export declare class SpringAnimation extends Animation {
|
|
7
|
+
_overshootClamping: boolean;
|
|
8
|
+
_restDisplacementThreshold: number;
|
|
9
|
+
_restSpeedThreshold: number;
|
|
10
|
+
_initialVelocity?: number;
|
|
11
|
+
_lastVelocity: number;
|
|
12
|
+
_startPosition: number;
|
|
13
|
+
_lastPosition: number;
|
|
14
|
+
_position: number;
|
|
15
|
+
_fromValue: number;
|
|
16
|
+
_toValue: any;
|
|
17
|
+
_mass: number;
|
|
18
|
+
_tension: number;
|
|
19
|
+
_friction: number;
|
|
20
|
+
_lastTime: number;
|
|
21
|
+
_onFrame: (value: number) => void;
|
|
22
|
+
_animationFrame: any;
|
|
23
|
+
_timeout: any;
|
|
24
|
+
_delay: number;
|
|
25
|
+
_onRest?: (value: ResultType) => void;
|
|
26
|
+
_onChange?: (value: number) => void;
|
|
27
|
+
constructor({ initialPosition, config, }: {
|
|
28
|
+
initialPosition: number;
|
|
29
|
+
config?: Omit<FluidValueConfig, 'duration' | 'easing'>;
|
|
30
|
+
});
|
|
31
|
+
onChange(value: number): void;
|
|
32
|
+
onUpdate(): void;
|
|
33
|
+
stop(): void;
|
|
34
|
+
set(toValue: number): void;
|
|
35
|
+
start({ toValue, onFrame, previousAnimation, onEnd, }: {
|
|
36
|
+
toValue: number;
|
|
37
|
+
onFrame: (value: number) => void;
|
|
38
|
+
previousAnimation?: SpringAnimation;
|
|
39
|
+
onEnd?: (result: ResultType) => void;
|
|
40
|
+
}): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Animation } from './Animation';
|
|
2
|
+
import type { FluidValueConfig, ResultType } from '../types/animation';
|
|
3
|
+
/**
|
|
4
|
+
* Class implementing timing based animation
|
|
5
|
+
*/
|
|
6
|
+
export declare class TimingAnimation extends Animation {
|
|
7
|
+
_startTime: number;
|
|
8
|
+
_fromValue: number;
|
|
9
|
+
_toValue: any;
|
|
10
|
+
_duration: number;
|
|
11
|
+
_easing: (value: number) => number;
|
|
12
|
+
_onFrame: (value: number) => void;
|
|
13
|
+
_animationFrame: any;
|
|
14
|
+
_timeout: any;
|
|
15
|
+
_lastPosition: number;
|
|
16
|
+
_position: number;
|
|
17
|
+
_delay: number;
|
|
18
|
+
_tempDuration: number;
|
|
19
|
+
_onRest?: (value: ResultType) => void;
|
|
20
|
+
_onChange?: (value: number) => void;
|
|
21
|
+
constructor({ initialPosition, config, }: {
|
|
22
|
+
initialPosition: number;
|
|
23
|
+
config?: Omit<FluidValueConfig, 'mass' | 'friction' | 'tension'>;
|
|
24
|
+
});
|
|
25
|
+
onChange(value: number): void;
|
|
26
|
+
onUpdate(): void;
|
|
27
|
+
stop(): void;
|
|
28
|
+
set(toValue: number): void;
|
|
29
|
+
start({ toValue, onFrame, previousAnimation, onEnd, }: {
|
|
30
|
+
toValue: number;
|
|
31
|
+
onFrame: (value: number) => void;
|
|
32
|
+
previousAnimation?: TimingAnimation;
|
|
33
|
+
onEnd?: (result: ResultType) => void;
|
|
34
|
+
}): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://github.com/gre/bezier-easing
|
|
3
|
+
* BezierEasing - use bezier curve for transition easing function
|
|
4
|
+
* by Gaëtan Renaudeau 2014 - 2015 – MIT License
|
|
5
|
+
*/
|
|
6
|
+
declare function LinearEasing(x: number): number;
|
|
7
|
+
declare function bezier(mX1: number, mY1: number, mX2: number, mY2: number): typeof LinearEasing;
|
|
8
|
+
export { bezier };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class implements common easing functions. The math is pretty obscure,
|
|
3
|
+
* but this cool website has nice visual illustrations of what they represent:
|
|
4
|
+
* http://xaedes.de/dev/transitions/
|
|
5
|
+
*/
|
|
6
|
+
export declare class Easing {
|
|
7
|
+
static step0(n: number): 0 | 1;
|
|
8
|
+
static step1(n: number): 0 | 1;
|
|
9
|
+
static linear(t: number): number;
|
|
10
|
+
static ease(t: number): number;
|
|
11
|
+
static quad(t: number): number;
|
|
12
|
+
static cubic(t: number): number;
|
|
13
|
+
static poly(n: number): (t: number) => number;
|
|
14
|
+
static sin(t: number): number;
|
|
15
|
+
static circle(t: number): number;
|
|
16
|
+
static exp(t: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* A simple elastic interaction, similar to a spring. Default bounciness
|
|
19
|
+
* is 1, which overshoots a little bit once. 0 bounciness doesn't overshoot
|
|
20
|
+
* at all, and bounciness of N > 1 will overshoot about N times.
|
|
21
|
+
*
|
|
22
|
+
* Wolfram Plots:
|
|
23
|
+
*
|
|
24
|
+
* http://tiny.cc/elastic_b_1 (default bounciness = 1)
|
|
25
|
+
* http://tiny.cc/elastic_b_3 (bounciness = 3)
|
|
26
|
+
*/
|
|
27
|
+
static elastic(bounciness?: number): (t: number) => number;
|
|
28
|
+
static back(s: number): (t: number) => number;
|
|
29
|
+
static bounce(t: number): number;
|
|
30
|
+
static bezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number;
|
|
31
|
+
static in(easing: (t: number) => number): (t: number) => number;
|
|
32
|
+
/**
|
|
33
|
+
* Runs an easing function backwards.
|
|
34
|
+
*/
|
|
35
|
+
static out(easing: (t: number) => number): (t: number) => number;
|
|
36
|
+
/**
|
|
37
|
+
* Makes any easing function symmetrical.
|
|
38
|
+
*/
|
|
39
|
+
static inOut(easing: (t: number) => number): (t: number) => number;
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a camelCase string to kebab-case.
|
|
3
|
+
* e.g. backgroundColor -> background-color
|
|
4
|
+
*
|
|
5
|
+
* @param str - The camelCase string to convert.
|
|
6
|
+
* @returns The converted kebab-case string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function camelCaseToKebabCase(str: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out properties with fluid values from a given props object.
|
|
3
|
+
* This function removes any properties that are considered fluid values,
|
|
4
|
+
* typically those that subscribe to updates and therefore should not be
|
|
5
|
+
* included in a static props object.
|
|
6
|
+
*
|
|
7
|
+
* @param props - The original props object, which may include fluid values.
|
|
8
|
+
* @returns A new props object with fluid values removed.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getCleanProps: ({ style, ...props }: any) => any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getCssValue() function to get css value with unit or without unit
|
|
3
|
+
* it is only for style property - it cannot be used with transform keys
|
|
4
|
+
* @param property - style property
|
|
5
|
+
* @param value - style value
|
|
6
|
+
* @returns - value with unit or without unit
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCssValue(property: string, value: number | string): string | number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is defined (not null or undefined).
|
|
3
|
+
*
|
|
4
|
+
* This utility function helps in determining whether a given value is neither `null` nor `undefined`.
|
|
5
|
+
* It can be useful for validation checks to ensure that a value is properly defined before proceeding
|
|
6
|
+
* with further operations.
|
|
7
|
+
*
|
|
8
|
+
* @param {T} value - The value to check.
|
|
9
|
+
* @returns {boolean} - Returns `true` if the value is neither `null` nor `undefined`, otherwise returns `false`.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare const isDefined: <T>(value: T) => value is T & {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { fluid } from './react/fluid';
|
|
2
|
+
export { makeFluid } from './react/makeFluid';
|
|
3
|
+
export { useFluidValue } from './react/useFluidValue';
|
|
4
|
+
export { useMount } from './react/useMount';
|
|
5
|
+
export { isFluidValue } from './helpers/isFluidValue';
|
|
6
|
+
export { Easing } from './easing/Easing';
|
|
7
|
+
export { interpolate } from './interpolation/Interpolation';
|
|
8
|
+
export { FluidValue } from './controllers/FluidValue';
|
|
9
|
+
export type { FluidValueConfig } from './types/animation';
|
|
10
|
+
export type { UseMountConfig } from './react/useMount';
|
|
11
|
+
export type { ExtrapolateConfig } from './interpolation/Interpolation';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const COLOR_NUMBER_REGEX: RegExp;
|
|
2
|
+
export declare const HEX_NAME_COLOR: RegExp;
|
|
3
|
+
interface classNameType {
|
|
4
|
+
[name: string]: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const colorNames: classNameType;
|
|
7
|
+
export declare function hexToRgba(hex: string): {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
a: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function rgbaToHex(rgba: {
|
|
14
|
+
r: number;
|
|
15
|
+
g: number;
|
|
16
|
+
b: number;
|
|
17
|
+
a: number;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function processColor(color: number | string): {
|
|
20
|
+
r: number;
|
|
21
|
+
g: number;
|
|
22
|
+
b: number;
|
|
23
|
+
a: number;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { FluidValue } from '../controllers/FluidValue';
|
|
2
|
+
type ExtrapolateType = 'identity' | 'extend' | 'clamp';
|
|
3
|
+
export declare const _getTemplateString: (str: string) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Function returns if the template of two strings are matched
|
|
6
|
+
* i.e. they can be interpolated
|
|
7
|
+
* @param str1 - first string
|
|
8
|
+
* @param str2 - second string
|
|
9
|
+
* @returns boolean indicating two strings matched or not
|
|
10
|
+
*/
|
|
11
|
+
export declare const stringMatched: (str1: string, str2: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Function which proccess the
|
|
14
|
+
* hexadecimal colors to its proper formats
|
|
15
|
+
* @param str - string
|
|
16
|
+
* @returns hex color string
|
|
17
|
+
*/
|
|
18
|
+
export declare const getProcessedColor: (str: string) => string;
|
|
19
|
+
export interface ExtrapolateConfig {
|
|
20
|
+
extrapolate?: ExtrapolateType;
|
|
21
|
+
extrapolateRight?: ExtrapolateType;
|
|
22
|
+
extrapolateLeft?: ExtrapolateType;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* interpolateNumbers to interpolate the numeric value
|
|
26
|
+
* @param value - number
|
|
27
|
+
* @param inputRange
|
|
28
|
+
* @param outputRange
|
|
29
|
+
* @param extrapolateConfig
|
|
30
|
+
* @returns - number | string
|
|
31
|
+
*/
|
|
32
|
+
export declare function interpolateNumbers(value: number, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig): any;
|
|
33
|
+
/**
|
|
34
|
+
* interpolateTransitionValue to interpolating TransitionValue type value
|
|
35
|
+
* @param value
|
|
36
|
+
* @param inputRange
|
|
37
|
+
* @param outputRange
|
|
38
|
+
* @param extrapolateConfig
|
|
39
|
+
* @returns TransitionValue
|
|
40
|
+
*/
|
|
41
|
+
export declare const interpolateTransitionValue: (value: FluidValue, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig) => {
|
|
42
|
+
isInterpolation: boolean;
|
|
43
|
+
interpolationConfig: {
|
|
44
|
+
inputRange: number[];
|
|
45
|
+
outputRange: (string | number)[];
|
|
46
|
+
extrapolateConfig: ExtrapolateConfig | undefined;
|
|
47
|
+
};
|
|
48
|
+
_subscribe: import("../types/animation").SubscribeFn;
|
|
49
|
+
_value: import("../types/animation").Length;
|
|
50
|
+
_config?: import("..").FluidValueConfig;
|
|
51
|
+
_currentValue: {
|
|
52
|
+
current: import("../types/animation").Length;
|
|
53
|
+
};
|
|
54
|
+
_subscriptions: Map<{
|
|
55
|
+
uuid: number;
|
|
56
|
+
property: string;
|
|
57
|
+
}, import("../types/animation").OnUpdateFn>;
|
|
58
|
+
get: () => import("../types/animation").Length;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* interpolate function to interpolate both transition
|
|
62
|
+
* as well as numerical value
|
|
63
|
+
* @param value
|
|
64
|
+
* @param inputRange
|
|
65
|
+
* @param outputRange
|
|
66
|
+
* @param extrapolateConfig
|
|
67
|
+
*/
|
|
68
|
+
export declare const interpolate: (value: number | FluidValue, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig) => any;
|
|
69
|
+
/**
|
|
70
|
+
* Determines if two values can be interpolated.
|
|
71
|
+
* This function checks if two values, either numbers or strings,
|
|
72
|
+
* can be interpolated by ensuring they are of the same type and, in the case of strings,
|
|
73
|
+
* that they are compatible for interpolation based on processed color values.
|
|
74
|
+
*
|
|
75
|
+
* @param previousValue - The previous value to compare. Can be a number or a string.
|
|
76
|
+
* @param newValue - The new value to compare. Can be a number or a string.
|
|
77
|
+
* @returns True if interpolation is possible, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
export declare function canInterpolate(previousValue: number | string, newValue: number | string): boolean;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|