Files
SnowLuma/.pnpm-store/v11/files/6a/39f178cf56aa32c951abcb4ecc65c74860020b987bb5d6a78c7854b8387f45f548c550a2afaccf4c28574afcc11106ee7f6b4cc5f264efe492f47885efd08f
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

33 lines
1.1 KiB
Plaintext

import { motionValue } from '../../value/index.mjs';
import { resolveVariant } from './resolve-dynamic-variants.mjs';
import { isKeyframesTarget } from './is-keyframes-target.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 resolveFinalValueInKeyframes(v) {
// TODO maybe throw if v.length - 1 is placeholder token?
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
}
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 };
//# sourceMappingURL=setters.mjs.map