securityos/node_modules/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs

25 lines
893 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
import { resolveVariantFromProps } from './resolve-variants.mjs';
/**
* Creates an object containing the latest state of every MotionValue on a VisualElement
*/
function getCurrent(visualElement) {
const current = {};
visualElement.values.forEach((value, key) => (current[key] = value.get()));
return current;
}
/**
* Creates an object containing the latest velocity of every MotionValue on a VisualElement
*/
function getVelocity(visualElement) {
const velocity = {};
visualElement.values.forEach((value, key) => (velocity[key] = value.getVelocity()));
return velocity;
}
function resolveVariant(visualElement, definition, custom) {
const props = visualElement.getProps();
return resolveVariantFromProps(props, definition, custom !== undefined ? custom : props.custom, getCurrent(visualElement), getVelocity(visualElement));
}
export { resolveVariant };