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 - ESM bundle
3
- * @version v4.3.3
3
+ * @version v4.3.5
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.3', engine: null };
807
+ const globalVersions = { version: '4.3.5', 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) {
@@ -4307,6 +4308,10 @@ class Timeline extends Timer {
4307
4308
  if (isUnd(synced) || synced && isUnd(synced.pause)) return this;
4308
4309
  synced.pause();
4309
4310
  const duration = +(/** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */(synced).effect.getTiming().duration : /** @type {Tickable} */(synced).duration);
4311
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
4312
+ if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
4313
+ /** @type {WAAPIAnimation} */(synced).persist = true;
4314
+ }
4310
4315
  return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
4311
4316
  }
4312
4317
 
@@ -4373,8 +4378,8 @@ class Timeline extends Timer {
4373
4378
  * @return {this}
4374
4379
  */
4375
4380
  refresh() {
4376
- forEachChildren(this, (/** @type {JSAnimation} */child) => {
4377
- if (child.refresh) child.refresh();
4381
+ forEachChildren(this, (/** @type {JSAnimation|Timer} */child) => {
4382
+ if (/** @type {JSAnimation} */(child).refresh) /** @type {JSAnimation} */(child).refresh();
4378
4383
  });
4379
4384
  return this;
4380
4385
  }
@@ -4384,7 +4389,7 @@ class Timeline extends Timer {
4384
4389
  */
4385
4390
  revert() {
4386
4391
  super.revert();
4387
- forEachChildren(this, (/** @type {JSAnimation} */child) => child.revert, true);
4392
+ forEachChildren(this, (/** @type {JSAnimation|Timer} */child) => child.revert, true);
4388
4393
  return cleanInlineStyles(this);
4389
4394
  }
4390
4395
 
@@ -6758,7 +6763,9 @@ class ScrollObserver {
6758
6763
  linked.pause();
6759
6764
  this.linked = linked;
6760
6765
  // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
6761
- if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
6766
+ if (!isUnd(linked) && !isUnd(/** @type {WAAPIAnimation} */(linked).persist)) {
6767
+ /** @type {WAAPIAnimation} */(linked).persist = true;
6768
+ }
6762
6769
  // Try to use a target of the linked object if no target parameters specified
6763
6770
  if (!this._params.target) {
6764
6771
  /** @type {HTMLElement} */
@@ -6960,12 +6967,11 @@ class ScrollObserver {
6960
6967
  // let offsetX = 0;
6961
6968
  // let offsetY = 0;
6962
6969
  // let $offsetParent = $el;
6963
- /** @type {Element} */
6964
6970
  if (linked) {
6965
6971
  linkedTime = linked.currentTime;
6966
6972
  linked.seek(0, true);
6967
6973
  }
6968
- /* Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
6974
+ // Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
6969
6975
  // const isContainerStatic = get(container.element, 'position') === 'static' ? set(container.element, { position: 'relative '}) : false;
6970
6976
  // while ($el && $el !== container.element && $el !== doc.body) {
6971
6977
  // const isSticky = get($el, 'position') === 'sticky' ?
@@ -9073,7 +9079,7 @@ class AutoLayout {
9073
9079
  // const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
9074
9080
 
9075
9081
  if (node.isTarget && (!node.measuredIsRemoved && oldStateNode.measuredIsVisible || node.measuredIsRemoved && node.measuredIsVisible)) {
9076
- if (!node.isInlined && (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none')) {
9082
+ if (nodeProperties.transform !== 'none' || oldStateNodeProperties.transform !== 'none') {
9077
9083
  node.hasTransform = true;
9078
9084
  transformed.push($el);
9079
9085
  }
@@ -9089,7 +9095,7 @@ class AutoLayout {
9089
9095
  if (!node.isTarget) {
9090
9096
  swapping.push($el);
9091
9097
  if (node.sizeChanged && parent && parent.isTarget && parent.sizeChanged) {
9092
- if (!node.isInlined && swapAtProps.transform) {
9098
+ if (swapAtProps.transform) {
9093
9099
  node.hasTransform = true;
9094
9100
  transformed.push($el);
9095
9101
  }
@@ -9129,7 +9135,7 @@ class AutoLayout {
9129
9135
 
9130
9136
  // muteNodeTransition(newNode);
9131
9137
 
9132
- // Don't animate dimensions and positions of inlined elements
9138
+ // Don't animate positions of inlined elements (to avoid text reflow)
9133
9139
  if (!newNode.isInlined) {
9134
9140
  // Display grid can mess with the absolute positioning, so set it to block during transition
9135
9141
  if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.setProperty('display', 'block', 'important');
@@ -9148,14 +9154,15 @@ class AutoLayout {
9148
9154
  $el.style.left = '0px';
9149
9155
  $el.style.top = '0px';
9150
9156
  }
9151
- $el.style.width = `${oldNodeState.width}px`;
9152
- $el.style.height = `${oldNodeState.height}px`;
9153
- // Overrides user defined min and max to prevents width and height clamping
9154
- $el.style.minWidth = `auto`;
9155
- $el.style.minHeight = `auto`;
9156
- $el.style.maxWidth = `none`;
9157
- $el.style.maxHeight = `none`;
9158
9157
  }
9158
+ // Animate dimensions for all elements (including inlined)
9159
+ $el.style.width = `${oldNodeState.width}px`;
9160
+ $el.style.height = `${oldNodeState.height}px`;
9161
+ // Overrides user defined min and max to prevents width and height clamping
9162
+ $el.style.minWidth = `auto`;
9163
+ $el.style.minHeight = `auto`;
9164
+ $el.style.maxWidth = `none`;
9165
+ $el.style.maxHeight = `none`;
9159
9166
  }
9160
9167
 
9161
9168
  // Restore the scroll position if the oldState differs from the current state
@@ -9176,21 +9183,19 @@ class AutoLayout {
9176
9183
  const animatedProps = {
9177
9184
  composition: 'none',
9178
9185
  };
9179
- if (!newNode.isInlined) {
9180
- if (oldNodeState.width !== newNodeState.width) {
9181
- animatedProps.width = [oldNodeState.width, newNodeState.width];
9182
- nodeHasChanged = true;
9183
- }
9184
- if (oldNodeState.height !== newNodeState.height) {
9185
- animatedProps.height = [oldNodeState.height, newNodeState.height];
9186
- nodeHasChanged = true;
9187
- }
9188
- // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
9189
- // Always animate translate
9190
- if (!newNode.hasTransform) {
9191
- animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9192
- nodeHasChanged = true;
9193
- }
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 waapi otherwise translate and other transforms can be out of sync
9195
+ // And we don't animate the position of inlined elements
9196
+ if (!newNode.hasTransform && !newNode.isInlined) {
9197
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
9198
+ nodeHasChanged = true;
9194
9199
  }
9195
9200
  this.properties.forEach(prop => {
9196
9201
  const oldVal = oldNodeState[prop];
@@ -9212,15 +9217,16 @@ class AutoLayout {
9212
9217
  for (let i = 0, l = swapping.length; i < l; i++) {
9213
9218
  const $el = swapping[i];
9214
9219
  const oldNode = oldState.getNode($el);
9220
+ const oldNodeProps = oldNode.properties;
9221
+ $el.style.width = `${oldNodeProps.width}px`;
9222
+ $el.style.height = `${oldNodeProps.height}px`;
9223
+ // Overrides user defined min and max to prevents width and height clamping
9224
+ $el.style.minWidth = `auto`;
9225
+ $el.style.minHeight = `auto`;
9226
+ $el.style.maxWidth = `none`;
9227
+ $el.style.maxHeight = `none`;
9228
+ // We don't animate the position of inlined elements
9215
9229
  if (!oldNode.isInlined) {
9216
- const oldNodeProps = oldNode.properties;
9217
- $el.style.width = `${oldNodeProps.width}px`;
9218
- $el.style.height = `${oldNodeProps.height}px`;
9219
- // Overrides user defined min and max to prevents width and height clamping
9220
- $el.style.minWidth = `auto`;
9221
- $el.style.minHeight = `auto`;
9222
- $el.style.maxWidth = `none`;
9223
- $el.style.maxHeight = `none`;
9224
9230
  $el.style.translate = `${oldNodeProps.x}px ${oldNodeProps.y}px`;
9225
9231
  }
9226
9232
  this.properties.forEach(prop => {
@@ -9235,14 +9241,15 @@ class AutoLayout {
9235
9241
  const newNode = newState.getNode($el);
9236
9242
  const newNodeProps = newNode.properties;
9237
9243
  this.timeline.call(() => {
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
+ // Don't set translate for inlined elements (to avoid text reflow)
9238
9252
  if (!newNode.isInlined) {
9239
- $el.style.width = `${newNodeProps.width}px`;
9240
- $el.style.height = `${newNodeProps.height}px`;
9241
- // Overrides user defined min and max to prevents width and height clamping
9242
- $el.style.minWidth = `auto`;
9243
- $el.style.minHeight = `auto`;
9244
- $el.style.maxWidth = `none`;
9245
- $el.style.maxHeight = `none`;
9246
9253
  $el.style.translate = `${newNodeProps.x}px ${newNodeProps.y}px`;
9247
9254
  }
9248
9255
  this.properties.forEach(prop => {
@@ -9275,19 +9282,27 @@ class AutoLayout {
9275
9282
  const transformedLength = transformed.length;
9276
9283
 
9277
9284
  if (transformedLength) {
9278
- // We only need to set the transform property here since translate is alread defined in the targets loop
9285
+ // We only need to set the transform property here since translate is already defined in the targets loop
9279
9286
  for (let i = 0; i < transformedLength; i++) {
9280
9287
  const $el = transformed[i];
9281
- $el.style.translate = `${oldState.getComputedValue($el, 'x')}px ${oldState.getComputedValue($el, 'y')}px`,
9288
+ const node = newState.getNode($el);
9289
+ // Don't set translate for inlined elements (to avoid text reflow)
9290
+ if (!node.isInlined) {
9291
+ $el.style.translate = `${oldState.getComputedValue($el, 'x')}px ${oldState.getComputedValue($el, 'y')}px`;
9292
+ }
9282
9293
  $el.style.transform = oldState.getComputedValue($el, 'transform');
9283
9294
  if (animatedSwap.includes($el)) {
9284
- const node = newState.getNode($el);
9285
9295
  node.ease = getFunctionValue(swapAtParams.ease, $el, node.index, node.total);
9286
9296
  node.duration = getFunctionValue(swapAtParams.duration, $el, node.index, node.total);
9287
9297
  }
9288
9298
  }
9289
9299
  this.transformAnimation = waapi.animate(transformed, {
9290
- translate: (/** @type {HTMLElement} */$el) => `${newState.getComputedValue($el, 'x')}px ${newState.getComputedValue($el, 'y')}px`,
9300
+ translate: (/** @type {HTMLElement} */$el) => {
9301
+ const node = newState.getNode($el);
9302
+ // Don't animate translate for inlined elements (to avoid text reflow)
9303
+ if (node.isInlined) return '0px 0px';
9304
+ return `${newState.getComputedValue($el, 'x')}px ${newState.getComputedValue($el, 'y')}px`;
9305
+ },
9291
9306
  transform: (/** @type {HTMLElement} */$el) => {
9292
9307
  const newValue = newState.getComputedValue($el, 'transform');
9293
9308
  if (!animatedSwap.includes($el)) return newValue;
@@ -9296,7 +9311,7 @@ class AutoLayout {
9296
9311
  return [oldValue, getFunctionValue(swapAtProps.transform, $el, node.index, node.total), newValue]
9297
9312
  },
9298
9313
  autoplay: false,
9299
- persist: true,
9314
+ // persist: true,
9300
9315
  ...timingParams,
9301
9316
  });
9302
9317
  this.timeline.sync(this.transformAnimation, 0);