animejs 4.3.6 → 4.4.1
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/README.md +6 -9
- package/dist/bundles/anime.esm.js +973 -391
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +977 -390
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +1 -1
- package/dist/modules/animatable/animatable.js +2 -2
- package/dist/modules/animatable/index.cjs +1 -1
- package/dist/modules/animatable/index.js +1 -1
- package/dist/modules/animation/additive.cjs +1 -1
- package/dist/modules/animation/additive.js +1 -1
- package/dist/modules/animation/animation.cjs +38 -16
- package/dist/modules/animation/animation.d.ts +2 -2
- package/dist/modules/animation/animation.js +42 -20
- package/dist/modules/animation/composition.cjs +1 -1
- package/dist/modules/animation/composition.js +3 -3
- package/dist/modules/animation/index.cjs +1 -1
- package/dist/modules/animation/index.js +1 -1
- package/dist/modules/core/clock.cjs +1 -1
- package/dist/modules/core/clock.js +1 -1
- package/dist/modules/core/colors.cjs +1 -1
- package/dist/modules/core/colors.js +1 -1
- package/dist/modules/core/consts.cjs +3 -9
- package/dist/modules/core/consts.d.ts +1 -5
- package/dist/modules/core/consts.js +4 -8
- package/dist/modules/core/globals.cjs +16 -5
- package/dist/modules/core/globals.d.ts +22 -1
- package/dist/modules/core/globals.js +18 -6
- package/dist/modules/core/helpers.cjs +7 -10
- package/dist/modules/core/helpers.js +8 -11
- package/dist/modules/core/render.cjs +7 -34
- package/dist/modules/core/render.js +8 -35
- package/dist/modules/core/styles.cjs +53 -32
- package/dist/modules/core/styles.d.ts +1 -0
- package/dist/modules/core/styles.js +55 -35
- package/dist/modules/core/targets.cjs +1 -1
- package/dist/modules/core/targets.js +1 -1
- package/dist/modules/core/transforms.cjs +129 -13
- package/dist/modules/core/transforms.d.ts +1 -0
- package/dist/modules/core/transforms.js +130 -15
- package/dist/modules/core/units.cjs +1 -1
- package/dist/modules/core/units.js +1 -1
- package/dist/modules/core/values.cjs +68 -8
- package/dist/modules/core/values.d.ts +5 -2
- package/dist/modules/core/values.js +69 -11
- package/dist/modules/draggable/draggable.cjs +1 -1
- package/dist/modules/draggable/draggable.js +1 -1
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
- package/dist/modules/easings/cubic-bezier/index.js +1 -1
- package/dist/modules/easings/eases/index.cjs +1 -1
- package/dist/modules/easings/eases/index.js +1 -1
- package/dist/modules/easings/eases/parser.cjs +1 -1
- package/dist/modules/easings/eases/parser.js +1 -1
- package/dist/modules/easings/index.cjs +1 -1
- package/dist/modules/easings/index.js +1 -1
- package/dist/modules/easings/irregular/index.cjs +1 -1
- package/dist/modules/easings/irregular/index.js +1 -1
- package/dist/modules/easings/linear/index.cjs +1 -1
- package/dist/modules/easings/linear/index.js +1 -1
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +1 -1
- package/dist/modules/easings/spring/index.js +1 -1
- package/dist/modules/easings/steps/index.cjs +1 -1
- package/dist/modules/easings/steps/index.js +1 -1
- package/dist/modules/engine/engine.cjs +1 -1
- package/dist/modules/engine/engine.js +1 -1
- package/dist/modules/engine/index.cjs +1 -1
- package/dist/modules/engine/index.js +1 -1
- package/dist/modules/events/index.cjs +1 -1
- package/dist/modules/events/index.js +1 -1
- package/dist/modules/events/scroll.cjs +1 -1
- package/dist/modules/events/scroll.js +1 -1
- package/dist/modules/index.cjs +9 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +4 -1
- package/dist/modules/layout/index.cjs +1 -1
- package/dist/modules/layout/index.js +1 -1
- package/dist/modules/layout/layout.cjs +29 -25
- package/dist/modules/layout/layout.d.ts +4 -3
- package/dist/modules/layout/layout.js +30 -26
- package/dist/modules/scope/index.cjs +1 -1
- package/dist/modules/scope/index.js +1 -1
- package/dist/modules/scope/scope.cjs +1 -1
- package/dist/modules/scope/scope.js +1 -1
- package/dist/modules/svg/drawable.cjs +1 -1
- package/dist/modules/svg/drawable.js +1 -1
- package/dist/modules/svg/helpers.cjs +1 -1
- package/dist/modules/svg/helpers.js +1 -1
- package/dist/modules/svg/index.cjs +1 -1
- package/dist/modules/svg/index.js +1 -1
- package/dist/modules/svg/morphto.cjs +3 -6
- package/dist/modules/svg/morphto.js +3 -6
- package/dist/modules/svg/motionpath.cjs +1 -1
- package/dist/modules/svg/motionpath.js +1 -1
- package/dist/modules/text/index.cjs +3 -1
- package/dist/modules/text/index.d.ts +1 -0
- package/dist/modules/text/index.js +2 -1
- package/dist/modules/text/scramble.cjs +272 -0
- package/dist/modules/text/scramble.d.ts +3 -0
- package/dist/modules/text/scramble.js +270 -0
- package/dist/modules/text/split.cjs +5 -5
- package/dist/modules/text/split.d.ts +5 -5
- package/dist/modules/text/split.js +5 -5
- package/dist/modules/timeline/index.cjs +1 -1
- package/dist/modules/timeline/index.js +1 -1
- package/dist/modules/timeline/position.cjs +1 -1
- package/dist/modules/timeline/position.js +1 -1
- package/dist/modules/timeline/timeline.cjs +36 -18
- package/dist/modules/timeline/timeline.d.ts +6 -5
- package/dist/modules/timeline/timeline.js +37 -19
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +8 -12
- package/dist/modules/timer/timer.d.ts +2 -0
- package/dist/modules/timer/timer.js +9 -13
- package/dist/modules/types/index.d.ts +76 -8
- package/dist/modules/utils/chainable.cjs +8 -5
- package/dist/modules/utils/chainable.js +8 -5
- package/dist/modules/utils/index.cjs +5 -1
- package/dist/modules/utils/index.d.ts +1 -0
- package/dist/modules/utils/index.js +2 -1
- package/dist/modules/utils/number.cjs +1 -1
- package/dist/modules/utils/number.js +1 -1
- package/dist/modules/utils/random.cjs +1 -1
- package/dist/modules/utils/random.js +1 -1
- package/dist/modules/utils/stagger.cjs +117 -20
- package/dist/modules/utils/stagger.js +118 -21
- package/dist/modules/utils/target.cjs +1 -1
- package/dist/modules/utils/target.js +1 -1
- package/dist/modules/utils/time.cjs +5 -3
- package/dist/modules/utils/time.d.ts +1 -1
- package/dist/modules/utils/time.js +5 -3
- package/dist/modules/waapi/composition.cjs +1 -1
- package/dist/modules/waapi/composition.js +1 -1
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +19 -20
- package/dist/modules/waapi/waapi.js +20 -21
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - CJS
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -24,26 +24,142 @@ var helpers = require('./helpers.cjs');
|
|
|
24
24
|
*/
|
|
25
25
|
const parseInlineTransforms = (target, propName, animationInlineStyles) => {
|
|
26
26
|
const inlineTransforms = target.style.transform;
|
|
27
|
-
let inlinedStylesPropertyValue;
|
|
28
27
|
if (inlineTransforms) {
|
|
29
28
|
const cachedTransforms = target[consts.transformsSymbol];
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
let pos = 0;
|
|
30
|
+
const len = inlineTransforms.length;
|
|
31
|
+
let fullTranslateValue;
|
|
32
|
+
while (pos < len) {
|
|
33
|
+
// Skip whitespace
|
|
34
|
+
while (pos < len && inlineTransforms.charCodeAt(pos) === 32) pos++;
|
|
35
|
+
if (pos >= len) break;
|
|
36
|
+
// Read function name
|
|
37
|
+
const nameStart = pos;
|
|
38
|
+
while (pos < len && inlineTransforms.charCodeAt(pos) !== 40) pos++;
|
|
39
|
+
if (pos >= len) break;
|
|
40
|
+
const name = inlineTransforms.substring(nameStart, pos);
|
|
41
|
+
// Scan to closing paren, recording top-level comma positions
|
|
42
|
+
let depth = 1;
|
|
43
|
+
const valueStart = pos + 1;
|
|
44
|
+
let c1 = -1, c2 = -1;
|
|
45
|
+
pos++;
|
|
46
|
+
while (pos < len && depth > 0) {
|
|
47
|
+
const c = inlineTransforms.charCodeAt(pos);
|
|
48
|
+
if (c === 40) depth++;
|
|
49
|
+
else if (c === 41) depth--;
|
|
50
|
+
else if (c === 44 && depth === 1) {
|
|
51
|
+
if (c1 === -1) c1 = pos;
|
|
52
|
+
else if (c2 === -1) c2 = pos;
|
|
40
53
|
}
|
|
54
|
+
pos++;
|
|
41
55
|
}
|
|
56
|
+
const valueEnd = pos - 1;
|
|
57
|
+
// Decompose multi-arg functions into individual axis properties
|
|
58
|
+
if (name === 'translate' || name === 'translate3d') {
|
|
59
|
+
if (c1 === -1) {
|
|
60
|
+
cachedTransforms.translateX = inlineTransforms.substring(valueStart, valueEnd).trim();
|
|
61
|
+
} else {
|
|
62
|
+
cachedTransforms.translateX = inlineTransforms.substring(valueStart, c1).trim();
|
|
63
|
+
if (c2 === -1) {
|
|
64
|
+
cachedTransforms.translateY = inlineTransforms.substring(c1 + 1, valueEnd).trim();
|
|
65
|
+
} else {
|
|
66
|
+
cachedTransforms.translateY = inlineTransforms.substring(c1 + 1, c2).trim();
|
|
67
|
+
cachedTransforms.translateZ = inlineTransforms.substring(c2 + 1, valueEnd).trim();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
fullTranslateValue = inlineTransforms.substring(valueStart, valueEnd);
|
|
71
|
+
} else if (name === 'scale' || name === 'scale3d') {
|
|
72
|
+
if (c1 === -1) {
|
|
73
|
+
cachedTransforms.scale = inlineTransforms.substring(valueStart, valueEnd).trim();
|
|
74
|
+
} else {
|
|
75
|
+
cachedTransforms.scaleX = inlineTransforms.substring(valueStart, c1).trim();
|
|
76
|
+
if (c2 === -1) {
|
|
77
|
+
cachedTransforms.scaleY = inlineTransforms.substring(c1 + 1, valueEnd).trim();
|
|
78
|
+
} else {
|
|
79
|
+
cachedTransforms.scaleY = inlineTransforms.substring(c1 + 1, c2).trim();
|
|
80
|
+
cachedTransforms.scaleZ = inlineTransforms.substring(c2 + 1, valueEnd).trim();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
cachedTransforms[name] = inlineTransforms.substring(valueStart, valueEnd);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Resolve the requested property from the cache
|
|
88
|
+
if (propName === 'translate3d' && fullTranslateValue) {
|
|
89
|
+
if (animationInlineStyles) animationInlineStyles[propName] = fullTranslateValue;
|
|
90
|
+
return fullTranslateValue;
|
|
91
|
+
}
|
|
92
|
+
const cached = cachedTransforms[propName];
|
|
93
|
+
if (!helpers.isUnd(cached)) {
|
|
94
|
+
if (animationInlineStyles) animationInlineStyles[propName] = cached;
|
|
95
|
+
return cached;
|
|
42
96
|
}
|
|
43
97
|
}
|
|
44
|
-
return
|
|
98
|
+
return propName === 'translate3d' ? '0px, 0px, 0px' :
|
|
99
|
+
propName === 'rotate3d' ? '0, 0, 0, 0deg' :
|
|
45
100
|
helpers.stringStartsWith(propName, 'scale') ? '1' :
|
|
46
101
|
helpers.stringStartsWith(propName, 'rotate') || helpers.stringStartsWith(propName, 'skew') ? '0deg' : '0px';
|
|
47
102
|
};
|
|
48
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Builds a CSS transform string from the target's cached transform properties.
|
|
106
|
+
* Iterates validTransforms in order (perspective > translate > rotate > scale > skew > matrix).
|
|
107
|
+
* When adjacent axis properties are all present, emits a shorter shorthand (translateX + translateY -> translate(x, y))
|
|
108
|
+
* The index is advanced past consumed properties so they are not emitted twice.
|
|
109
|
+
* Properties without a grouping partner (e.g. translateY alone, scaleZ alone) emit individually.
|
|
110
|
+
*
|
|
111
|
+
* @param {Record<String, String>} props
|
|
112
|
+
* @return {String}
|
|
113
|
+
*/
|
|
114
|
+
const buildTransformString = (props) => {
|
|
115
|
+
let str = consts.emptyString;
|
|
116
|
+
for (let i = 0, l = consts.validTransforms.length; i < l; i++) {
|
|
117
|
+
const key = consts.validTransforms[i];
|
|
118
|
+
const val = props[key];
|
|
119
|
+
if (val !== undefined) {
|
|
120
|
+
// Group translateX with adjacent translateY / translateZ
|
|
121
|
+
if (key === 'translateX') {
|
|
122
|
+
const next = props.translateY;
|
|
123
|
+
if (next !== undefined) {
|
|
124
|
+
const next2 = props.translateZ;
|
|
125
|
+
if (next2 !== undefined) {
|
|
126
|
+
str += `translate3d(${val},${next},${next2}) `;
|
|
127
|
+
i += 2;
|
|
128
|
+
} else {
|
|
129
|
+
str += `translate(${val},${next}) `;
|
|
130
|
+
i += 1;
|
|
131
|
+
}
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Group scaleX with adjacent scaleY / scaleZ (only when standalone scale is absent)
|
|
136
|
+
if (key === 'scaleX' && props.scale === undefined) {
|
|
137
|
+
const next = props.scaleY;
|
|
138
|
+
if (next !== undefined) {
|
|
139
|
+
const next2 = props.scaleZ;
|
|
140
|
+
if (next2 !== undefined) {
|
|
141
|
+
str += `scale3d(${val},${next},${next2}) `;
|
|
142
|
+
i += 2;
|
|
143
|
+
} else {
|
|
144
|
+
str += `scale(${val},${next}) `;
|
|
145
|
+
i += 1;
|
|
146
|
+
}
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// All other properties: emit individually using pre-built fragment string
|
|
151
|
+
str += `${consts.transformsFragmentStrings[key]}${val}) `;
|
|
152
|
+
}
|
|
153
|
+
// Preserve non-animatable rotate3d in correct position (after rotateZ, before scale)
|
|
154
|
+
if (key === 'rotateZ') {
|
|
155
|
+
if (props.rotate3d !== undefined) str += `rotate3d(${props.rotate3d}) `;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Preserve non-animatable matrix/matrix3d from inline styles
|
|
159
|
+
if (props.matrix !== undefined) str += `matrix(${props.matrix}) `;
|
|
160
|
+
if (props.matrix3d !== undefined) str += `matrix3d(${props.matrix3d}) `;
|
|
161
|
+
return str;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
exports.buildTransformString = buildTransformString;
|
|
49
165
|
exports.parseInlineTransforms = parseInlineTransforms;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { transformsFragmentStrings, emptyString, validTransforms, transformsSymbol } from './consts.js';
|
|
9
9
|
import { isUnd, stringStartsWith } from './helpers.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -22,26 +22,141 @@ import { isUnd, stringStartsWith } from './helpers.js';
|
|
|
22
22
|
*/
|
|
23
23
|
const parseInlineTransforms = (target, propName, animationInlineStyles) => {
|
|
24
24
|
const inlineTransforms = target.style.transform;
|
|
25
|
-
let inlinedStylesPropertyValue;
|
|
26
25
|
if (inlineTransforms) {
|
|
27
26
|
const cachedTransforms = target[transformsSymbol];
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
let pos = 0;
|
|
28
|
+
const len = inlineTransforms.length;
|
|
29
|
+
let fullTranslateValue;
|
|
30
|
+
while (pos < len) {
|
|
31
|
+
// Skip whitespace
|
|
32
|
+
while (pos < len && inlineTransforms.charCodeAt(pos) === 32) pos++;
|
|
33
|
+
if (pos >= len) break;
|
|
34
|
+
// Read function name
|
|
35
|
+
const nameStart = pos;
|
|
36
|
+
while (pos < len && inlineTransforms.charCodeAt(pos) !== 40) pos++;
|
|
37
|
+
if (pos >= len) break;
|
|
38
|
+
const name = inlineTransforms.substring(nameStart, pos);
|
|
39
|
+
// Scan to closing paren, recording top-level comma positions
|
|
40
|
+
let depth = 1;
|
|
41
|
+
const valueStart = pos + 1;
|
|
42
|
+
let c1 = -1, c2 = -1;
|
|
43
|
+
pos++;
|
|
44
|
+
while (pos < len && depth > 0) {
|
|
45
|
+
const c = inlineTransforms.charCodeAt(pos);
|
|
46
|
+
if (c === 40) depth++;
|
|
47
|
+
else if (c === 41) depth--;
|
|
48
|
+
else if (c === 44 && depth === 1) {
|
|
49
|
+
if (c1 === -1) c1 = pos;
|
|
50
|
+
else if (c2 === -1) c2 = pos;
|
|
38
51
|
}
|
|
52
|
+
pos++;
|
|
39
53
|
}
|
|
54
|
+
const valueEnd = pos - 1;
|
|
55
|
+
// Decompose multi-arg functions into individual axis properties
|
|
56
|
+
if (name === 'translate' || name === 'translate3d') {
|
|
57
|
+
if (c1 === -1) {
|
|
58
|
+
cachedTransforms.translateX = inlineTransforms.substring(valueStart, valueEnd).trim();
|
|
59
|
+
} else {
|
|
60
|
+
cachedTransforms.translateX = inlineTransforms.substring(valueStart, c1).trim();
|
|
61
|
+
if (c2 === -1) {
|
|
62
|
+
cachedTransforms.translateY = inlineTransforms.substring(c1 + 1, valueEnd).trim();
|
|
63
|
+
} else {
|
|
64
|
+
cachedTransforms.translateY = inlineTransforms.substring(c1 + 1, c2).trim();
|
|
65
|
+
cachedTransforms.translateZ = inlineTransforms.substring(c2 + 1, valueEnd).trim();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
fullTranslateValue = inlineTransforms.substring(valueStart, valueEnd);
|
|
69
|
+
} else if (name === 'scale' || name === 'scale3d') {
|
|
70
|
+
if (c1 === -1) {
|
|
71
|
+
cachedTransforms.scale = inlineTransforms.substring(valueStart, valueEnd).trim();
|
|
72
|
+
} else {
|
|
73
|
+
cachedTransforms.scaleX = inlineTransforms.substring(valueStart, c1).trim();
|
|
74
|
+
if (c2 === -1) {
|
|
75
|
+
cachedTransforms.scaleY = inlineTransforms.substring(c1 + 1, valueEnd).trim();
|
|
76
|
+
} else {
|
|
77
|
+
cachedTransforms.scaleY = inlineTransforms.substring(c1 + 1, c2).trim();
|
|
78
|
+
cachedTransforms.scaleZ = inlineTransforms.substring(c2 + 1, valueEnd).trim();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
cachedTransforms[name] = inlineTransforms.substring(valueStart, valueEnd);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Resolve the requested property from the cache
|
|
86
|
+
if (propName === 'translate3d' && fullTranslateValue) {
|
|
87
|
+
if (animationInlineStyles) animationInlineStyles[propName] = fullTranslateValue;
|
|
88
|
+
return fullTranslateValue;
|
|
89
|
+
}
|
|
90
|
+
const cached = cachedTransforms[propName];
|
|
91
|
+
if (!isUnd(cached)) {
|
|
92
|
+
if (animationInlineStyles) animationInlineStyles[propName] = cached;
|
|
93
|
+
return cached;
|
|
40
94
|
}
|
|
41
95
|
}
|
|
42
|
-
return
|
|
96
|
+
return propName === 'translate3d' ? '0px, 0px, 0px' :
|
|
97
|
+
propName === 'rotate3d' ? '0, 0, 0, 0deg' :
|
|
43
98
|
stringStartsWith(propName, 'scale') ? '1' :
|
|
44
99
|
stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew') ? '0deg' : '0px';
|
|
45
100
|
};
|
|
46
101
|
|
|
47
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Builds a CSS transform string from the target's cached transform properties.
|
|
104
|
+
* Iterates validTransforms in order (perspective > translate > rotate > scale > skew > matrix).
|
|
105
|
+
* When adjacent axis properties are all present, emits a shorter shorthand (translateX + translateY -> translate(x, y))
|
|
106
|
+
* The index is advanced past consumed properties so they are not emitted twice.
|
|
107
|
+
* Properties without a grouping partner (e.g. translateY alone, scaleZ alone) emit individually.
|
|
108
|
+
*
|
|
109
|
+
* @param {Record<String, String>} props
|
|
110
|
+
* @return {String}
|
|
111
|
+
*/
|
|
112
|
+
const buildTransformString = (props) => {
|
|
113
|
+
let str = emptyString;
|
|
114
|
+
for (let i = 0, l = validTransforms.length; i < l; i++) {
|
|
115
|
+
const key = validTransforms[i];
|
|
116
|
+
const val = props[key];
|
|
117
|
+
if (val !== undefined) {
|
|
118
|
+
// Group translateX with adjacent translateY / translateZ
|
|
119
|
+
if (key === 'translateX') {
|
|
120
|
+
const next = props.translateY;
|
|
121
|
+
if (next !== undefined) {
|
|
122
|
+
const next2 = props.translateZ;
|
|
123
|
+
if (next2 !== undefined) {
|
|
124
|
+
str += `translate3d(${val},${next},${next2}) `;
|
|
125
|
+
i += 2;
|
|
126
|
+
} else {
|
|
127
|
+
str += `translate(${val},${next}) `;
|
|
128
|
+
i += 1;
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Group scaleX with adjacent scaleY / scaleZ (only when standalone scale is absent)
|
|
134
|
+
if (key === 'scaleX' && props.scale === undefined) {
|
|
135
|
+
const next = props.scaleY;
|
|
136
|
+
if (next !== undefined) {
|
|
137
|
+
const next2 = props.scaleZ;
|
|
138
|
+
if (next2 !== undefined) {
|
|
139
|
+
str += `scale3d(${val},${next},${next2}) `;
|
|
140
|
+
i += 2;
|
|
141
|
+
} else {
|
|
142
|
+
str += `scale(${val},${next}) `;
|
|
143
|
+
i += 1;
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// All other properties: emit individually using pre-built fragment string
|
|
149
|
+
str += `${transformsFragmentStrings[key]}${val}) `;
|
|
150
|
+
}
|
|
151
|
+
// Preserve non-animatable rotate3d in correct position (after rotateZ, before scale)
|
|
152
|
+
if (key === 'rotateZ') {
|
|
153
|
+
if (props.rotate3d !== undefined) str += `rotate3d(${props.rotate3d}) `;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Preserve non-animatable matrix/matrix3d from inline styles
|
|
157
|
+
if (props.matrix !== undefined) str += `matrix(${props.matrix}) `;
|
|
158
|
+
if (props.matrix3d !== undefined) str += `matrix3d(${props.matrix3d}) `;
|
|
159
|
+
return str;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export { buildTransformString, parseInlineTransforms };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - CJS
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -19,6 +19,7 @@ var colors = require('./colors.cjs');
|
|
|
19
19
|
* Tween,
|
|
20
20
|
* TweenPropValue,
|
|
21
21
|
* TweenDecomposedValue,
|
|
22
|
+
* TargetsArray,
|
|
22
23
|
* } from '../types/index.js'
|
|
23
24
|
*/
|
|
24
25
|
|
|
@@ -36,15 +37,16 @@ const setValue = (targetValue, defaultValue) => {
|
|
|
36
37
|
* @param {TweenPropValue} value
|
|
37
38
|
* @param {Target} target
|
|
38
39
|
* @param {Number} index
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {Object}
|
|
40
|
+
* @param {TargetsArray} targets
|
|
41
|
+
* @param {Object|null} store
|
|
42
|
+
* @param {Tween|null} prevTween
|
|
41
43
|
* @return {any}
|
|
42
44
|
*/
|
|
43
|
-
const getFunctionValue = (value, target, index,
|
|
45
|
+
const getFunctionValue = (value, target, index, targets, store, prevTween) => {
|
|
44
46
|
let func;
|
|
45
47
|
if (helpers.isFnc(value)) {
|
|
46
48
|
func = () => {
|
|
47
|
-
const computed = /** @type {Function} */(value)(target, index,
|
|
49
|
+
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
|
|
48
50
|
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
|
|
49
51
|
return !isNaN(+computed) ? +computed : computed || 0;
|
|
50
52
|
};
|
|
@@ -111,9 +113,17 @@ const getCSSValue = (target, propName, animationInlineStyles) => {
|
|
|
111
113
|
*/
|
|
112
114
|
const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
|
|
113
115
|
const type = !helpers.isUnd(tweenType) ? tweenType : getTweenType(target, propName);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
if (type === consts.tweenTypes.OBJECT) {
|
|
117
|
+
const value = target[propName];
|
|
118
|
+
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
|
|
119
|
+
return value || 0;
|
|
120
|
+
}
|
|
121
|
+
if (type === consts.tweenTypes.ATTRIBUTE) {
|
|
122
|
+
const value = /** @type {DOMTarget} */(target).getAttribute(propName);
|
|
123
|
+
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
return type === consts.tweenTypes.TRANSFORM ? transforms.parseInlineTransforms(/** @type {DOMTarget} */(target), propName, animationInlineStyles) :
|
|
117
127
|
type === consts.tweenTypes.CSS_VAR ? getCSSValue(/** @type {DOMTarget} */(target), propName, animationInlineStyles).trimStart() :
|
|
118
128
|
getCSSValue(/** @type {DOMTarget} */(target), propName, animationInlineStyles);
|
|
119
129
|
};
|
|
@@ -215,6 +225,56 @@ const decomposeTweenValue = (tween, targetObject) => {
|
|
|
215
225
|
|
|
216
226
|
const decomposedOriginalValue = createDecomposedValueTargetObject();
|
|
217
227
|
|
|
228
|
+
/**
|
|
229
|
+
* @param {Tween} tween
|
|
230
|
+
* @param {Number} progress
|
|
231
|
+
* @param {Number} precision
|
|
232
|
+
* @return {String}
|
|
233
|
+
*/
|
|
234
|
+
const composeColorValue = (tween, progress, precision) => {
|
|
235
|
+
const mod = tween._modifier;
|
|
236
|
+
const fn = tween._fromNumbers;
|
|
237
|
+
const tn = tween._toNumbers;
|
|
238
|
+
const r = helpers.round(helpers.clamp(/** @type {Number} */(mod(helpers.lerp(fn[0], tn[0], progress))), 0, 255), 0);
|
|
239
|
+
const g = helpers.round(helpers.clamp(/** @type {Number} */(mod(helpers.lerp(fn[1], tn[1], progress))), 0, 255), 0);
|
|
240
|
+
const b = helpers.round(helpers.clamp(/** @type {Number} */(mod(helpers.lerp(fn[2], tn[2], progress))), 0, 255), 0);
|
|
241
|
+
const a = helpers.clamp(/** @type {Number} */(mod(helpers.round(helpers.lerp(fn[3], tn[3], progress), precision))), 0, 1);
|
|
242
|
+
if (tween._composition !== consts.compositionTypes.none) {
|
|
243
|
+
const ns = tween._numbers;
|
|
244
|
+
ns[0] = r;
|
|
245
|
+
ns[1] = g;
|
|
246
|
+
ns[2] = b;
|
|
247
|
+
ns[3] = a;
|
|
248
|
+
}
|
|
249
|
+
return `rgba(${r},${g},${b},${a})`;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @param {Tween} tween
|
|
254
|
+
* @param {Number} progress
|
|
255
|
+
* @param {Number} precision
|
|
256
|
+
* @return {String}
|
|
257
|
+
*/
|
|
258
|
+
const composeComplexValue = (tween, progress, precision) => {
|
|
259
|
+
const mod = tween._modifier;
|
|
260
|
+
const fn = tween._fromNumbers;
|
|
261
|
+
const tn = tween._toNumbers;
|
|
262
|
+
const ts = tween._strings;
|
|
263
|
+
const hasComposition = tween._composition !== consts.compositionTypes.none;
|
|
264
|
+
let v = ts[0];
|
|
265
|
+
for (let j = 0, l = tn.length; j < l; j++) {
|
|
266
|
+
const n = /** @type {Number} */(mod(helpers.round(helpers.lerp(fn[j], tn[j], progress), precision)));
|
|
267
|
+
const s = ts[j + 1];
|
|
268
|
+
v += `${s ? n + s : n}`;
|
|
269
|
+
if (hasComposition) {
|
|
270
|
+
tween._numbers[j] = n;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return v;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
exports.composeColorValue = composeColorValue;
|
|
277
|
+
exports.composeComplexValue = composeComplexValue;
|
|
218
278
|
exports.createDecomposedValueTargetObject = createDecomposedValueTargetObject;
|
|
219
279
|
exports.decomposeRawValue = decomposeRawValue;
|
|
220
280
|
exports.decomposeTweenValue = decomposeTweenValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function setValue<T, D>(targetValue: T | undefined, defaultValue: D): T | D;
|
|
2
|
-
export function getFunctionValue(value: TweenPropValue, target: Target, index: number,
|
|
2
|
+
export function getFunctionValue(value: TweenPropValue, target: Target, index: number, targets: TargetsArray, store: any | null, prevTween: Tween | null): any;
|
|
3
3
|
export function getTweenType(target: Target, prop: string): tweenTypes;
|
|
4
4
|
export function getOriginalAnimatableValue(target: Target, propName: string, tweenType?: tweenTypes, animationInlineStyles?: any | void): string | number;
|
|
5
5
|
export function getRelativeValue(x: number, y: number, operator: string): number;
|
|
@@ -7,8 +7,11 @@ export function createDecomposedValueTargetObject(): TweenDecomposedValue;
|
|
|
7
7
|
export function decomposeRawValue(rawValue: string | number, targetObject: TweenDecomposedValue): TweenDecomposedValue;
|
|
8
8
|
export function decomposeTweenValue(tween: Tween, targetObject: TweenDecomposedValue): TweenDecomposedValue;
|
|
9
9
|
export const decomposedOriginalValue: TweenDecomposedValue;
|
|
10
|
+
export function composeColorValue(tween: Tween, progress: number, precision: number): string;
|
|
11
|
+
export function composeComplexValue(tween: Tween, progress: number, precision: number): string;
|
|
10
12
|
import type { TweenPropValue } from '../types/index.js';
|
|
11
13
|
import type { Target } from '../types/index.js';
|
|
14
|
+
import type { TargetsArray } from '../types/index.js';
|
|
15
|
+
import type { Tween } from '../types/index.js';
|
|
12
16
|
import { tweenTypes } from './consts.js';
|
|
13
17
|
import type { TweenDecomposedValue } from '../types/index.js';
|
|
14
|
-
import type { Tween } from '../types/index.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, proxyTargetSymbol, cssVarPrefix, cssVariableMatchRgx, emptyString } from './consts.js';
|
|
9
|
-
import { isUnd, isValidSVGAttribute, stringStartsWith, isCol, isFnc, isStr, cloneArray } from './helpers.js';
|
|
8
|
+
import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, compositionTypes, proxyTargetSymbol, cssVarPrefix, cssVariableMatchRgx, emptyString } from './consts.js';
|
|
9
|
+
import { isUnd, isValidSVGAttribute, stringStartsWith, isCol, isFnc, isStr, round, lerp, clamp, cloneArray } from './helpers.js';
|
|
10
10
|
import { parseInlineTransforms } from './transforms.js';
|
|
11
11
|
import { convertColorStringValuesToRgbaArray } from './colors.js';
|
|
12
12
|
|
|
@@ -17,6 +17,7 @@ import { convertColorStringValuesToRgbaArray } from './colors.js';
|
|
|
17
17
|
* Tween,
|
|
18
18
|
* TweenPropValue,
|
|
19
19
|
* TweenDecomposedValue,
|
|
20
|
+
* TargetsArray,
|
|
20
21
|
* } from '../types/index.js'
|
|
21
22
|
*/
|
|
22
23
|
|
|
@@ -34,15 +35,16 @@ const setValue = (targetValue, defaultValue) => {
|
|
|
34
35
|
* @param {TweenPropValue} value
|
|
35
36
|
* @param {Target} target
|
|
36
37
|
* @param {Number} index
|
|
37
|
-
* @param {
|
|
38
|
-
* @param {Object}
|
|
38
|
+
* @param {TargetsArray} targets
|
|
39
|
+
* @param {Object|null} store
|
|
40
|
+
* @param {Tween|null} prevTween
|
|
39
41
|
* @return {any}
|
|
40
42
|
*/
|
|
41
|
-
const getFunctionValue = (value, target, index,
|
|
43
|
+
const getFunctionValue = (value, target, index, targets, store, prevTween) => {
|
|
42
44
|
let func;
|
|
43
45
|
if (isFnc(value)) {
|
|
44
46
|
func = () => {
|
|
45
|
-
const computed = /** @type {Function} */(value)(target, index,
|
|
47
|
+
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
|
|
46
48
|
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
|
|
47
49
|
return !isNaN(+computed) ? +computed : computed || 0;
|
|
48
50
|
};
|
|
@@ -109,9 +111,17 @@ const getCSSValue = (target, propName, animationInlineStyles) => {
|
|
|
109
111
|
*/
|
|
110
112
|
const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
|
|
111
113
|
const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
if (type === tweenTypes.OBJECT) {
|
|
115
|
+
const value = target[propName];
|
|
116
|
+
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
|
|
117
|
+
return value || 0;
|
|
118
|
+
}
|
|
119
|
+
if (type === tweenTypes.ATTRIBUTE) {
|
|
120
|
+
const value = /** @type {DOMTarget} */(target).getAttribute(propName);
|
|
121
|
+
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
return type === tweenTypes.TRANSFORM ? parseInlineTransforms(/** @type {DOMTarget} */(target), propName, animationInlineStyles) :
|
|
115
125
|
type === tweenTypes.CSS_VAR ? getCSSValue(/** @type {DOMTarget} */(target), propName, animationInlineStyles).trimStart() :
|
|
116
126
|
getCSSValue(/** @type {DOMTarget} */(target), propName, animationInlineStyles);
|
|
117
127
|
};
|
|
@@ -213,4 +223,52 @@ const decomposeTweenValue = (tween, targetObject) => {
|
|
|
213
223
|
|
|
214
224
|
const decomposedOriginalValue = createDecomposedValueTargetObject();
|
|
215
225
|
|
|
216
|
-
|
|
226
|
+
/**
|
|
227
|
+
* @param {Tween} tween
|
|
228
|
+
* @param {Number} progress
|
|
229
|
+
* @param {Number} precision
|
|
230
|
+
* @return {String}
|
|
231
|
+
*/
|
|
232
|
+
const composeColorValue = (tween, progress, precision) => {
|
|
233
|
+
const mod = tween._modifier;
|
|
234
|
+
const fn = tween._fromNumbers;
|
|
235
|
+
const tn = tween._toNumbers;
|
|
236
|
+
const r = round(clamp(/** @type {Number} */(mod(lerp(fn[0], tn[0], progress))), 0, 255), 0);
|
|
237
|
+
const g = round(clamp(/** @type {Number} */(mod(lerp(fn[1], tn[1], progress))), 0, 255), 0);
|
|
238
|
+
const b = round(clamp(/** @type {Number} */(mod(lerp(fn[2], tn[2], progress))), 0, 255), 0);
|
|
239
|
+
const a = clamp(/** @type {Number} */(mod(round(lerp(fn[3], tn[3], progress), precision))), 0, 1);
|
|
240
|
+
if (tween._composition !== compositionTypes.none) {
|
|
241
|
+
const ns = tween._numbers;
|
|
242
|
+
ns[0] = r;
|
|
243
|
+
ns[1] = g;
|
|
244
|
+
ns[2] = b;
|
|
245
|
+
ns[3] = a;
|
|
246
|
+
}
|
|
247
|
+
return `rgba(${r},${g},${b},${a})`;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @param {Tween} tween
|
|
252
|
+
* @param {Number} progress
|
|
253
|
+
* @param {Number} precision
|
|
254
|
+
* @return {String}
|
|
255
|
+
*/
|
|
256
|
+
const composeComplexValue = (tween, progress, precision) => {
|
|
257
|
+
const mod = tween._modifier;
|
|
258
|
+
const fn = tween._fromNumbers;
|
|
259
|
+
const tn = tween._toNumbers;
|
|
260
|
+
const ts = tween._strings;
|
|
261
|
+
const hasComposition = tween._composition !== compositionTypes.none;
|
|
262
|
+
let v = ts[0];
|
|
263
|
+
for (let j = 0, l = tn.length; j < l; j++) {
|
|
264
|
+
const n = /** @type {Number} */(mod(round(lerp(fn[j], tn[j], progress), precision)));
|
|
265
|
+
const s = ts[j + 1];
|
|
266
|
+
v += `${s ? n + s : n}`;
|
|
267
|
+
if (hasComposition) {
|
|
268
|
+
tween._numbers[j] = n;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return v;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export { composeColorValue, composeComplexValue, createDecomposedValueTargetObject, decomposeRawValue, decomposeTweenValue, decomposedOriginalValue, getFunctionValue, getOriginalAnimatableValue, getRelativeValue, getTweenType, setValue };
|