motion-dom 12.23.28 → 12.24.3
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 +45 -23
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +2 -12
- package/dist/es/animation/utils/is-css-variable.mjs +1 -12
- package/dist/es/animation/waapi/utils/px-values.mjs +19 -0
- package/dist/es/index.mjs +1 -1
- package/dist/es/value/spring-value.mjs +7 -1
- package/dist/es/value/types/maps/number.mjs +19 -0
- package/dist/index.d.ts +3158 -0
- package/dist/motion-dom.dev.js +45 -23
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -0
- package/dist/size-rollup-style-effect.js +1 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -223,17 +223,6 @@ const isCSSVariableToken = (value) => {
|
|
|
223
223
|
return singleCssVariableRegex.test(value.split("/*")[0].trim());
|
|
224
224
|
};
|
|
225
225
|
const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
|
|
226
|
-
/**
|
|
227
|
-
* Check if a value contains a CSS variable anywhere (e.g. inside calc()).
|
|
228
|
-
* Unlike isCSSVariableToken which checks if the value IS a var() token,
|
|
229
|
-
* this checks if the value CONTAINS var() somewhere in the string.
|
|
230
|
-
*/
|
|
231
|
-
function containsCSSVariable(value) {
|
|
232
|
-
if (typeof value !== "string")
|
|
233
|
-
return false;
|
|
234
|
-
// Strip comments to avoid false positives
|
|
235
|
-
return value.split("/*")[0].includes("var(--");
|
|
236
|
-
}
|
|
237
226
|
|
|
238
227
|
const number = {
|
|
239
228
|
test: (v) => typeof v === "number",
|
|
@@ -2808,17 +2797,36 @@ const numberValueTypes = {
|
|
|
2808
2797
|
right: px,
|
|
2809
2798
|
bottom: px,
|
|
2810
2799
|
left: px,
|
|
2800
|
+
inset: px,
|
|
2801
|
+
insetBlock: px,
|
|
2802
|
+
insetBlockStart: px,
|
|
2803
|
+
insetBlockEnd: px,
|
|
2804
|
+
insetInline: px,
|
|
2805
|
+
insetInlineStart: px,
|
|
2806
|
+
insetInlineEnd: px,
|
|
2811
2807
|
// Spacing props
|
|
2812
2808
|
padding: px,
|
|
2813
2809
|
paddingTop: px,
|
|
2814
2810
|
paddingRight: px,
|
|
2815
2811
|
paddingBottom: px,
|
|
2816
2812
|
paddingLeft: px,
|
|
2813
|
+
paddingBlock: px,
|
|
2814
|
+
paddingBlockStart: px,
|
|
2815
|
+
paddingBlockEnd: px,
|
|
2816
|
+
paddingInline: px,
|
|
2817
|
+
paddingInlineStart: px,
|
|
2818
|
+
paddingInlineEnd: px,
|
|
2817
2819
|
margin: px,
|
|
2818
2820
|
marginTop: px,
|
|
2819
2821
|
marginRight: px,
|
|
2820
2822
|
marginBottom: px,
|
|
2821
2823
|
marginLeft: px,
|
|
2824
|
+
marginBlock: px,
|
|
2825
|
+
marginBlockStart: px,
|
|
2826
|
+
marginBlockEnd: px,
|
|
2827
|
+
marginInline: px,
|
|
2828
|
+
marginInlineStart: px,
|
|
2829
|
+
marginInlineEnd: px,
|
|
2822
2830
|
// Misc
|
|
2823
2831
|
backgroundPositionX: px,
|
|
2824
2832
|
backgroundPositionY: px,
|
|
@@ -2936,16 +2944,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
2936
2944
|
const [origin, target] = unresolvedKeyframes;
|
|
2937
2945
|
const originType = findDimensionValueType(origin);
|
|
2938
2946
|
const targetType = findDimensionValueType(target);
|
|
2939
|
-
/**
|
|
2940
|
-
* If one keyframe contains embedded CSS variables (e.g. in calc()) and the other
|
|
2941
|
-
* doesn't, we need to measure to convert to pixels. This handles GitHub issue #3410.
|
|
2942
|
-
*/
|
|
2943
|
-
const originHasVar = containsCSSVariable(origin);
|
|
2944
|
-
const targetHasVar = containsCSSVariable(target);
|
|
2945
|
-
if (originHasVar !== targetHasVar && positionalValues[name]) {
|
|
2946
|
-
this.needsMeasurement = true;
|
|
2947
|
-
return;
|
|
2948
|
-
}
|
|
2949
2947
|
/**
|
|
2950
2948
|
* Either we don't recognise these value types or we can animate between them.
|
|
2951
2949
|
*/
|
|
@@ -3044,17 +3042,36 @@ const pxValues = new Set([
|
|
|
3044
3042
|
"right",
|
|
3045
3043
|
"bottom",
|
|
3046
3044
|
"left",
|
|
3045
|
+
"inset",
|
|
3046
|
+
"insetBlock",
|
|
3047
|
+
"insetBlockStart",
|
|
3048
|
+
"insetBlockEnd",
|
|
3049
|
+
"insetInline",
|
|
3050
|
+
"insetInlineStart",
|
|
3051
|
+
"insetInlineEnd",
|
|
3047
3052
|
// Spacing props
|
|
3048
3053
|
"padding",
|
|
3049
3054
|
"paddingTop",
|
|
3050
3055
|
"paddingRight",
|
|
3051
3056
|
"paddingBottom",
|
|
3052
3057
|
"paddingLeft",
|
|
3058
|
+
"paddingBlock",
|
|
3059
|
+
"paddingBlockStart",
|
|
3060
|
+
"paddingBlockEnd",
|
|
3061
|
+
"paddingInline",
|
|
3062
|
+
"paddingInlineStart",
|
|
3063
|
+
"paddingInlineEnd",
|
|
3053
3064
|
"margin",
|
|
3054
3065
|
"marginTop",
|
|
3055
3066
|
"marginRight",
|
|
3056
3067
|
"marginBottom",
|
|
3057
3068
|
"marginLeft",
|
|
3069
|
+
"marginBlock",
|
|
3070
|
+
"marginBlockStart",
|
|
3071
|
+
"marginBlockEnd",
|
|
3072
|
+
"marginInline",
|
|
3073
|
+
"marginInlineStart",
|
|
3074
|
+
"marginInlineEnd",
|
|
3058
3075
|
// Misc
|
|
3059
3076
|
"backgroundPositionX",
|
|
3060
3077
|
"backgroundPositionY",
|
|
@@ -4332,7 +4349,13 @@ function attachSpring(value, source, options) {
|
|
|
4332
4349
|
value.attach((v, set) => {
|
|
4333
4350
|
latestValue = v;
|
|
4334
4351
|
latestSetter = (latest) => set(parseValue(latest, unit));
|
|
4335
|
-
frame.postRender(
|
|
4352
|
+
frame.postRender(() => {
|
|
4353
|
+
startAnimation();
|
|
4354
|
+
value['events'].animationStart?.notify();
|
|
4355
|
+
activeAnimation?.then(() => {
|
|
4356
|
+
value['events'].animationComplete?.notify();
|
|
4357
|
+
});
|
|
4358
|
+
});
|
|
4336
4359
|
}, stopAnimation);
|
|
4337
4360
|
if (isMotionValue(source)) {
|
|
4338
4361
|
const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
|
|
@@ -4718,7 +4741,6 @@ exports.cancelSync = cancelSync;
|
|
|
4718
4741
|
exports.collectMotionValues = collectMotionValues;
|
|
4719
4742
|
exports.color = color;
|
|
4720
4743
|
exports.complex = complex;
|
|
4721
|
-
exports.containsCSSVariable = containsCSSVariable;
|
|
4722
4744
|
exports.convertOffsetToTimes = convertOffsetToTimes;
|
|
4723
4745
|
exports.createGeneratorEasing = createGeneratorEasing;
|
|
4724
4746
|
exports.createRenderBatcher = createRenderBatcher;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { positionalKeys } from '../../render/utils/keys-position.mjs';
|
|
2
2
|
import { findDimensionValueType } from '../../value/types/dimensions.mjs';
|
|
3
3
|
import { getVariableValue } from '../utils/css-variables-conversion.mjs';
|
|
4
|
-
import { isCSSVariableToken
|
|
4
|
+
import { isCSSVariableToken } from '../utils/is-css-variable.mjs';
|
|
5
5
|
import { KeyframeResolver } from './KeyframesResolver.mjs';
|
|
6
6
|
import { isNone } from './utils/is-none.mjs';
|
|
7
7
|
import { makeNoneKeyframesAnimatable } from './utils/make-none-animatable.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { isNumOrPxType, positionalValues } from './utils/unit-conversion.mjs';
|
|
9
9
|
|
|
10
10
|
class DOMKeyframesResolver extends KeyframeResolver {
|
|
11
11
|
constructor(unresolvedKeyframes, onComplete, name, motionValue, element) {
|
|
@@ -52,16 +52,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
52
52
|
const [origin, target] = unresolvedKeyframes;
|
|
53
53
|
const originType = findDimensionValueType(origin);
|
|
54
54
|
const targetType = findDimensionValueType(target);
|
|
55
|
-
/**
|
|
56
|
-
* If one keyframe contains embedded CSS variables (e.g. in calc()) and the other
|
|
57
|
-
* doesn't, we need to measure to convert to pixels. This handles GitHub issue #3410.
|
|
58
|
-
*/
|
|
59
|
-
const originHasVar = containsCSSVariable(origin);
|
|
60
|
-
const targetHasVar = containsCSSVariable(target);
|
|
61
|
-
if (originHasVar !== targetHasVar && positionalValues[name]) {
|
|
62
|
-
this.needsMeasurement = true;
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
55
|
/**
|
|
66
56
|
* Either we don't recognise these value types or we can animate between them.
|
|
67
57
|
*/
|
|
@@ -11,16 +11,5 @@ const isCSSVariableToken = (value) => {
|
|
|
11
11
|
return singleCssVariableRegex.test(value.split("/*")[0].trim());
|
|
12
12
|
};
|
|
13
13
|
const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
|
|
14
|
-
/**
|
|
15
|
-
* Check if a value contains a CSS variable anywhere (e.g. inside calc()).
|
|
16
|
-
* Unlike isCSSVariableToken which checks if the value IS a var() token,
|
|
17
|
-
* this checks if the value CONTAINS var() somewhere in the string.
|
|
18
|
-
*/
|
|
19
|
-
function containsCSSVariable(value) {
|
|
20
|
-
if (typeof value !== "string")
|
|
21
|
-
return false;
|
|
22
|
-
// Strip comments to avoid false positives
|
|
23
|
-
return value.split("/*")[0].includes("var(--");
|
|
24
|
-
}
|
|
25
14
|
|
|
26
|
-
export {
|
|
15
|
+
export { isCSSVariableName, isCSSVariableToken };
|
|
@@ -20,17 +20,36 @@ const pxValues = new Set([
|
|
|
20
20
|
"right",
|
|
21
21
|
"bottom",
|
|
22
22
|
"left",
|
|
23
|
+
"inset",
|
|
24
|
+
"insetBlock",
|
|
25
|
+
"insetBlockStart",
|
|
26
|
+
"insetBlockEnd",
|
|
27
|
+
"insetInline",
|
|
28
|
+
"insetInlineStart",
|
|
29
|
+
"insetInlineEnd",
|
|
23
30
|
// Spacing props
|
|
24
31
|
"padding",
|
|
25
32
|
"paddingTop",
|
|
26
33
|
"paddingRight",
|
|
27
34
|
"paddingBottom",
|
|
28
35
|
"paddingLeft",
|
|
36
|
+
"paddingBlock",
|
|
37
|
+
"paddingBlockStart",
|
|
38
|
+
"paddingBlockEnd",
|
|
39
|
+
"paddingInline",
|
|
40
|
+
"paddingInlineStart",
|
|
41
|
+
"paddingInlineEnd",
|
|
29
42
|
"margin",
|
|
30
43
|
"marginTop",
|
|
31
44
|
"marginRight",
|
|
32
45
|
"marginBottom",
|
|
33
46
|
"marginLeft",
|
|
47
|
+
"marginBlock",
|
|
48
|
+
"marginBlockStart",
|
|
49
|
+
"marginBlockEnd",
|
|
50
|
+
"marginInline",
|
|
51
|
+
"marginInlineStart",
|
|
52
|
+
"marginInlineEnd",
|
|
34
53
|
// Misc
|
|
35
54
|
"backgroundPositionX",
|
|
36
55
|
"backgroundPositionY",
|
package/dist/es/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ export { NativeAnimationWrapper } from './animation/NativeAnimationWrapper.mjs';
|
|
|
8
8
|
export { animationMapKey, getAnimationMap } from './animation/utils/active-animations.mjs';
|
|
9
9
|
export { getVariableValue, parseCSSVariable } from './animation/utils/css-variables-conversion.mjs';
|
|
10
10
|
export { getValueTransition } from './animation/utils/get-value-transition.mjs';
|
|
11
|
-
export {
|
|
11
|
+
export { isCSSVariableName, isCSSVariableToken } from './animation/utils/is-css-variable.mjs';
|
|
12
12
|
export { makeAnimationInstant } from './animation/utils/make-animation-instant.mjs';
|
|
13
13
|
export { inertia } from './animation/generators/inertia.mjs';
|
|
14
14
|
export { defaultEasing, keyframes } from './animation/generators/keyframes.mjs';
|
|
@@ -52,7 +52,13 @@ function attachSpring(value, source, options) {
|
|
|
52
52
|
value.attach((v, set) => {
|
|
53
53
|
latestValue = v;
|
|
54
54
|
latestSetter = (latest) => set(parseValue(latest, unit));
|
|
55
|
-
frame.postRender(
|
|
55
|
+
frame.postRender(() => {
|
|
56
|
+
startAnimation();
|
|
57
|
+
value['events'].animationStart?.notify();
|
|
58
|
+
activeAnimation?.then(() => {
|
|
59
|
+
value['events'].animationComplete?.notify();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
56
62
|
}, stopAnimation);
|
|
57
63
|
if (isMotionValue(source)) {
|
|
58
64
|
const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
|
|
@@ -25,17 +25,36 @@ const numberValueTypes = {
|
|
|
25
25
|
right: px,
|
|
26
26
|
bottom: px,
|
|
27
27
|
left: px,
|
|
28
|
+
inset: px,
|
|
29
|
+
insetBlock: px,
|
|
30
|
+
insetBlockStart: px,
|
|
31
|
+
insetBlockEnd: px,
|
|
32
|
+
insetInline: px,
|
|
33
|
+
insetInlineStart: px,
|
|
34
|
+
insetInlineEnd: px,
|
|
28
35
|
// Spacing props
|
|
29
36
|
padding: px,
|
|
30
37
|
paddingTop: px,
|
|
31
38
|
paddingRight: px,
|
|
32
39
|
paddingBottom: px,
|
|
33
40
|
paddingLeft: px,
|
|
41
|
+
paddingBlock: px,
|
|
42
|
+
paddingBlockStart: px,
|
|
43
|
+
paddingBlockEnd: px,
|
|
44
|
+
paddingInline: px,
|
|
45
|
+
paddingInlineStart: px,
|
|
46
|
+
paddingInlineEnd: px,
|
|
34
47
|
margin: px,
|
|
35
48
|
marginTop: px,
|
|
36
49
|
marginRight: px,
|
|
37
50
|
marginBottom: px,
|
|
38
51
|
marginLeft: px,
|
|
52
|
+
marginBlock: px,
|
|
53
|
+
marginBlockStart: px,
|
|
54
|
+
marginBlockEnd: px,
|
|
55
|
+
marginInline: px,
|
|
56
|
+
marginInlineStart: px,
|
|
57
|
+
marginInlineEnd: px,
|
|
39
58
|
// Misc
|
|
40
59
|
backgroundPositionX: px,
|
|
41
60
|
backgroundPositionY: px,
|