motion-dom 12.7.3 → 12.7.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2946 -475
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +178 -0
- package/dist/es/animation/GroupAnimation.mjs +6 -15
- package/dist/es/animation/JSAnimation.mjs +346 -0
- package/dist/es/animation/NativeAnimation.mjs +64 -67
- package/dist/es/animation/NativeAnimationExtended.mjs +65 -0
- package/dist/es/animation/NativeAnimationWrapper.mjs +14 -0
- package/dist/es/animation/drivers/driver-frameloop.mjs +17 -0
- package/dist/es/animation/generators/inertia.mjs +87 -0
- package/dist/es/animation/generators/keyframes.mjs +49 -0
- package/dist/es/animation/generators/spring/defaults.mjs +27 -0
- package/dist/es/animation/generators/spring/find.mjs +84 -0
- package/dist/es/animation/generators/spring/index.mjs +175 -0
- package/dist/es/animation/generators/utils/velocity.mjs +9 -0
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +131 -0
- package/dist/es/animation/keyframes/KeyframesResolver.mjs +156 -0
- package/dist/es/animation/keyframes/get-final.mjs +3 -4
- package/dist/es/animation/keyframes/offsets/default.mjs +9 -0
- package/dist/es/animation/keyframes/offsets/fill.mjs +12 -0
- package/dist/es/animation/keyframes/offsets/time.mjs +5 -0
- package/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +11 -0
- package/dist/es/animation/keyframes/utils/fill-wildcards.mjs +7 -0
- package/dist/es/animation/keyframes/utils/is-none.mjs +15 -0
- package/dist/es/animation/keyframes/utils/make-none-animatable.mjs +30 -0
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs +36 -0
- package/dist/es/animation/utils/WithPromise.mjs +28 -0
- package/dist/es/animation/utils/active-animations.mjs +9 -0
- package/dist/es/animation/utils/can-animate.mjs +42 -0
- package/dist/es/animation/utils/css-variables-conversion.mjs +41 -0
- package/dist/es/animation/utils/is-animatable.mjs +30 -0
- package/dist/es/animation/utils/is-css-variable.mjs +15 -0
- package/dist/es/animation/utils/replace-transition-type.mjs +18 -0
- package/dist/es/animation/waapi/easing/is-supported.mjs +1 -1
- package/dist/es/animation/waapi/easing/map-easing.mjs +5 -3
- package/dist/es/animation/waapi/start-waapi-animation.mjs +6 -4
- package/dist/es/animation/waapi/supports/waapi.mjs +39 -0
- package/dist/es/animation/waapi/utils/accelerated-values.mjs +14 -0
- package/dist/es/animation/waapi/utils/apply-generator.mjs +2 -1
- package/dist/es/animation/waapi/utils/unsupported-easing.mjs +18 -0
- package/dist/es/frameloop/batcher.mjs +2 -1
- package/dist/es/frameloop/order.mjs +1 -0
- package/dist/es/index.mjs +49 -2
- package/dist/es/render/dom/is-css-var.mjs +3 -0
- package/dist/es/render/dom/parse-transform.mjs +83 -0
- package/dist/es/render/dom/style-computed.mjs +10 -0
- package/dist/es/render/dom/style-set.mjs +9 -0
- package/dist/es/render/utils/keys-position.mjs +13 -0
- package/dist/es/render/utils/keys-transform.mjs +28 -0
- package/dist/es/scroll/observe.mjs +18 -0
- package/dist/es/stats/index.mjs +2 -0
- package/dist/es/utils/interpolate.mjs +74 -0
- package/dist/es/utils/mix/color.mjs +47 -0
- package/dist/es/utils/mix/complex.mjs +92 -0
- package/dist/es/utils/mix/immediate.mjs +5 -0
- package/dist/es/utils/mix/index.mjs +14 -0
- package/dist/es/utils/mix/number.mjs +26 -0
- package/dist/es/utils/mix/visibility.mjs +16 -0
- package/dist/es/value/index.mjs +3 -1
- package/dist/es/value/types/auto.mjs +9 -0
- package/dist/es/value/types/color/hex.mjs +40 -0
- package/dist/es/value/types/color/hsla-to-rgba.mjs +42 -0
- package/dist/es/value/types/color/hsla.mjs +22 -0
- package/dist/es/value/types/color/index.mjs +27 -0
- package/dist/es/value/types/color/rgba.mjs +25 -0
- package/dist/es/value/types/color/utils.mjs +29 -0
- package/dist/es/value/types/complex/filter.mjs +30 -0
- package/dist/es/value/types/complex/index.mjs +91 -0
- package/dist/es/value/types/dimensions.mjs +15 -0
- package/dist/es/value/types/int.mjs +8 -0
- package/dist/es/value/types/maps/defaults.mjs +30 -0
- package/dist/es/value/types/maps/number.mjs +51 -0
- package/dist/es/value/types/maps/transform.mjs +31 -0
- package/dist/es/value/types/numbers/index.mjs +17 -0
- package/dist/es/value/types/numbers/units.mjs +18 -0
- package/dist/es/value/types/test.mjs +6 -0
- package/dist/es/value/types/utils/animatable-none.mjs +15 -0
- package/dist/es/value/types/utils/color-regex.mjs +3 -0
- package/dist/es/value/types/utils/find.mjs +15 -0
- package/dist/es/value/types/utils/float-regex.mjs +3 -0
- package/dist/es/value/types/utils/get-as-type.mjs +10 -0
- package/dist/es/value/types/utils/is-nullish.mjs +5 -0
- package/dist/es/value/types/utils/sanitize.mjs +5 -0
- package/dist/es/value/types/utils/single-color-regex.mjs +3 -0
- package/dist/es/view/start.mjs +4 -3
- package/dist/index.d.ts +945 -444
- package/dist/motion-dom.dev.js +2945 -475
- package/dist/motion-dom.js +1 -1
- package/package.json +3 -3
- package/dist/es/animation/keyframes/hydrate.mjs +0 -26
- package/dist/es/animation/waapi/utils/attach-timeline.mjs +0 -6
- package/dist/es/render/dom/style.mjs +0 -15
- package/dist/es/utils/is-bezier-definition.mjs +0 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { warning } from 'motion-utils';
|
|
2
|
+
import { isGenerator } from '../generators/utils/is-generator.mjs';
|
|
3
|
+
import { isAnimatable } from './is-animatable.mjs';
|
|
4
|
+
|
|
5
|
+
function hasKeyframesChanged(keyframes) {
|
|
6
|
+
const current = keyframes[0];
|
|
7
|
+
if (keyframes.length === 1)
|
|
8
|
+
return true;
|
|
9
|
+
for (let i = 0; i < keyframes.length; i++) {
|
|
10
|
+
if (keyframes[i] !== current)
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function canAnimate(keyframes, name, type, velocity) {
|
|
15
|
+
/**
|
|
16
|
+
* Check if we're able to animate between the start and end keyframes,
|
|
17
|
+
* and throw a warning if we're attempting to animate between one that's
|
|
18
|
+
* animatable and another that isn't.
|
|
19
|
+
*/
|
|
20
|
+
const originKeyframe = keyframes[0];
|
|
21
|
+
if (originKeyframe === null)
|
|
22
|
+
return false;
|
|
23
|
+
/**
|
|
24
|
+
* These aren't traditionally animatable but we do support them.
|
|
25
|
+
* In future we could look into making this more generic or replacing
|
|
26
|
+
* this function with mix() === mixImmediate
|
|
27
|
+
*/
|
|
28
|
+
if (name === "display" || name === "visibility")
|
|
29
|
+
return true;
|
|
30
|
+
const targetKeyframe = keyframes[keyframes.length - 1];
|
|
31
|
+
const isOriginAnimatable = isAnimatable(originKeyframe, name);
|
|
32
|
+
const isTargetAnimatable = isAnimatable(targetKeyframe, name);
|
|
33
|
+
warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
|
|
34
|
+
// Always skip if any of these are true
|
|
35
|
+
if (!isOriginAnimatable || !isTargetAnimatable) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return (hasKeyframesChanged(keyframes) ||
|
|
39
|
+
((type === "spring" || isGenerator(type)) && velocity));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { canAnimate };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { invariant, isNumericalString } from 'motion-utils';
|
|
2
|
+
import { isCSSVariableToken } from './is-css-variable.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parse Framer's special CSS variable format into a CSS token and a fallback.
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* `var(--foo, #fff)` => [`--foo`, '#fff']
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param current
|
|
12
|
+
*/
|
|
13
|
+
const splitCSSVariableRegex =
|
|
14
|
+
// eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
|
|
15
|
+
/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;
|
|
16
|
+
function parseCSSVariable(current) {
|
|
17
|
+
const match = splitCSSVariableRegex.exec(current);
|
|
18
|
+
if (!match)
|
|
19
|
+
return [,];
|
|
20
|
+
const [, token1, token2, fallback] = match;
|
|
21
|
+
return [`--${token1 ?? token2}`, fallback];
|
|
22
|
+
}
|
|
23
|
+
const maxDepth = 4;
|
|
24
|
+
function getVariableValue(current, element, depth = 1) {
|
|
25
|
+
invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
|
|
26
|
+
const [token, fallback] = parseCSSVariable(current);
|
|
27
|
+
// No CSS variable detected
|
|
28
|
+
if (!token)
|
|
29
|
+
return;
|
|
30
|
+
// Attempt to read this CSS variable off the element
|
|
31
|
+
const resolved = window.getComputedStyle(element).getPropertyValue(token);
|
|
32
|
+
if (resolved) {
|
|
33
|
+
const trimmed = resolved.trim();
|
|
34
|
+
return isNumericalString(trimmed) ? parseFloat(trimmed) : trimmed;
|
|
35
|
+
}
|
|
36
|
+
return isCSSVariableToken(fallback)
|
|
37
|
+
? getVariableValue(fallback, element, depth + 1)
|
|
38
|
+
: fallback;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { getVariableValue, parseCSSVariable };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { complex } from '../../value/types/complex/index.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if a value is animatable. Examples:
|
|
5
|
+
*
|
|
6
|
+
* ✅: 100, "100px", "#fff"
|
|
7
|
+
* ❌: "block", "url(2.jpg)"
|
|
8
|
+
* @param value
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const isAnimatable = (value, name) => {
|
|
13
|
+
// If the list of keys tat might be non-animatable grows, replace with Set
|
|
14
|
+
if (name === "zIndex")
|
|
15
|
+
return false;
|
|
16
|
+
// If it's a number or a keyframes array, we can animate it. We might at some point
|
|
17
|
+
// need to do a deep isAnimatable check of keyframes, or let Popmotion handle this,
|
|
18
|
+
// but for now lets leave it like this for performance reasons
|
|
19
|
+
if (typeof value === "number" || Array.isArray(value))
|
|
20
|
+
return true;
|
|
21
|
+
if (typeof value === "string" && // It's animatable if we have a string
|
|
22
|
+
(complex.test(value) || value === "0") && // And it contains numbers and/or colors
|
|
23
|
+
!value.startsWith("url(") // Unless it starts with "url("
|
|
24
|
+
) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { isAnimatable };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
2
|
+
const isCSSVariableName =
|
|
3
|
+
/*@__PURE__*/ checkStringStartsWith("--");
|
|
4
|
+
const startsAsVariableToken =
|
|
5
|
+
/*@__PURE__*/ checkStringStartsWith("var(--");
|
|
6
|
+
const isCSSVariableToken = (value) => {
|
|
7
|
+
const startsWithToken = startsAsVariableToken(value);
|
|
8
|
+
if (!startsWithToken)
|
|
9
|
+
return false;
|
|
10
|
+
// Ensure any comments are stripped from the value as this can harm performance of the regex.
|
|
11
|
+
return singleCssVariableRegex.test(value.split("/*")[0].trim());
|
|
12
|
+
};
|
|
13
|
+
const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
|
|
14
|
+
|
|
15
|
+
export { isCSSVariableName, isCSSVariableToken };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inertia } from '../generators/inertia.mjs';
|
|
2
|
+
import { keyframes } from '../generators/keyframes.mjs';
|
|
3
|
+
import { spring } from '../generators/spring/index.mjs';
|
|
4
|
+
|
|
5
|
+
const transitionTypeMap = {
|
|
6
|
+
decay: inertia,
|
|
7
|
+
inertia,
|
|
8
|
+
tween: keyframes,
|
|
9
|
+
keyframes: keyframes,
|
|
10
|
+
spring,
|
|
11
|
+
};
|
|
12
|
+
function replaceTransitionType(transition) {
|
|
13
|
+
if (typeof transition.type === "string") {
|
|
14
|
+
transition.type = transitionTypeMap[transition.type];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { replaceTransitionType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBezierDefinition } from '
|
|
1
|
+
import { isBezierDefinition } from 'motion-utils';
|
|
2
2
|
import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
|
|
3
3
|
import { supportedWaapiEasing } from './supported.mjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBezierDefinition } from '
|
|
1
|
+
import { isBezierDefinition } from 'motion-utils';
|
|
2
2
|
import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
|
|
3
3
|
import { generateLinearEasing } from '../utils/linear.mjs';
|
|
4
4
|
import { cubicBezierAsString } from './cubic-bezier.mjs';
|
|
@@ -8,8 +8,10 @@ function mapEasingToNativeEasing(easing, duration) {
|
|
|
8
8
|
if (!easing) {
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
|
-
else if (typeof easing === "function"
|
|
12
|
-
return
|
|
11
|
+
else if (typeof easing === "function") {
|
|
12
|
+
return supportsLinearEasing()
|
|
13
|
+
? generateLinearEasing(easing, duration)
|
|
14
|
+
: "ease-out";
|
|
13
15
|
}
|
|
14
16
|
else if (isBezierDefinition(easing)) {
|
|
15
17
|
return cubicBezierAsString(easing);
|
|
@@ -2,7 +2,7 @@ import { activeAnimations } from '../../stats/animation-count.mjs';
|
|
|
2
2
|
import { statsBuffer } from '../../stats/buffer.mjs';
|
|
3
3
|
import { mapEasingToNativeEasing } from './easing/map-easing.mjs';
|
|
4
4
|
|
|
5
|
-
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "
|
|
5
|
+
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeOut", times, } = {}, pseudoElement = undefined) {
|
|
6
6
|
const keyframeOptions = {
|
|
7
7
|
[valueName]: keyframes,
|
|
8
8
|
};
|
|
@@ -17,15 +17,17 @@ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duratio
|
|
|
17
17
|
if (statsBuffer.value) {
|
|
18
18
|
activeAnimations.waapi++;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const options = {
|
|
21
21
|
delay,
|
|
22
22
|
duration,
|
|
23
23
|
easing: !Array.isArray(easing) ? easing : "linear",
|
|
24
24
|
fill: "both",
|
|
25
25
|
iterations: repeat + 1,
|
|
26
26
|
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
};
|
|
28
|
+
if (pseudoElement)
|
|
29
|
+
options.pseudoElement = pseudoElement;
|
|
30
|
+
const animation = element.animate(keyframeOptions, options);
|
|
29
31
|
if (statsBuffer.value) {
|
|
30
32
|
animation.finished.finally(() => {
|
|
31
33
|
activeAnimations.waapi--;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { memo } from 'motion-utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A list of values that can be hardware-accelerated.
|
|
5
|
+
*/
|
|
6
|
+
const acceleratedValues = new Set([
|
|
7
|
+
"opacity",
|
|
8
|
+
"clipPath",
|
|
9
|
+
"filter",
|
|
10
|
+
"transform",
|
|
11
|
+
// TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
|
|
12
|
+
// or until we implement support for linear() easing.
|
|
13
|
+
// "background-color"
|
|
14
|
+
]);
|
|
15
|
+
const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
16
|
+
function supportsBrowserAnimation(options) {
|
|
17
|
+
const { motionValue, name, repeatDelay, repeatType, damping, type } = options;
|
|
18
|
+
if (!motionValue ||
|
|
19
|
+
!motionValue.owner ||
|
|
20
|
+
!(motionValue.owner.current instanceof HTMLElement)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const { onUpdate, transformTemplate } = motionValue.owner.getProps();
|
|
24
|
+
return (supportsWaapi() &&
|
|
25
|
+
name &&
|
|
26
|
+
acceleratedValues.has(name) &&
|
|
27
|
+
(name !== "transform" || !transformTemplate) &&
|
|
28
|
+
/**
|
|
29
|
+
* If we're outputting values to onUpdate then we can't use WAAPI as there's
|
|
30
|
+
* no way to read the value from WAAPI every frame.
|
|
31
|
+
*/
|
|
32
|
+
!onUpdate &&
|
|
33
|
+
!repeatDelay &&
|
|
34
|
+
repeatType !== "mirror" &&
|
|
35
|
+
damping !== 0 &&
|
|
36
|
+
type !== "inertia");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { supportsBrowserAnimation };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list of values that can be hardware-accelerated.
|
|
3
|
+
*/
|
|
4
|
+
const acceleratedValues = new Set([
|
|
5
|
+
"opacity",
|
|
6
|
+
"clipPath",
|
|
7
|
+
"filter",
|
|
8
|
+
"transform",
|
|
9
|
+
// TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
|
|
10
|
+
// or until we implement support for linear() easing.
|
|
11
|
+
// "background-color"
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
export { acceleratedValues };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
|
|
1
2
|
import { isGenerator } from '../../generators/utils/is-generator.mjs';
|
|
2
3
|
|
|
3
4
|
function applyGeneratorOptions({ type, ...options }) {
|
|
4
|
-
if (isGenerator(type)) {
|
|
5
|
+
if (isGenerator(type) && supportsLinearEasing()) {
|
|
5
6
|
return type.applyToOptions(options);
|
|
6
7
|
}
|
|
7
8
|
else {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { anticipate, backInOut, circInOut } from 'motion-utils';
|
|
2
|
+
|
|
3
|
+
const unsupportedEasingFunctions = {
|
|
4
|
+
anticipate,
|
|
5
|
+
backInOut,
|
|
6
|
+
circInOut,
|
|
7
|
+
};
|
|
8
|
+
function isUnsupportedEase(key) {
|
|
9
|
+
return key in unsupportedEasingFunctions;
|
|
10
|
+
}
|
|
11
|
+
function replaceStringEasing(transition) {
|
|
12
|
+
if (typeof transition.ease === "string" &&
|
|
13
|
+
isUnsupportedEase(transition.ease)) {
|
|
14
|
+
transition.ease = unsupportedEasingFunctions[transition.ease];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { replaceStringEasing };
|
|
@@ -16,7 +16,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
16
16
|
acc[key] = createRenderStep(flagRunNextFrame, allowKeepAlive ? key : undefined);
|
|
17
17
|
return acc;
|
|
18
18
|
}, {});
|
|
19
|
-
const { read, resolveKeyframes, update, preRender, render, postRender } = steps;
|
|
19
|
+
const { setup, read, resolveKeyframes, update, preRender, render, postRender, } = steps;
|
|
20
20
|
const processBatch = () => {
|
|
21
21
|
const timestamp = MotionGlobalConfig.useManualTiming
|
|
22
22
|
? state.timestamp
|
|
@@ -30,6 +30,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
30
30
|
state.timestamp = timestamp;
|
|
31
31
|
state.isProcessing = true;
|
|
32
32
|
// Unrolled render loop for better per-frame performance
|
|
33
|
+
setup.process(state);
|
|
33
34
|
read.process(state);
|
|
34
35
|
resolveKeyframes.process(state);
|
|
35
36
|
update.process(state);
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
+
export { AsyncMotionValueAnimation } from './animation/AsyncMotionValueAnimation.mjs';
|
|
1
2
|
export { GroupAnimation } from './animation/GroupAnimation.mjs';
|
|
2
3
|
export { GroupAnimationWithThen } from './animation/GroupAnimationWithThen.mjs';
|
|
4
|
+
export { JSAnimation, animateValue } from './animation/JSAnimation.mjs';
|
|
3
5
|
export { NativeAnimation } from './animation/NativeAnimation.mjs';
|
|
6
|
+
export { NativeAnimationExtended } from './animation/NativeAnimationExtended.mjs';
|
|
7
|
+
export { NativeAnimationWrapper } from './animation/NativeAnimationWrapper.mjs';
|
|
8
|
+
export { animationMapKey, getAnimationMap } from './animation/utils/active-animations.mjs';
|
|
9
|
+
export { getVariableValue, parseCSSVariable } from './animation/utils/css-variables-conversion.mjs';
|
|
4
10
|
export { getValueTransition } from './animation/utils/get-value-transition.mjs';
|
|
11
|
+
export { isCSSVariableName, isCSSVariableToken } from './animation/utils/is-css-variable.mjs';
|
|
12
|
+
export { inertia } from './animation/generators/inertia.mjs';
|
|
13
|
+
export { defaultEasing, keyframes } from './animation/generators/keyframes.mjs';
|
|
14
|
+
export { spring } from './animation/generators/spring/index.mjs';
|
|
5
15
|
export { calcGeneratorDuration, maxGeneratorDuration } from './animation/generators/utils/calc-duration.mjs';
|
|
6
16
|
export { createGeneratorEasing } from './animation/generators/utils/create-generator-easing.mjs';
|
|
7
17
|
export { isGenerator } from './animation/generators/utils/is-generator.mjs';
|
|
18
|
+
export { DOMKeyframesResolver } from './animation/keyframes/DOMKeyframesResolver.mjs';
|
|
19
|
+
export { KeyframeResolver, flushKeyframeResolvers } from './animation/keyframes/KeyframesResolver.mjs';
|
|
20
|
+
export { defaultOffset } from './animation/keyframes/offsets/default.mjs';
|
|
21
|
+
export { fillOffset } from './animation/keyframes/offsets/fill.mjs';
|
|
22
|
+
export { convertOffsetToTimes } from './animation/keyframes/offsets/time.mjs';
|
|
23
|
+
export { applyPxDefaults } from './animation/keyframes/utils/apply-px-defaults.mjs';
|
|
24
|
+
export { fillWildcards } from './animation/keyframes/utils/fill-wildcards.mjs';
|
|
8
25
|
export { cubicBezierAsString } from './animation/waapi/easing/cubic-bezier.mjs';
|
|
9
26
|
export { isWaapiSupportedEasing } from './animation/waapi/easing/is-supported.mjs';
|
|
10
27
|
export { mapEasingToNativeEasing } from './animation/waapi/easing/map-easing.mjs';
|
|
11
28
|
export { supportedWaapiEasing } from './animation/waapi/easing/supported.mjs';
|
|
12
29
|
export { startWaapiAnimation } from './animation/waapi/start-waapi-animation.mjs';
|
|
13
|
-
export {
|
|
30
|
+
export { supportsPartialKeyframes } from './animation/waapi/supports/partial-keyframes.mjs';
|
|
31
|
+
export { supportsBrowserAnimation } from './animation/waapi/supports/waapi.mjs';
|
|
32
|
+
export { acceleratedValues } from './animation/waapi/utils/accelerated-values.mjs';
|
|
14
33
|
export { generateLinearEasing } from './animation/waapi/utils/linear.mjs';
|
|
15
34
|
export { createRenderBatcher } from './frameloop/batcher.mjs';
|
|
16
35
|
export { cancelMicrotask, microtask } from './frameloop/microtask.mjs';
|
|
@@ -21,15 +40,43 @@ export { hover } from './gestures/hover.mjs';
|
|
|
21
40
|
export { press } from './gestures/press/index.mjs';
|
|
22
41
|
export { isNodeOrChild } from './gestures/utils/is-node-or-child.mjs';
|
|
23
42
|
export { isPrimaryPointer } from './gestures/utils/is-primary-pointer.mjs';
|
|
43
|
+
export { parseValueFromTransform, readTransformValue } from './render/dom/parse-transform.mjs';
|
|
44
|
+
export { getComputedStyle } from './render/dom/style-computed.mjs';
|
|
45
|
+
export { setStyle } from './render/dom/style-set.mjs';
|
|
46
|
+
export { positionalKeys } from './render/utils/keys-position.mjs';
|
|
47
|
+
export { transformPropOrder, transformProps } from './render/utils/keys-transform.mjs';
|
|
48
|
+
export { observeTimeline } from './scroll/observe.mjs';
|
|
24
49
|
export { recordStats } from './stats/index.mjs';
|
|
25
50
|
export { activeAnimations } from './stats/animation-count.mjs';
|
|
26
51
|
export { statsBuffer } from './stats/buffer.mjs';
|
|
27
|
-
export {
|
|
52
|
+
export { interpolate } from './utils/interpolate.mjs';
|
|
53
|
+
export { mix } from './utils/mix/index.mjs';
|
|
54
|
+
export { mixColor, mixLinearColor } from './utils/mix/color.mjs';
|
|
55
|
+
export { getMixer, mixArray, mixComplex, mixObject } from './utils/mix/complex.mjs';
|
|
56
|
+
export { mixImmediate } from './utils/mix/immediate.mjs';
|
|
57
|
+
export { mixNumber } from './utils/mix/number.mjs';
|
|
58
|
+
export { invisibleValues, mixVisibility } from './utils/mix/visibility.mjs';
|
|
28
59
|
export { resolveElements } from './utils/resolve-elements.mjs';
|
|
29
60
|
export { supportsFlags } from './utils/supports/flags.mjs';
|
|
30
61
|
export { supportsLinearEasing } from './utils/supports/linear-easing.mjs';
|
|
31
62
|
export { supportsScrollTimeline } from './utils/supports/scroll-timeline.mjs';
|
|
32
63
|
export { MotionValue, collectMotionValues, motionValue } from './value/index.mjs';
|
|
64
|
+
export { color } from './value/types/color/index.mjs';
|
|
65
|
+
export { hex } from './value/types/color/hex.mjs';
|
|
66
|
+
export { hsla } from './value/types/color/hsla.mjs';
|
|
67
|
+
export { hslaToRgba } from './value/types/color/hsla-to-rgba.mjs';
|
|
68
|
+
export { rgbUnit, rgba } from './value/types/color/rgba.mjs';
|
|
69
|
+
export { analyseComplexValue, complex } from './value/types/complex/index.mjs';
|
|
70
|
+
export { dimensionValueTypes, findDimensionValueType } from './value/types/dimensions.mjs';
|
|
71
|
+
export { defaultValueTypes, getDefaultValueType } from './value/types/maps/defaults.mjs';
|
|
72
|
+
export { numberValueTypes } from './value/types/maps/number.mjs';
|
|
73
|
+
export { transformValueTypes } from './value/types/maps/transform.mjs';
|
|
74
|
+
export { alpha, number, scale } from './value/types/numbers/index.mjs';
|
|
75
|
+
export { degrees, percent, progressPercentage, px, vh, vw } from './value/types/numbers/units.mjs';
|
|
76
|
+
export { testValueType } from './value/types/test.mjs';
|
|
77
|
+
export { getAnimatableNone } from './value/types/utils/animatable-none.mjs';
|
|
78
|
+
export { findValueType } from './value/types/utils/find.mjs';
|
|
79
|
+
export { getValueAsType } from './value/types/utils/get-as-type.mjs';
|
|
33
80
|
export { ViewTransitionBuilder, animateView } from './view/index.mjs';
|
|
34
81
|
export { cancelSync, sync } from './frameloop/index-legacy.mjs';
|
|
35
82
|
export { cancelFrame, frame, frameData, frameSteps } from './frameloop/frame.mjs';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const radToDeg = (rad) => (rad * 180) / Math.PI;
|
|
2
|
+
const rotate = (v) => {
|
|
3
|
+
const angle = radToDeg(Math.atan2(v[1], v[0]));
|
|
4
|
+
return rebaseAngle(angle);
|
|
5
|
+
};
|
|
6
|
+
const matrix2dParsers = {
|
|
7
|
+
x: 4,
|
|
8
|
+
y: 5,
|
|
9
|
+
translateX: 4,
|
|
10
|
+
translateY: 5,
|
|
11
|
+
scaleX: 0,
|
|
12
|
+
scaleY: 3,
|
|
13
|
+
scale: (v) => (Math.abs(v[0]) + Math.abs(v[3])) / 2,
|
|
14
|
+
rotate,
|
|
15
|
+
rotateZ: rotate,
|
|
16
|
+
skewX: (v) => radToDeg(Math.atan(v[1])),
|
|
17
|
+
skewY: (v) => radToDeg(Math.atan(v[2])),
|
|
18
|
+
skew: (v) => (Math.abs(v[1]) + Math.abs(v[2])) / 2,
|
|
19
|
+
};
|
|
20
|
+
const rebaseAngle = (angle) => {
|
|
21
|
+
angle = angle % 360;
|
|
22
|
+
if (angle < 0)
|
|
23
|
+
angle += 360;
|
|
24
|
+
return angle;
|
|
25
|
+
};
|
|
26
|
+
const rotateZ = rotate;
|
|
27
|
+
const scaleX = (v) => Math.sqrt(v[0] * v[0] + v[1] * v[1]);
|
|
28
|
+
const scaleY = (v) => Math.sqrt(v[4] * v[4] + v[5] * v[5]);
|
|
29
|
+
const matrix3dParsers = {
|
|
30
|
+
x: 12,
|
|
31
|
+
y: 13,
|
|
32
|
+
z: 14,
|
|
33
|
+
translateX: 12,
|
|
34
|
+
translateY: 13,
|
|
35
|
+
translateZ: 14,
|
|
36
|
+
scaleX,
|
|
37
|
+
scaleY,
|
|
38
|
+
scale: (v) => (scaleX(v) + scaleY(v)) / 2,
|
|
39
|
+
rotateX: (v) => rebaseAngle(radToDeg(Math.atan2(v[6], v[5]))),
|
|
40
|
+
rotateY: (v) => rebaseAngle(radToDeg(Math.atan2(-v[2], v[0]))),
|
|
41
|
+
rotateZ,
|
|
42
|
+
rotate: rotateZ,
|
|
43
|
+
skewX: (v) => radToDeg(Math.atan(v[4])),
|
|
44
|
+
skewY: (v) => radToDeg(Math.atan(v[1])),
|
|
45
|
+
skew: (v) => (Math.abs(v[1]) + Math.abs(v[4])) / 2,
|
|
46
|
+
};
|
|
47
|
+
function defaultTransformValue(name) {
|
|
48
|
+
return name.includes("scale") ? 1 : 0;
|
|
49
|
+
}
|
|
50
|
+
function parseValueFromTransform(transform, name) {
|
|
51
|
+
if (!transform || transform === "none") {
|
|
52
|
+
return defaultTransformValue(name);
|
|
53
|
+
}
|
|
54
|
+
const matrix3dMatch = transform.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
|
|
55
|
+
let parsers;
|
|
56
|
+
let match;
|
|
57
|
+
if (matrix3dMatch) {
|
|
58
|
+
parsers = matrix3dParsers;
|
|
59
|
+
match = matrix3dMatch;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const matrix2dMatch = transform.match(/^matrix\(([-\d.e\s,]+)\)$/u);
|
|
63
|
+
parsers = matrix2dParsers;
|
|
64
|
+
match = matrix2dMatch;
|
|
65
|
+
}
|
|
66
|
+
if (!match) {
|
|
67
|
+
return defaultTransformValue(name);
|
|
68
|
+
}
|
|
69
|
+
const valueParser = parsers[name];
|
|
70
|
+
const values = match[1].split(",").map(convertTransformToNumber);
|
|
71
|
+
return typeof valueParser === "function"
|
|
72
|
+
? valueParser(values)
|
|
73
|
+
: values[valueParser];
|
|
74
|
+
}
|
|
75
|
+
const readTransformValue = (instance, name) => {
|
|
76
|
+
const { transform = "none" } = getComputedStyle(instance);
|
|
77
|
+
return parseValueFromTransform(transform, name);
|
|
78
|
+
};
|
|
79
|
+
function convertTransformToNumber(value) {
|
|
80
|
+
return parseFloat(value.trim());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { parseValueFromTransform, readTransformValue };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isCSSVar } from './is-css-var.mjs';
|
|
2
|
+
|
|
3
|
+
function getComputedStyle(element, name) {
|
|
4
|
+
const computedStyle = window.getComputedStyle(element);
|
|
5
|
+
return isCSSVar(name)
|
|
6
|
+
? computedStyle.getPropertyValue(name)
|
|
7
|
+
: computedStyle[name];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { getComputedStyle };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a list of every possible transform key.
|
|
3
|
+
*/
|
|
4
|
+
const transformPropOrder = [
|
|
5
|
+
"transformPerspective",
|
|
6
|
+
"x",
|
|
7
|
+
"y",
|
|
8
|
+
"z",
|
|
9
|
+
"translateX",
|
|
10
|
+
"translateY",
|
|
11
|
+
"translateZ",
|
|
12
|
+
"scale",
|
|
13
|
+
"scaleX",
|
|
14
|
+
"scaleY",
|
|
15
|
+
"rotate",
|
|
16
|
+
"rotateX",
|
|
17
|
+
"rotateY",
|
|
18
|
+
"rotateZ",
|
|
19
|
+
"skew",
|
|
20
|
+
"skewX",
|
|
21
|
+
"skewY",
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* A quick lookup for transform props.
|
|
25
|
+
*/
|
|
26
|
+
const transformProps = /*@__PURE__*/ (() => new Set(transformPropOrder))();
|
|
27
|
+
|
|
28
|
+
export { transformPropOrder, transformProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { frame, cancelFrame } from '../frameloop/frame.mjs';
|
|
2
|
+
|
|
3
|
+
function observeTimeline(update, timeline) {
|
|
4
|
+
let prevProgress;
|
|
5
|
+
const onFrame = () => {
|
|
6
|
+
const { currentTime } = timeline;
|
|
7
|
+
const percentage = currentTime === null ? 0 : currentTime.value;
|
|
8
|
+
const progress = percentage / 100;
|
|
9
|
+
if (prevProgress !== progress) {
|
|
10
|
+
update(progress);
|
|
11
|
+
}
|
|
12
|
+
prevProgress = progress;
|
|
13
|
+
};
|
|
14
|
+
frame.update(onFrame, true);
|
|
15
|
+
return () => cancelFrame(onFrame);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { observeTimeline };
|
package/dist/es/stats/index.mjs
CHANGED
|
@@ -44,6 +44,7 @@ function reportStats() {
|
|
|
44
44
|
cancelFrame(record);
|
|
45
45
|
const summary = {
|
|
46
46
|
frameloop: {
|
|
47
|
+
setup: summarise(value.frameloop.setup),
|
|
47
48
|
rate: summarise(value.frameloop.rate),
|
|
48
49
|
read: summarise(value.frameloop.read),
|
|
49
50
|
resolveKeyframes: summarise(value.frameloop.resolveKeyframes),
|
|
@@ -81,6 +82,7 @@ function recordStats() {
|
|
|
81
82
|
const newStatsBuffer = statsBuffer;
|
|
82
83
|
newStatsBuffer.value = {
|
|
83
84
|
frameloop: {
|
|
85
|
+
setup: [],
|
|
84
86
|
rate: [],
|
|
85
87
|
read: [],
|
|
86
88
|
resolveKeyframes: [],
|