animejs 4.3.4 → 4.3.5

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 (124) hide show
  1. package/dist/bundles/anime.esm.js +62 -52
  2. package/dist/bundles/anime.esm.min.js +2 -2
  3. package/dist/bundles/anime.umd.js +62 -52
  4. package/dist/bundles/anime.umd.min.js +2 -2
  5. package/dist/modules/animatable/animatable.cjs +1 -1
  6. package/dist/modules/animatable/animatable.js +1 -1
  7. package/dist/modules/animatable/index.cjs +1 -1
  8. package/dist/modules/animatable/index.js +1 -1
  9. package/dist/modules/animation/additive.cjs +1 -1
  10. package/dist/modules/animation/additive.js +1 -1
  11. package/dist/modules/animation/animation.cjs +1 -1
  12. package/dist/modules/animation/animation.js +1 -1
  13. package/dist/modules/animation/composition.cjs +1 -1
  14. package/dist/modules/animation/composition.js +1 -1
  15. package/dist/modules/animation/index.cjs +1 -1
  16. package/dist/modules/animation/index.js +1 -1
  17. package/dist/modules/core/clock.cjs +1 -1
  18. package/dist/modules/core/clock.js +1 -1
  19. package/dist/modules/core/colors.cjs +1 -1
  20. package/dist/modules/core/colors.js +1 -1
  21. package/dist/modules/core/consts.cjs +3 -1
  22. package/dist/modules/core/consts.d.ts +1 -0
  23. package/dist/modules/core/consts.js +3 -2
  24. package/dist/modules/core/globals.cjs +2 -2
  25. package/dist/modules/core/globals.js +2 -2
  26. package/dist/modules/core/helpers.cjs +5 -5
  27. package/dist/modules/core/helpers.js +6 -6
  28. package/dist/modules/core/render.cjs +1 -1
  29. package/dist/modules/core/render.js +1 -1
  30. package/dist/modules/core/styles.cjs +1 -1
  31. package/dist/modules/core/styles.js +1 -1
  32. package/dist/modules/core/targets.cjs +1 -1
  33. package/dist/modules/core/targets.js +1 -1
  34. package/dist/modules/core/transforms.cjs +1 -1
  35. package/dist/modules/core/transforms.js +1 -1
  36. package/dist/modules/core/units.cjs +1 -1
  37. package/dist/modules/core/units.js +1 -1
  38. package/dist/modules/core/values.cjs +1 -1
  39. package/dist/modules/core/values.js +1 -1
  40. package/dist/modules/draggable/draggable.cjs +1 -1
  41. package/dist/modules/draggable/draggable.js +1 -1
  42. package/dist/modules/draggable/index.cjs +1 -1
  43. package/dist/modules/draggable/index.js +1 -1
  44. package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
  45. package/dist/modules/easings/cubic-bezier/index.js +1 -1
  46. package/dist/modules/easings/eases/index.cjs +1 -1
  47. package/dist/modules/easings/eases/index.js +1 -1
  48. package/dist/modules/easings/eases/parser.cjs +1 -1
  49. package/dist/modules/easings/eases/parser.js +1 -1
  50. package/dist/modules/easings/index.cjs +1 -1
  51. package/dist/modules/easings/index.js +1 -1
  52. package/dist/modules/easings/irregular/index.cjs +1 -1
  53. package/dist/modules/easings/irregular/index.js +1 -1
  54. package/dist/modules/easings/linear/index.cjs +1 -1
  55. package/dist/modules/easings/linear/index.js +1 -1
  56. package/dist/modules/easings/none.cjs +1 -1
  57. package/dist/modules/easings/none.js +1 -1
  58. package/dist/modules/easings/spring/index.cjs +1 -1
  59. package/dist/modules/easings/spring/index.js +1 -1
  60. package/dist/modules/easings/steps/index.cjs +1 -1
  61. package/dist/modules/easings/steps/index.js +1 -1
  62. package/dist/modules/engine/engine.cjs +1 -1
  63. package/dist/modules/engine/engine.js +1 -1
  64. package/dist/modules/engine/index.cjs +1 -1
  65. package/dist/modules/engine/index.js +1 -1
  66. package/dist/modules/events/index.cjs +1 -1
  67. package/dist/modules/events/index.js +1 -1
  68. package/dist/modules/events/scroll.cjs +1 -1
  69. package/dist/modules/events/scroll.js +1 -1
  70. package/dist/modules/index.cjs +1 -1
  71. package/dist/modules/index.js +1 -1
  72. package/dist/modules/layout/index.cjs +1 -1
  73. package/dist/modules/layout/index.js +1 -1
  74. package/dist/modules/layout/layout.cjs +55 -46
  75. package/dist/modules/layout/layout.js +55 -46
  76. package/dist/modules/scope/index.cjs +1 -1
  77. package/dist/modules/scope/index.js +1 -1
  78. package/dist/modules/scope/scope.cjs +1 -1
  79. package/dist/modules/scope/scope.js +1 -1
  80. package/dist/modules/svg/drawable.cjs +1 -1
  81. package/dist/modules/svg/drawable.js +1 -1
  82. package/dist/modules/svg/helpers.cjs +1 -1
  83. package/dist/modules/svg/helpers.js +1 -1
  84. package/dist/modules/svg/index.cjs +1 -1
  85. package/dist/modules/svg/index.js +1 -1
  86. package/dist/modules/svg/morphto.cjs +1 -1
  87. package/dist/modules/svg/morphto.js +1 -1
  88. package/dist/modules/svg/motionpath.cjs +1 -1
  89. package/dist/modules/svg/motionpath.js +1 -1
  90. package/dist/modules/text/index.cjs +1 -1
  91. package/dist/modules/text/index.js +1 -1
  92. package/dist/modules/text/split.cjs +1 -1
  93. package/dist/modules/text/split.js +1 -1
  94. package/dist/modules/timeline/index.cjs +1 -1
  95. package/dist/modules/timeline/index.js +1 -1
  96. package/dist/modules/timeline/position.cjs +1 -1
  97. package/dist/modules/timeline/position.js +1 -1
  98. package/dist/modules/timeline/timeline.cjs +1 -1
  99. package/dist/modules/timeline/timeline.js +1 -1
  100. package/dist/modules/timer/index.cjs +1 -1
  101. package/dist/modules/timer/index.js +1 -1
  102. package/dist/modules/timer/timer.cjs +1 -1
  103. package/dist/modules/timer/timer.js +1 -1
  104. package/dist/modules/utils/chainable.cjs +1 -1
  105. package/dist/modules/utils/chainable.js +1 -1
  106. package/dist/modules/utils/index.cjs +1 -1
  107. package/dist/modules/utils/index.js +1 -1
  108. package/dist/modules/utils/number.cjs +1 -1
  109. package/dist/modules/utils/number.js +1 -1
  110. package/dist/modules/utils/random.cjs +1 -1
  111. package/dist/modules/utils/random.js +1 -1
  112. package/dist/modules/utils/stagger.cjs +1 -1
  113. package/dist/modules/utils/stagger.js +1 -1
  114. package/dist/modules/utils/target.cjs +1 -1
  115. package/dist/modules/utils/target.js +1 -1
  116. package/dist/modules/utils/time.cjs +1 -1
  117. package/dist/modules/utils/time.js +1 -1
  118. package/dist/modules/waapi/composition.cjs +2 -2
  119. package/dist/modules/waapi/composition.js +2 -2
  120. package/dist/modules/waapi/index.cjs +1 -1
  121. package/dist/modules/waapi/index.js +1 -1
  122. package/dist/modules/waapi/waapi.cjs +1 -1
  123. package/dist/modules/waapi/waapi.js +1 -1
  124. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - UMD bundle
