physics-animator 0.14.0 → 0.15.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/README.md
CHANGED
|
@@ -11,6 +11,11 @@ const useSpringValue_js_1 = require("./useSpringValue.js");
|
|
|
11
11
|
*/
|
|
12
12
|
function useSpringState(options) {
|
|
13
13
|
const [state, setState] = (0, react_1.useState)(options.initial);
|
|
14
|
-
(0,
|
|
15
|
-
|
|
14
|
+
const [target, setTarget] = (0, react_1.useState)(options.initial);
|
|
15
|
+
(0, useSpringValue_js_1.useSpringValue)({
|
|
16
|
+
...options,
|
|
17
|
+
initial: options.initial,
|
|
18
|
+
target
|
|
19
|
+
}, setState);
|
|
20
|
+
return { state, target, setTarget };
|
|
16
21
|
}
|
|
@@ -8,6 +8,11 @@ import { useSpringValue } from "./useSpringValue.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export function useSpringState(options) {
|
|
10
10
|
const [state, setState] = useState(options.initial);
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const [target, setTarget] = useState(options.initial);
|
|
12
|
+
useSpringValue({
|
|
13
|
+
...options,
|
|
14
|
+
initial: options.initial,
|
|
15
|
+
target
|
|
16
|
+
}, setState);
|
|
17
|
+
return { state, target, setTarget };
|
|
13
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Animator } from "../Animator.js";
|
|
2
2
|
import { SpringParameters } from "../animators/SpringAnimator.js";
|
|
3
|
+
type WidenNumber<T> = T extends number ? number : T;
|
|
3
4
|
/**
|
|
4
5
|
* A value that animates to a target value using a spring animation.
|
|
5
6
|
* This **will** cause a re-render when the value changes.
|
|
@@ -11,5 +12,9 @@ export declare function useSpringState<T extends number | number[] | {
|
|
|
11
12
|
}>(options: {
|
|
12
13
|
animator?: Animator;
|
|
13
14
|
initial: T;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
} & SpringParameters): {
|
|
16
|
+
readonly state: WidenNumber<T>;
|
|
17
|
+
readonly target: WidenNumber<T>;
|
|
18
|
+
readonly setTarget: import("react").Dispatch<import("react").SetStateAction<WidenNumber<T>>>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
package/package.json
CHANGED