framer-motion 5.4.0-beta.4 → 5.4.0-beta.5
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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useFrame } from '@react-three/fiber';
|
|
2
|
+
import { useMotionValue } from '../../../value/use-motion-value.mjs';
|
|
3
|
+
|
|
4
|
+
function useTime() {
|
|
5
|
+
var time = useMotionValue(0);
|
|
6
|
+
useFrame(function (state) { return time.set(state.clock.getElapsedTime()); });
|
|
7
|
+
return time;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { useTime };
|
package/dist/es/three-entry.mjs
CHANGED
|
@@ -3029,5 +3029,44 @@ function MotionCanvas(_a) {
|
|
|
3029
3029
|
React__namespace.createElement(MotionContext.Provider, { value: motionContext }, children)));
|
|
3030
3030
|
}
|
|
3031
3031
|
|
|
3032
|
+
/**
|
|
3033
|
+
* Creates a `MotionValue` to track the state and velocity of a value.
|
|
3034
|
+
*
|
|
3035
|
+
* Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
|
|
3036
|
+
*
|
|
3037
|
+
* ```jsx
|
|
3038
|
+
* export const MyComponent = () => {
|
|
3039
|
+
* const scale = useMotionValue(1)
|
|
3040
|
+
*
|
|
3041
|
+
* return <motion.div style={{ scale }} />
|
|
3042
|
+
* }
|
|
3043
|
+
* ```
|
|
3044
|
+
*
|
|
3045
|
+
* @param initial - The initial state.
|
|
3046
|
+
*
|
|
3047
|
+
* @public
|
|
3048
|
+
*/
|
|
3049
|
+
function useMotionValue(initial) {
|
|
3050
|
+
var value = useConstant(function () { return motionValue(initial); });
|
|
3051
|
+
/**
|
|
3052
|
+
* If this motion value is being used in static mode, like on
|
|
3053
|
+
* the Framer canvas, force components to rerender when the motion
|
|
3054
|
+
* value is updated.
|
|
3055
|
+
*/
|
|
3056
|
+
var isStatic = React.useContext(MotionConfigContext).isStatic;
|
|
3057
|
+
if (isStatic) {
|
|
3058
|
+
var _a = tslib.__read(React.useState(initial), 2), setLatest_1 = _a[1];
|
|
3059
|
+
React.useEffect(function () { return value.onChange(setLatest_1); }, []);
|
|
3060
|
+
}
|
|
3061
|
+
return value;
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
function useTime() {
|
|
3065
|
+
var time = useMotionValue(0);
|
|
3066
|
+
fiber.useFrame(function (state) { return time.set(state.clock.getElapsedTime()); });
|
|
3067
|
+
return time;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3032
3070
|
exports.MotionCanvas = MotionCanvas;
|
|
3033
3071
|
exports.motion = motion;
|
|
3072
|
+
exports.useTime = useTime;
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useTime(): import("../../..").MotionValue<number>;
|
package/types/three-entry.d.ts
CHANGED