first commit
This commit is contained in:
19
node_modules/framer-motion/dist/es/value/use-will-change/WillChangeMotionValue.mjs
generated
vendored
Normal file
19
node_modules/framer-motion/dist/es/value/use-will-change/WillChangeMotionValue.mjs
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { MotionValue, transformProps, acceleratedValues } from 'motion-dom';
|
||||
|
||||
class WillChangeMotionValue extends MotionValue {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.isEnabled = false;
|
||||
}
|
||||
add(name) {
|
||||
if (transformProps.has(name) || acceleratedValues.has(name)) {
|
||||
this.isEnabled = true;
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
update() {
|
||||
this.set(this.isEnabled ? "transform" : "auto");
|
||||
}
|
||||
}
|
||||
|
||||
export { WillChangeMotionValue };
|
||||
20
node_modules/framer-motion/dist/es/value/use-will-change/add-will-change.mjs
generated
vendored
Normal file
20
node_modules/framer-motion/dist/es/value/use-will-change/add-will-change.mjs
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
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 };
|
||||
9
node_modules/framer-motion/dist/es/value/use-will-change/index.mjs
generated
vendored
Normal file
9
node_modules/framer-motion/dist/es/value/use-will-change/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use client";
|
||||
import { useConstant } from '../../utils/use-constant.mjs';
|
||||
import { WillChangeMotionValue } from './WillChangeMotionValue.mjs';
|
||||
|
||||
function useWillChange() {
|
||||
return useConstant(() => new WillChangeMotionValue("auto"));
|
||||
}
|
||||
|
||||
export { useWillChange };
|
||||
7
node_modules/framer-motion/dist/es/value/use-will-change/is.mjs
generated
vendored
Normal file
7
node_modules/framer-motion/dist/es/value/use-will-change/is.mjs
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { isMotionValue } from 'motion-dom';
|
||||
|
||||
function isWillChangeMotionValue(value) {
|
||||
return Boolean(isMotionValue(value) && value.add);
|
||||
}
|
||||
|
||||
export { isWillChangeMotionValue };
|
||||
Reference in New Issue
Block a user