animejs 4.3.4 → 4.3.6

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.
Files changed (125) hide show
  1. package/README.md +1 -1
  2. package/dist/bundles/anime.esm.js +77 -52
  3. package/dist/bundles/anime.esm.min.js +2 -2
  4. package/dist/bundles/anime.umd.js +77 -52
  5. package/dist/bundles/anime.umd.min.js +2 -2
  6. package/dist/modules/animatable/animatable.cjs +1 -1
  7. package/dist/modules/animatable/animatable.js +1 -1
  8. package/dist/modules/animatable/index.cjs +1 -1
  9. package/dist/modules/animatable/index.js +1 -1
  10. package/dist/modules/animation/additive.cjs +1 -1
  11. package/dist/modules/animation/additive.js +1 -1
  12. package/dist/modules/animation/animation.cjs +1 -1
  13. package/dist/modules/animation/animation.js +1 -1
  14. package/dist/modules/animation/composition.cjs +1 -1
  15. package/dist/modules/animation/composition.js +1 -1
  16. package/dist/modules/animation/index.cjs +1 -1
  17. package/dist/modules/animation/index.js +1 -1
  18. package/dist/modules/core/clock.cjs +1 -1
  19. package/dist/modules/core/clock.js +1 -1
  20. package/dist/modules/core/colors.cjs +1 -1
  21. package/dist/modules/core/colors.js +1 -1
  22. package/dist/modules/core/consts.cjs +3 -1
  23. package/dist/modules/core/consts.d.ts +1 -0
  24. package/dist/modules/core/consts.js +3 -2
  25. package/dist/modules/core/globals.cjs +2 -2
  26. package/dist/modules/core/globals.js +2 -2
  27. package/dist/modules/core/helpers.cjs +5 -5
  28. package/dist/modules/core/helpers.js +6 -6
  29. package/dist/modules/core/render.cjs +1 -1
  30. package/dist/modules/core/render.js +1 -1
  31. package/dist/modules/core/styles.cjs +1 -1
  32. package/dist/modules/core/styles.js +1 -1
  33. package/dist/modules/core/targets.cjs +1 -1
  34. package/dist/modules/core/targets.js +1 -1
  35. package/dist/modules/core/transforms.cjs +1 -1
  36. package/dist/modules/core/transforms.js +1 -1
  37. package/dist/modules/core/units.cjs +1 -1
  38. package/dist/modules/core/units.js +1 -1
  39. package/dist/modules/core/values.cjs +1 -1
  40. package/dist/modules/core/values.js +1 -1
  41. package/dist/modules/draggable/draggable.cjs +1 -1
  42. package/dist/modules/draggable/draggable.js +1 -1
  43. package/dist/modules/draggable/index.cjs +1 -1
  44. package/dist/modules/draggable/index.js +1 -1
  45. package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
  46. package/dist/modules/easings/cubic-bezier/index.js +1 -1
  47. package/dist/modules/easings/eases/index.cjs +1 -1
  48. package/dist/modules/easings/eases/index.js +1 -1
  49. package/dist/modules/easings/eases/parser.cjs +1 -1
  50. package/dist/modules/easings/eases/parser.js +1 -1
  51. package/dist/modules/easings/index.cjs +1 -1
  52. package/dist/modules/easings/index.js +1 -1
  53. package/dist/modules/easings/irregular/index.cjs +1 -1
  54. package/dist/modules/easings/irregular/index.js +1 -1
  55. package/dist/modules/easings/linear/index.cjs +1 -1
  56. package/dist/modules/easings/linear/index.js +1 -1
  57. package/dist/modules/easings/none.cjs +1 -1
  58. package/dist/modules/easings/none.js +1 -1
  59. package/dist/modules/easings/spring/index.cjs +1 -1
  60. package/dist/modules/easings/spring/index.js +1 -1
  61. package/dist/modules/easings/steps/index.cjs +1 -1
  62. package/dist/modules/easings/steps/index.js +1 -1
  63. package/dist/modules/engine/engine.cjs +1 -1
  64. package/dist/modules/engine/engine.js +1 -1
  65. package/dist/modules/engine/index.cjs +1 -1
  66. package/dist/modules/engine/index.js +1 -1
  67. package/dist/modules/events/index.cjs +1 -1
  68. package/dist/modules/events/index.js +1 -1
  69. package/dist/modules/events/scroll.cjs +1 -1
  70. package/dist/modules/events/scroll.js +1 -1
  71. package/dist/modules/index.cjs +1 -1
  72. package/dist/modules/index.js +1 -1
  73. package/dist/modules/layout/index.cjs +1 -1
  74. package/dist/modules/layout/index.js +1 -1
  75. package/dist/modules/layout/layout.cjs +74 -46
  76. package/dist/modules/layout/layout.js +74 -46
  77. package/dist/modules/scope/index.cjs +1 -1
  78. package/dist/modules/scope/index.js +1 -1
  79. package/dist/modules/scope/scope.cjs +1 -1
  80. package/dist/modules/scope/scope.js +1 -1
  81. package/dist/modules/svg/drawable.cjs +1 -1
  82. package/dist/modules/svg/drawable.js +1 -1
  83. package/dist/modules/svg/helpers.cjs +1 -1
  84. package/dist/modules/svg/helpers.js +1 -1
  85. package/dist/modules/svg/index.cjs +1 -1
  86. package/dist/modules/svg/index.js +1 -1
  87. package/dist/modules/svg/morphto.cjs +1 -1
  88. package/dist/modules/svg/morphto.js +1 -1
  89. package/dist/modules/svg/motionpath.cjs +1 -1
  90. package/dist/modules/svg/motionpath.js +1 -1
  91. package/dist/modules/text/index.cjs +1 -1
  92. package/dist/modules/text/index.js +1 -1
  93. package/dist/modules/text/split.cjs +1 -1
  94. package/dist/modules/text/split.js +1 -1
  95. package/dist/modules/timeline/index.cjs +1 -1
  96. package/dist/modules/timeline/index.js +1 -1
  97. package/dist/modules/timeline/position.cjs +1 -1
  98. package/dist/modules/timeline/position.js +1 -1
  99. package/dist/modules/timeline/timeline.cjs +1 -1
  100. package/dist/modules/timeline/timeline.js +1 -1
  101. package/dist/modules/timer/index.cjs +1 -1
  102. package/dist/modules/timer/index.js +1 -1
  103. package/dist/modules/timer/timer.cjs +1 -1
  104. package/dist/modules/timer/timer.js +1 -1
  105. package/dist/modules/utils/chainable.cjs +1 -1
  106. package/dist/modules/utils/chainable.js +1 -1
  107. package/dist/modules/utils/index.cjs +1 -1
  108. package/dist/modules/utils/index.js +1 -1
  109. package/dist/modules/utils/number.cjs +1 -1
  110. package/dist/modules/utils/number.js +1 -1
  111. package/dist/modules/utils/random.cjs +1 -1
  112. package/dist/modules/utils/random.js +1 -1
  113. package/dist/modules/utils/stagger.cjs +1 -1
  114. package/dist/modules/utils/stagger.js +1 -1
  115. package/dist/modules/utils/target.cjs +1 -1
  116. package/dist/modules/utils/target.js +1 -1
  117. package/dist/modules/utils/time.cjs +1 -1
  118. package/dist/modules/utils/time.js +1 -1
  119. package/dist/modules/waapi/composition.cjs +2 -2
  120. package/dist/modules/waapi/composition.js +2 -2
  121. package/dist/modules/waapi/index.cjs +1 -1
  122. package/dist/modules/waapi/index.js +1 -1
  123. package/dist/modules/waapi/waapi.cjs +1 -1
  124. package/dist/modules/waapi/waapi.js +1 -1
  125. package/package.json +1 -1