3
- * @version v4.3.4
3
+ * @version v4.3.5
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -746,6 +746,7 @@
746
746
 
747
747
  // Regex
748
748
 
749
+ const validRgbHslRgx = /\)\s*[-.\d]/;
749
750
  const hexTestRgx = /(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i;
750
751
  const rgbExecRgx = /rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i;
751
752
  const rgbaExecRgx = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i;
@@ -809,7 +810,7 @@
809
810
 
810
811
  const devTools = isBrowser && win.AnimeJSDevTools;
811
812
 
812
- const globalVersions = { version: '4.3.4', engine: null };
813
+ const globalVersions = { version: '4.3.5', engine: null };
813
814
 
814
815
  if (isBrowser) {
815
816
  if (!win.AnimeJS) win.AnimeJS = [];
@@ -857,11 +858,11 @@
857
858
  /**@param {any} a @return {Boolean} */
858
859
  const isHex = a => hexTestRgx.test(a);
859
860
  /**@param {any} a @return {Boolean} */
860
- const isRgb = a => stringStartsWith(a, 'rgb') && a[a.length - 1] === ')';
861
+ const isRgb = a => stringStartsWith(a, 'rgb');
861
862
  /**@param {any} a @return {Boolean} */
862
- const isHsl = a => stringStartsWith(a, 'hsl') && a[a.length - 1] === ')';
863
- /**@param {any} a @return {Boolean} */
864
- const isCol = a => isHex(a) || isRgb(a) || isHsl(a);
863
+ const isHsl = a => stringStartsWith(a, 'hsl');
864
+ /**@param {any} a @return {Boolean} */ // Make sure boxShadow syntax like 'rgb(255, 0, 0) 0px 0px 6px 0px' is not a valid color type
865
+ const isCol = a => isHex(a) || ((isRgb(a) || isHsl(a)) && (a[a.length - 1] === ')' || !validRgbHslRgx.test(a)));
865
866
  /**@param {any} a @return {Boolean} */
866
867
  const isKey = a => !globals.defaults.hasOwnProperty(a);
867
868
 
@@ -3983,7 +3984,7 @@
3983
3984
  parent.animations.push(animation);
3984
3985
  removeWAAPIAnimation($el, property);
3985
3986
  addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
3986
- const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
3987
+ const handleRemove = () => removeWAAPIAnimation($el, property, parent);
3987
3988
  animation.oncancel = handleRemove;
3988
3989
  animation.onremove = handleRemove;
3989
3990
  if (!parent.persist) {
@@ -9084,7 +9085,7 @@
9084
9085
  // const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
9085
9086
 
9086
9087
  if (node.isTarget && (!node.measuredIsRemoved && oldStateNode.measuredIsVisible || node.measuredIsRemoved && node.measuredIsVisible)) {
9087
- if (!node.isInlined && (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none')) {
9088
+ if (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none') {
9088
9089
  node.hasTransform = true;
9089
9090
  transformed.push($el);
9090
9091
  }
@@ -9100,7 +9101,7 @@
9100
9101
  if (!node.isTarget) {
9101
9102
  swapping.push($el);
9102
9103
  if (node.sizeChanged && parent && parent.isTarget && parent.sizeChanged) {
9103
- if (!node.isInlined && swapAtProps.transform) {
9104
+ if (swapAtProps.transform) {
9104
9105
  node.hasTransform = true;
9105
9106
  transformed.push($el);
9106
9107
  }
@@ -9140,7 +9141,7 @@
9140
9141
 
9141
9142
  // muteNodeTransition(newNode);
9142
9143
 
9143
- // Don't animate dimensions and positions of inlined elements
9144
+ // Don't animate positions of inlined elements (to avoid text reflow)
9144
9145
  if (!newNode.isInlined) {
9145
9146
  // Display grid can mess with the absolute positioning, so set it to block during transition
9146
9147
  if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.setProperty('display', 'block', 'important');
@@ -9159,14 +9160,15 @@
9159
9160
  $el.style.left = '0px';
9160
9161
  $el.style.top = '0px';
9161
9162
  }
9162
- $el.style.width = `${oldNodeState.width}px`;
9163
- $el.style.height = `${oldNodeState.height}px`;
9164
- // Overrides user defined min and max to prevents width and height clamping
9165
- $el.style.minWidth = `auto`;
9166
- $el.style.minHeight = `auto`;
9167
- $el.style.maxWidth = `none`;
9168
- $el.style.maxHeight = `none`;
9169
9163
  }
9164
+ // Animate dimensions for all elements (including inlined)
9165
+ $el.style.width = `${oldNodeState.width}px`;
9166
+ $el.style.height = `${oldNodeState.height}px`;
9167
+ // Overrides user defined min and max to prevents width and height clamping
9168
+ $el.style.minWidth = `auto`;
9169
+ $el.style.minHeight = `auto`;
9170
+ $el.style.maxWidth = `none`;
9171
+ $el.style.maxHeight = `none`;
9170
9172
  }
9171
9173
 
9172
9174
  // Restore the scroll position if the oldState differs from the current state
@@ -9187,21 +9189,19 @@
9187
9189
  const animatedProps = {
9188
9190
  composition: 'none',
9189
9191
  };
9190
- if (!newNode.isInlined) {
9191
- if (oldNodeState.width !== newNodeState.width) {
9192
- animatedProps.width = [oldNodeState.width, newNodeState.width];
9193
- nodeHasChanged = true;
9194
- }
9195
- if (oldNodeState.height !== newNodeState.height) {
9196
- animatedProps.height = [oldNodeState.height, newNodeState.height];
9197
- nodeHasChanged = true;
9198
- }
9199
- // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
9200
- // Always animate translate
9201
- if (!newNode.hasTransform) {
9202
- animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9203
- nodeHasChanged = true;
9204
- }
9192
+ if (oldNodeState.width !== newNodeState.width) {
9193
+ animatedProps.width = [oldNodeState.width, newNodeState.width];
9194
+ nodeHasChanged = true;
9195
+ }
9196
+ if (oldNodeState.height !== newNodeState.height) {
9197
+ animatedProps.height = [oldNodeState.height, newNodeState.height];
9198
+ nodeHasChanged = true;
9199
+ }
9200
+ // If the node has transforms we handle the translate animation in waapi otherwise translate and other transforms can be out of sync
9201
+ // And we don't animate the position of inlined elements
9202
+ if (!newNode.hasTransform && !newNode.isInlined) {
9203
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9204
+ nodeHasChanged = true;
9205
9205
  }
9206
9206
  this.properties.forEach(prop => {
9207
9207
  const oldVal = oldNodeState[prop];
@@ -9223,15 +9223,16 @@
9223
9223
  for (let i = 0, l = swapping.length; i < l; i++) {
9224
9224
  const $el = swapping[i];
9225
9225
  const oldNode = oldState.getNode($el);
9226
+ const oldNodeProps = oldNode.properties;
9227
+ $el.style.width = `${oldNodeProps.width}px`;
9228
+ $el.style.height = `${oldNodeProps.height}px`;
9229
+ // Overrides user defined min and max to prevents width and height clamping
9230
+ $el.style.minWidth = `auto`;
9231
+ $el.style.minHeight = `auto`;
9232
+ $el.style.maxWidth = `none`;
9233
+ $el.style.maxHeight = `none`;
9234
+ // We don't animate the position of inlined elements
9226
9235
  if (!oldNode.isInlined) {
9227
- const oldNodeProps = oldNode.properties;
9228
- $el.style.width = `${oldNodeProps.width}px`;
9229
- $el.style.height = `${oldNodeProps.height}px`;
9230
- // Overrides user defined min and max to prevents width and height clamping
9231
- $el.style.minWidth = `auto`;
9232
- $el.style.minHeight = `auto`;
9233
- $el.style.maxWidth = `none`;
9234
- $el.style.maxHeight = `none`;
9235
9236
  $el.style.translate = `${oldNodeProps.x}px ${oldNodeProps.y}px`;
9236
9237
  }
9237
9238
  this.properties.forEach(prop => {
@@ -9246,14 +9247,15 @@
9246
9247
  const newNode = newState.getNode($el);
9247
9248
  const newNodeProps = newNode.properties;
9248
9249
  this.timeline.call(() => {
9250
+ $el.style.width = `${newNodeProps.width}px`;
9251
+ $el.style.height = `${newNodeProps.height}px`;
9252
+ // Overrides user defined min and max to prevents width and height clamping
9253
+ $el.style.minWidth = `auto`;
9254
+ $el.style.minHeight = `auto`;
9255
+ $el.style.maxWidth = `none`;
9256
+ $el.style.maxHeight = `none`;
9257
+ // Don't set translate for inlined elements (to avoid text reflow)
9249
9258
  if (!newNode.isInlined) {
9250
- $el.style.width = `${newNodeProps.width}px`;
9251
- $el.style.height = `${newNodeProps.height}px`;
9252
- // Overrides user defined min and max to prevents width and height clamping
9253
- $el.style.minWidth = `auto`;
9254
- $el.style.minHeight = `auto`;
9255
- $el.style.maxWidth = `none`;
9256
- $el.style.maxHeight = `none`;
9257
9259
  $el.style.translate = `${newNodeProps.x}px ${newNodeProps.y}px`;
9258
9260
  }
9259
9261
  this.properties.forEach(prop => {
@@ -9286,19 +9288,27 @@
9286
9288
  const transformedLength = transformed.length;
9287
9289
 
9288
9290
  if (transformedLength) {
9289
- // We only need to set the transform property here since translate is alread defined in the targets loop
9291
+ // We only need to set the transform property here since translate is already defined in the targets loop
9290
9292
  for (let i = 0; i < transformedLength; i++) {
9291
9293
  const $el = transformed[i];
9292
- $el.style.translate = `${oldState.getComputedValue($el, 'x')}px ${oldState.getComputedValue($el, 'y')}px`,
9294
+ const node = newState.getNode($el);
9295
+ // Don't set translate for inlined elements (to avoid text reflow)
9296
+ if (!node.isInlined) {
9297
+ $el.style.translate = `${oldState.getComputedValue($el, 'x')}px ${oldState.getComputedValue($el, 'y')}px`;
9298
+ }
9293
9299
  $el.style.transform = oldState.getComputedValue($el, 'transform');
9294
9300
  if (animatedSwap.includes($el)) {
9295
- const node = newState.getNode($el);
9296
9301
  node.ease = getFunctionValue(swapAtParams.ease, $el, node.index, node.total);
9297
9302
  node.duration = getFunctionValue(swapAtParams.duration, $el, node.index, node.total);
9298
9303
  }
9299
9304
  }
9300
9305
  this.transformAnimation = waapi.animate(transformed, {
9301
- translate: (/** @type {HTMLElement} */$el) => `${newState.getComputedValue($el, 'x')}px ${newState.getComputedValue($el, 'y')}px`,
9306
+ translate: (/** @type {HTMLElement} */$el) => {
9307
+ const node = newState.getNode($el);
9308
+ // Don't animate translate for inlined elements (to avoid text reflow)
9309
+ if (node.isInlined) return '0px 0px';
9310
+ return `${newState.getComputedValue($el, 'x')}px ${newState.getComputedValue($el, 'y')}px`;
9311
+ },
9302
9312
  transform: (/** @type {HTMLElement} */$el) => {
9303
9313
  const newValue = newState.getComputedValue($el, 'transform');
9304
9314
  if (!animatedSwap.includes($el)) return newValue;
@@ -9307,7 +9317,7 @@
9307
9317
  return [oldValue, getFunctionValue(swapAtProps.transform, $el, node.index, node.total), newValue]
9308
9318
  },
9309
9319
  autoplay: false,
9310
- persist: true,
9320
+ // persist: true,
9311
9321
  ...timingParams,
9312
9322
  });
9313
9323
  this.timeline.sync(this.transformAnimation, 0);