Files
Webklar.com/node_modules/framer-motion/dist/es/value/use-will-change/add-will-change.mjs
Basilosaurusrex f027651f9b main repo
2025-11-24 18:09:40 +01:00

21 lines
718 B
JavaScript

import { MotionGlobalConfig } from 'motion-utils';
import { isWillChangeMotionValue } from './is.mjs';
function addValueToWillChange(visualElement, key) {
const willChange = visualElement.getValue("willChange");
/**
* It could be that a user has set willChange to a regular MotionValue,
* in which case we can't add the value to it.
*/
if (isWillChangeMotionValue(willChange)) {
return willChange.add(key);
}
else if (!willChange && MotionGlobalConfig.WillChange) {
const newWillChange = new MotionGlobalConfig.WillChange("auto");
visualElement.addValue("willChange", newWillChange);
newWillChange.add(key);
}
}
export { addValueToWillChange };