package/README.md CHANGED
@@ -64,7 +64,7 @@ Help the project become sustainable by sponsoring us on <a target="_blank" href=
64
64
  <tbody>
65
65
  <tr>
66
66
  <td>
67
- <a target="_blank" href="https://www.testmu.ai?utm_source=animeJS&utm_medium=organic&utm_campaign=july_08&utm_term=sk&utm_content=opensource">
67
+ <a target="_blank" href="https://www.testmuai.com/?utm_medium=sponsor&utm_source=animejs">
68
68
  <picture>
69
69
  <source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/testmu-ai-logomark.png?v=200126">
70
70
  <img align="center" src="./assets/sponsors/testmu-ai-logomark-dark.png?v=200126" width="141">
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - ESM bundle
3
- * @version v4.3.4
3
+ * @version v4.3.6
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -740,6 +740,7 @@ const noop = () => {};
740
740
 
741
741
  // Regex
742
742
 
743
+ const validRgbHslRgx = /\)\s*[-.\d]/;
743
744
  const hexTestRgx = /(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i;
744
745
  const rgbExecRgx = /rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i;
745
746
  const rgbaExecRgx = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i;
@@ -803,7 +804,7 @@ const globals = {
803
804
 
804
805
  const devTools = isBrowser && win.AnimeJSDevTools;
805
806
 
806
- const globalVersions = { version: '4.3.4', engine: null };
807
+ const globalVersions = { version: '4.3.6', engine: null };
807
808
 
808
809
  if (isBrowser) {
809
810
  if (!win.AnimeJS) win.AnimeJS = [];
@@ -851,11 +852,11 @@ const isSvg = a => isBrowser && a instanceof SVGElement;
851
852
  /**@param {any} a @return {Boolean} */
852
853
  const isHex = a => hexTestRgx.test(a);
853
854
  /**@param {any} a @return {Boolean} */
854
- const isRgb = a => stringStartsWith(a, 'rgb') && a[a.length - 1] === ')';
855
+ const isRgb = a => stringStartsWith(a, 'rgb');
855
856
  /**@param {any} a @return {Boolean} */
856
- const isHsl = a => stringStartsWith(a, 'hsl') && a[a.length - 1] === ')';
857
- /**@param {any} a @return {Boolean} */
858
- const isCol = a => isHex(a) || isRgb(a) || isHsl(a);
857
+ const isHsl = a => stringStartsWith(a, 'hsl');
858
+ /**@param {any} a @return {Boolean} */ // Make sure boxShadow syntax like 'rgb(255, 0, 0) 0px 0px 6px 0px' is not a valid color type
859
+ const isCol = a => isHex(a) || ((isRgb(a) || isHsl(a)) && (a[a.length - 1] === ')' || !validRgbHslRgx.test(a)));
859
860
  /**@param {any} a @return {Boolean} */
860
861
  const isKey = a => !globals.defaults.hasOwnProperty(a);
861
862
 
@@ -3977,7 +3978,7 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
3977
3978
  parent.animations.push(animation);
3978
3979
  removeWAAPIAnimation($el, property);
3979
3980
  addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
3980
- const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
3981
+ const handleRemove = () => removeWAAPIAnimation($el, property, parent);
3981
3982
  animation.oncancel = handleRemove;
3982
3983
  animation.onremove = handleRemove;
3983
3984
  if (!parent.persist) {
@@ -7821,6 +7822,8 @@ const waapi = {
7821
7822
 
7822
7823
 
7823
7824
 
7825
+
7826
+
7824
7827
  /**
7825
7828
  * @typedef {DOMTargetSelector|Array<DOMTargetSelector>} LayoutChildrenParam
7826
7829
  */
@@ -8844,6 +8847,12 @@ class AutoLayout {
8844
8847
  }
8845
8848
  }
8846
8849
  tlParams.onComplete = () => {
8850
+ const ap = /** @type {ScrollObserver} */(params.autoplay);
8851
+ const isScrollControled = ap && ap.linked;
8852
+ if (isScrollControled) {
8853
+ if (onComplete) onComplete(this.timeline);
8854
+ return;
8855
+ }
8847
8856
  // Make sure to call .cancel() after restoreNodeInlineStyles(node); otehrwise the commited styles get reverted
8848
8857
  if (this.transformAnimation) this.transformAnimation.cancel();
8849
8858
  newState.forEachRootNode(node => {
@@ -8865,6 +8874,13 @@ class AutoLayout {
8865
8874
  });
8866
8875
  };
8867
8876
  tlParams.onPause = () => {
8877
+ const ap = /** @type {ScrollObserver} */(params.autoplay);
8878
+ const isScrollControled = ap && ap.linked;
8879
+ if (isScrollControled) {
8880
+ if (onComplete) onComplete(this.timeline);
8881
+ if (onPause) onPause(this.timeline);
8882
+ return;
8883
+ }
8868
8884
  if (!this.root.classList.contains('is-animated')) return;
8869
8885
  if (this.transformAnimation) this.transformAnimation.cancel();
8870
8886
  newState.forEachRootNode(restoreNodeVisualState);
@@ -9078,7 +9094,7 @@ class AutoLayout {
9078
9094
  // const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
9079
9095
 
9080
9096
  if (node.isTarget && (!node.measuredIsRemoved && oldStateNode.measuredIsVisible || node.measuredIsRemoved && node.measuredIsVisible)) {
9081
- if (!node.isInlined && (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none')) {
9097
+ if (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none') {
9082
9098
  node.hasTransform = true;
9083
9099
  transformed.push($el);
9084
9100
  }
@@ -9094,7 +9110,7 @@ class AutoLayout {
9094
9110
  if (!node.isTarget) {
9095
9111
  swapping.push($el);
9096
9112
  if (node.sizeChanged && parent && parent.isTarget && parent.sizeChanged) {
9097
- if (!node.isInlined && swapAtProps.transform) {
9113
+ if (swapAtProps.transform) {
9098
9114
  node.hasTransform = true;
9099
9115
  transformed.push($el);
9100
9116
  }
@@ -9134,7 +9150,7 @@ class AutoLayout {
9134
9150
 
9135
9151
  // muteNodeTransition(newNode);
9136
9152
 
9137
- // Don't animate dimensions and positions of inlined elements
9153
+ // Don't animate positions of inlined elements (to avoid text reflow)
9138
9154
  if (!newNode.isInlined) {
9139
9155
  // Display grid can mess with the absolute positioning, so set it to block during transition
9140
9156
  if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.setProperty('display', 'block', 'important');
@@ -9153,14 +9169,15 @@ class AutoLayout {
9153
9169
  $el.style.left = '0px';
9154
9170
  $el.style.top = '0px';
9155
9171
  }
9156
- $el.style.width = `${oldNodeState.width}px`;
9157
- $el.style.height = `${oldNodeState.height}px`;
9158
- // Overrides user defined min and max to prevents width and height clamping
9159
- $el.style.minWidth = `auto`;
9160
- $el.style.minHeight = `auto`;
9161
- $el.style.maxWidth = `none`;
9162
- $el.style.maxHeight = `none`;
9163
9172
  }
9173
+ // Animate dimensions for all elements (including inlined)
9174
+ $el.style.width = `${oldNodeState.width}px`;
9175
+ $el.style.height = `${oldNodeState.height}px`;
9176
+ // Overrides user defined min and max to prevents width and height clamping
9177
+ $el.style.minWidth = `auto`;
9178
+ $el.style.minHeight = `auto`;
9179
+ $el.style.maxWidth = `none`;
9180
+ $el.style.maxHeight = `none`;
9164
9181
  }
9165
9182
 
9166
9183
  // Restore the scroll position if the oldState differs from the current state
@@ -9181,21 +9198,19 @@ class AutoLayout {
9181
9198
  const animatedProps = {
9182
9199
  composition: 'none',
9183
9200
  };
9184
- if (!newNode.isInlined) {
9185
- if (oldNodeState.width !== newNodeState.width) {
9186
- animatedProps.width = [oldNodeState.width, newNodeState.width];
9187
- nodeHasChanged = true;
9188
- }
9189
- if (oldNodeState.height !== newNodeState.height) {
9190
- animatedProps.height = [oldNodeState.height, newNodeState.height];
9191
- nodeHasChanged = true;
9192
- }
9193
- // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
9194
- // Always animate translate
9195
- if (!newNode.hasTransform) {
9196
- animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9197
- nodeHasChanged = true;
9198
- }
9201
+ if (oldNodeState.width !== newNodeState.width) {
9202
+ animatedProps.width = [oldNodeState.width, newNodeState.width];
9203
+ nodeHasChanged = true;
9204
+ }
9205
+ if (oldNodeState.height !== newNodeState.height) {
9206
+ animatedProps.height = [oldNodeState.height, newNodeState.height];
9207
+ nodeHasChanged = true;
9208
+ }
9209
+ // If the node has transforms we handle the translate animation in waapi otherwise translate and other transforms can be out of sync
9210
+ // And we don't animate the position of inlined elements
9211
+ if (!newNode.hasTransform && !newNode.isInlined) {
9212
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9213
+ nodeHasChanged = true;
9199
9214
  }
9200
9215
  this.properties.forEach(prop => {
9201
9216
  const oldVal = oldNodeState[prop];
@@ -9217,15 +9232,16 @@ class AutoLayout {
9217
9232
  for (let i = 0, l = swapping.length; i < l; i++) {
9218
9233
  const $el = swapping[i];
9219
9234
  const oldNode = oldState.getNode($el);
9235
+ const oldNodeProps = oldNode.properties;
9236
+ $el.style.width = `${oldNodeProps.width}px`;
9237
+ $el.style.height = `${oldNodeProps.height}px`;
9238
+ // Overrides user defined min and max to prevents width and height clamping
9239
+ $el.style.minWidth = `auto`;
9240
+ $el.style.minHeight = `auto`;
9241
+ $el.style.maxWidth = `none`;
9242
+ $el.style.maxHeight = `none`;
9243
+ // We don't animate the position of inlined elements
9220
9244
  if (!oldNode.isInlined) {
9221
- const oldNodeProps = oldNode.properties;
9222
- $el.style.width = `${oldNodeProps.width}px`;
9223
- $el.style.height = `${oldNodeProps.height}px`;
9224
- // Overrides user defined min and max to prevents width and height clamping
9225
- $el.style.minWidth = `auto`;
9226
- $el.style.minHeight = `auto`;
9227
- $el.style.maxWidth = `none`;
9228
- $el.style.maxHeight = `none`;
9229
9245
  $el.style.translate = `${oldNodeProps.x}px ${oldNodeProps.y}px`;
9230
9246
  }
9231
9247
  this.properties.forEach(prop => {
@@ -9240,14 +9256,15 @@ class AutoLayout {
9240
9256
  const newNode = newState.getNode($el);
9241
9257
  const newNodeProps = newNode.properties;
9242
9258
  this.timeline.call(() => {
9259
+ $el.style.width = `${newNodeProps.width}px`;
9260
+ $el.style.height = `${newNodeProps.height}px`;
9261
+ // Overrides user defined min and max to prevents width and height clamping
9262
+ $el.style.minWidth = `auto`;
9263
+ $el.style.minHeight = `auto`;
9264
+ $el.style.maxWidth = `none`;
9265
+ $el.style.maxHeight = `none`;
9266
+ // Don't set translate for inlined elements (to avoid text reflow)
9243
9267
  if (!newNode.isInlined) {
9244
- $el.style.width = `${newNodeProps.width}px`;
9245
- $el.style.height = `${newNodeProps.height}px`;
9246
- // Overrides user defined min and max to prevents width and height clamping
9247
- $el.style.minWidth = `auto`;
9248
- $el.style.minHeight = `auto`;
9249
- $el.style.maxWidth = `none`;
9250
- $el.style.maxHeight = `none`;
9251
9268
  $el.style.translate = `${newNodeProps.x}px ${newNodeProps.y}px`;
9252
9269
  }
9253
9270
  this.properties.forEach(prop => {
@@ -9280,19 +9297,27 @@ class AutoLayout {
9280
9297
  const transformedLength = transformed.length;
9281
9298
 
9282
9299
  if (transformedLength) {
9283
- // We only need to set the transform property here since translate is alread defined in the targets loop
9300
+ // We only need to set the transform property here since translate is already defined in the targets loop
9284
9301
  for (let i = 0; i < transformedLength; i++) {
9285
9302
  const $el = transformed[i];
9286
- $el.style.translate = `${oldState.getComputedValue($el, 'x')}px ${oldState.getComputedValue($el, 'y')}px`,
9303
+ const node = newState.getNode($el);
9304
+ // Don't set translate for inlined elements (to avoid text reflow)
9305
+ if (!node.isInlined) {
9306
+ $el.style.translate = `${oldState.getComputedValue($el, 'x')}px ${oldState.getComputedValue($el, 'y')}px`;
9307
+ }
9287
9308
  $el.style.transform = oldState.getComputedValue($el, 'transform');
9288
9309
  if (animatedSwap.includes($el)) {
9289
- const node = newState.getNode($el);
9290
9310
  node.ease = getFunctionValue(swapAtParams.ease, $el, node.index, node.total);
9291
9311
  node.duration = getFunctionValue(swapAtParams.duration, $el, node.index, node.total);
9292
9312
  }
9293
9313
  }
9294
9314
  this.transformAnimation = waapi.animate(transformed, {
9295
- translate: (/** @type {HTMLElement} */$el) => `${newState.getComputedValue($el, 'x')}px ${newState.getComputedValue($el, 'y')}px`,
9315
+ translate: (/** @type {HTMLElement} */$el) => {
9316
+ const node = newState.getNode($el);
9317
+ // Don't animate translate for inlined elements (to avoid text reflow)
9318
+ if (node.isInlined) return '0px 0px';
9319
+ return `${newState.getComputedValue($el, 'x')}px ${newState.getComputedValue($el, 'y')}px`;
9320
+ },
9296
9321
  transform: (/** @type {HTMLElement} */$el) => {
9297
9322
  const newValue = newState.getComputedValue($el, 'transform');
9298
9323
  if (!animatedSwap.includes($el)) return newValue;
@@ -9301,7 +9326,7 @@ class AutoLayout {
9301
9326
  return [oldValue, getFunctionValue(swapAtProps.transform, $el, node.index, node.total), newValue]
9302
9327
  },
9303
9328
  autoplay: false,
9304
- persist: true,
9329
+ // persist: true,
9305
9330
  ...timingParams,
9306
9331
  });
9307
9332
  this.timeline.sync(this.transformAnimation, 0);