till download files, everything works
This commit is contained in:
1 parent
ce893a4185
commit
ed1a580b09
6050 files changed
+768543
-177
No files matched your search
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import { MotionValue } from '../index.mjs';
|
||||
import { getWillChangeName } from './get-will-change-name.mjs';
|
||||
import { addUniqueItem } from '../../utils/array.mjs';
|
||||
|
||||
class WillChangeMotionValue extends MotionValue {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.values = [];
|
||||
}
|
||||
add(name) {
|
||||
const styleName = getWillChangeName(name);
|
||||
if (styleName) {
|
||||
addUniqueItem(this.values, styleName);
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
update() {
|
||||
this.set(this.values.length ? this.values.join(", ") : "auto");
|
||||
}
|
||||
}
|
||||
|
||||
export { WillChangeMotionValue };
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
export { addValueToWillChange };
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import { acceleratedValues } from '../../animation/animators/utils/accelerated-values.mjs';
|
||||
import { camelToDash } from '../../render/dom/utils/camel-to-dash.mjs';
|
||||
import { transformProps } from '../../render/html/utils/transform.mjs';
|
||||
|
||||
function getWillChangeName(name) {
|
||||
if (transformProps.has(name)) {
|
||||
return "transform";
|
||||
}
|
||||
else if (acceleratedValues.has(name)) {
|
||||
return camelToDash(name);
|
||||
}
|
||||
}
|
||||
|
||||
export { getWillChangeName };
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { useConstant } from '../../utils/use-constant.mjs';
|
||||
import { WillChangeMotionValue } from './WillChangeMotionValue.mjs';
|
||||
|
||||
function useWillChange() {
|
||||
return useConstant(() => new WillChangeMotionValue("auto"));
|
||||
}
|
||||
|
||||
export { useWillChange };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { isMotionValue } from '../utils/is-motion-value.mjs';
|
||||
|
||||
function isWillChangeMotionValue(value) {
|
||||
return Boolean(isMotionValue(value) && value.add);
|
||||
}
|
||||
|
||||
export { isWillChangeMotionValue };
|
||||
Reference in new issue
Block a user