| 123456789101112131415161718192021222324252627 |
- import { motionValue } from 'motion-dom';
- import { resolveFinalValueInKeyframes } from '../../utils/resolve-value.mjs';
- import { resolveVariant } from './resolve-dynamic-variants.mjs';
- /**
- * Set VisualElement's MotionValue, creating a new MotionValue for it if
- * it doesn't exist.
- */
- function setMotionValue(visualElement, key, value) {
- if (visualElement.hasValue(key)) {
- visualElement.getValue(key).set(value);
- }
- else {
- visualElement.addValue(key, motionValue(value));
- }
- }
- function setTarget(visualElement, definition) {
- const resolved = resolveVariant(visualElement, definition);
- let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
- target = { ...target, ...transitionEnd };
- for (const key in target) {
- const value = resolveFinalValueInKeyframes(target[key]);
- setMotionValue(visualElement, key, value);
- }
- }
- export { setTarget };
|