Mission Control Dashboard - Initial implementation
This commit is contained in:
37
node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs
generated
vendored
Normal file
37
node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
function getValueState(visualElement) {
|
||||
const state = [{}, {}];
|
||||
visualElement?.values.forEach((value, key) => {
|
||||
state[0][key] = value.get();
|
||||
state[1][key] = value.getVelocity();
|
||||
});
|
||||
return state;
|
||||
}
|
||||
function resolveVariantFromProps(props, definition, custom, visualElement) {
|
||||
/**
|
||||
* If the variant definition is a function, resolve.
|
||||
*/
|
||||
if (typeof definition === "function") {
|
||||
const [current, velocity] = getValueState(visualElement);
|
||||
definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
|
||||
}
|
||||
/**
|
||||
* If the variant definition is a variant label, or
|
||||
* the function returned a variant label, resolve.
|
||||
*/
|
||||
if (typeof definition === "string") {
|
||||
definition = props.variants && props.variants[definition];
|
||||
}
|
||||
/**
|
||||
* At this point we've resolved both functions and variant labels,
|
||||
* but the resolved variant label might itself have been a function.
|
||||
* If so, resolve. This can only have returned a valid target object.
|
||||
*/
|
||||
if (typeof definition === "function") {
|
||||
const [current, velocity] = getValueState(visualElement);
|
||||
definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
|
||||
}
|
||||
return definition;
|
||||
}
|
||||
|
||||
export { resolveVariantFromProps };
|
||||
//# sourceMappingURL=resolve-variants.mjs.map
|
||||
Reference in New Issue
Block a user