animejs 4.3.3 → 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 +73 -58
  2. package/dist/bundles/anime.esm.min.js +2 -2
  3. package/dist/bundles/anime.umd.js +73 -58
  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 +5 -4
  69. package/dist/modules/events/scroll.js +5 -4
  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 +8 -4
  99. package/dist/modules/timeline/timeline.js +8 -4
  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.3
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.3', 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) {
@@ -4313,6 +4314,10 @@
4313
4314
  if (isUnd(synced) || synced && isUnd(synced.pause)) return this;
4314
4315
  synced.pause();
4315
4316
  const duration = +(/** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */(synced).effect.getTiming().duration : /** @type {Tickable} */(synced).duration);
4317
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
4318
+ if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
4319
+ /** @type {WAAPIAnimation} */(synced).persist = true;
4320
+ }
4316
4321
  return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
4317
4322
  }
4318
4323
 
@@ -4379,8 +4384,8 @@
4379
4384
  * @return {this}
4380
4385
  */
4381
4386
  refresh() {
4382
- forEachChildren(this, (/** @type {JSAnimation} */child) => {
4383
- if (child.refresh) child.refresh();
4387
+ forEachChildren(this, (/** @type {JSAnimation|Timer} */child) => {
4388
+ if (/** @type {JSAnimation} */(child).refresh) /** @type {JSAnimation} */(child).refresh();
4384
4389
  });
4385
4390
  return this;
4386
4391
  }
@@ -4390,7 +4395,7 @@
4390
4395
  */
4391
4396
  revert() {
4392
4397
  super.revert();
4393
- forEachChildren(this, (/** @type {JSAnimation} */child) => child.revert, true);
4398
+ forEachChildren(this, (/** @type {JSAnimation|Timer} */child) => child.revert, true);
4394
4399
  return cleanInlineStyles(this);
4395
4400
  }
4396
4401
 
@@ -6764,7 +6769,9 @@
6764
6769
  linked.pause();
6765
6770
  this.linked = linked;
6766
6771
  // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
6767
- if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
6772
+ if (!isUnd(linked) && !isUnd(/** @type {WAAPIAnimation} */(linked).persist)) {
6773
+ /** @type {WAAPIAnimation} */(linked).persist = true;
6774
+ }
6768
6775
  // Try to use a target of the linked object if no target parameters specified
6769
6776
  if (!this._params.target) {
6770
6777
  /** @type {HTMLElement} */
@@ -6966,12 +6973,11 @@
6966
6973
  // let offsetX = 0;
6967
6974
  // let offsetY = 0;
6968
6975
  // let $offsetParent = $el;
6969
- /** @type {Element} */
6970
6976
  if (linked) {
6971
6977
  linkedTime = linked.currentTime;
6972
6978
  linked.seek(0, true);
6973
6979
  }
6974
- /* Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
6980
+ // Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
6975
6981
  // const isContainerStatic = get(container.element, 'position') === 'static' ? set(container.element, { position: 'relative '}) : false;
6976
6982
  // while ($el && $el !== container.element && $el !== doc.body) {
6977
6983
  // const isSticky = get($el, 'position') === 'sticky' ?
@@ -9079,7 +9085,7 @@
9079
9085
  // const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
9080
9086
 
9081
9087
  if (node.isTarget && (!node.measuredIsRemoved && oldStateNode.measuredIsVisible || node.measuredIsRemoved && node.measuredIsVisible)) {
9082
- if (!node.isInlined && (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none')) {
9088
+ if (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none') {
9083
9089
  node.hasTransform = true;
9084
9090
  transformed.push($el);
9085
9091
  }
@@ -9095,7 +9101,7 @@
9095
9101
  if (!node.isTarget) {
9096
9102
  swapping.push($el);
9097
9103
  if (node.sizeChanged && parent && parent.isTarget && parent.sizeChanged) {
9098
- if (!node.isInlined && swapAtProps.transform) {
9104
+ if (swapAtProps.transform) {
9099
9105
  node.hasTransform = true;
9100
9106
  transformed.push($el);
9101
9107
  }
@@ -9135,7 +9141,7 @@
9135
9141
 
9136
9142
  // muteNodeTransition(newNode);
9137
9143
 
9138
- // Don't animate dimensions and positions of inlined elements
9144
+ // Don't animate positions of inlined elements (to avoid text reflow)
9139
9145
  if (!newNode.isInlined) {
9140
9146
  // Display grid can mess with the absolute positioning, so set it to block during transition
9141
9147
  if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.setProperty('display', 'block', 'important');
@@ -9154,14 +9160,15 @@
9154
9160
  $el.style.left = '0px';
9155
9161
  $el.style.top = '0px';
9156
9162
  }
9157
- $el.style.width = `${oldNodeState.width}px`;
9158
- $el.style.height = `${oldNodeState.height}px`;
9159
- // Overrides user defined min and max to prevents width and height clamping
9160
- $el.style.minWidth = `auto`;
9161
- $el.style.minHeight = `auto`;
9162
- $el.style.maxWidth = `none`;
9163
- $el.style.maxHeight = `none`;
9164
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`;
9165
9172
  }
9166
9173
 
9167
9174
  // Restore the scroll position if the oldState differs from the current state
@@ -9182,21 +9189,19 @@
9182
9189
  const animatedProps = {
9183
9190
  composition: 'none',
9184
9191
  };
9185
- if (!newNode.isInlined) {
9186
- if (oldNodeState.width !== newNodeState.width) {
9187
- animatedProps.width = [oldNodeState.width, newNodeState.width];
9188
- nodeHasChanged = true;
9189
- }
9190
- if (oldNodeState.height !== newNodeState.height) {
9191
- animatedProps.height = [oldNodeState.height, newNodeState.height];
9192
- nodeHasChanged = true;
9193
- }
9194
- // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
9195
- // Always animate translate
9196
- if (!newNode.hasTransform) {
9197
- animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9198
- nodeHasChanged = true;
9199
- }
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;
9200
9205
  }
9201
9206
  this.properties.forEach(prop => {
9202
9207
  const oldVal = oldNodeState[prop];
@@ -9218,15 +9223,16 @@
9218
9223
  for (let i = 0, l = swapping.length; i < l; i++) {
9219
9224
  const $el = swapping[i];
9220
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
9221
9235
  if (!oldNode.isInlined) {
9222
- const oldNodeProps = oldNode.properties;
9223
- $el.style.width = `${oldNodeProps.width}px`;
9224
- $el.style.height = `${oldNodeProps.height}px`;
9225
- // Overrides user defined min and max to prevents width and height clamping
9226
- $el.style.minWidth = `auto`;
9227
- $el.style.minHeight = `auto`;
9228
- $el.style.maxWidth = `none`;
9229
- $el.style.maxHeight = `none`;
9230
9236
  $el.style.translate = `${oldNodeProps.x}px ${oldNodeProps.y}px`;
9231
9237
  }
9232
9238
  this.properties.forEach(prop => {
@@ -9241,14 +9247,15 @@
9241
9247
  const newNode = newState.getNode($el);
9242
9248
  const newNodeProps = newNode.properties;
9243
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)
9244
9258
  if (!newNode.isInlined) {
9245
- $el.style.width = `${newNodeProps.width}px`;
9246
- $el.style.height = `${newNodeProps.height}px`;
9247
- // Overrides user defined min and max to prevents width and height clamping
9248
- $el.style.minWidth = `auto`;
9249
- $el.style.minHeight = `auto`;
9250
- $el.style.maxWidth = `none`;
9251
- $el.style.maxHeight = `none`;
9252
9259
  $el.style.translate = `${newNodeProps.x}px ${newNodeProps.y}px`;
9253
9260
  }
9254
9261
  this.properties.forEach(prop => {
@@ -9281,19 +9288,27 @@
9281
9288
  const transformedLength = transformed.length;
9282
9289
 
9283
9290
  if (transformedLength) {
9284
- // 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
9285
9292
  for (let i = 0; i < transformedLength; i++) {
9286
9293
  const $el = transformed[i];
9287
- $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
+ }
9288
9299
  $el.style.transform = oldState.getComputedValue($el, 'transform');
9289
9300
  if (animatedSwap.includes($el)) {
9290
- const node = newState.getNode($el);
9291
9301
  node.ease = getFunctionValue(swapAtParams.ease, $el, node.index, node.total);
9292
9302
  node.duration = getFunctionValue(swapAtParams.duration, $el, node.index, node.total);
9293
9303
  }
9294
9304
  }
9295
9305
  this.transformAnimation = waapi.animate(transformed, {
9296
- 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
+ },
9297
9312
  transform: (/** @type {HTMLElement} */$el) => {
9298
9313
  const newValue = newState.getComputedValue($el, 'transform');
9299
9314
  if (!animatedSwap.includes($el)) return newValue;
@@ -9302,7 +9317,7 @@
9302
9317
  return [oldValue, getFunctionValue(swapAtProps.transform, $el, node.index, node.total), newValue]
9303
9318
  },
9304
9319
  autoplay: false,
9305
- persist: true,
9320
+ // persist: true,
9306
9321
  ...timingParams,
9307
9322
  });
9308
9323
  this.timeline.sync(this.transformAnimation, 0);