Viewing File: /home/ubuntu/route-and-root-frontend-base/node_modules/framer-motion/dist/es/value/use-velocity.mjs
import { useEffect } from 'react';
import { useMotionValue } from './use-motion-value.mjs';
/**
* Creates a `MotionValue` that updates when the velocity of the provided `MotionValue` changes.
*
* ```javascript
* const x = useMotionValue(0)
* const xVelocity = useVelocity(x)
* const xAcceleration = useVelocity(xVelocity)
* ```
*
* @public
*/
function useVelocity(value) {
var velocity = useMotionValue(value.getVelocity());
useEffect(function () {
return value.velocityUpdateSubscribers.add(function (newVelocity) {
velocity.set(newVelocity);
});
}, [value]);
return velocity;
}
export { useVelocity };
Back to Directory
File Manager