11/**
22 * Anime.js - ESM bundle
3- * @version v4.3.4
3+ * @version v4.3.5
44 * @license MIT
55 * @copyright 2026 - Julian Garnier
66 */
@@ -740,6 +740,7 @@ const noop = () => {};
740740
741741// Regex
742742
743+ const validRgbHslRgx = / \) \s * [ - . \d ] / ;
743744const hexTestRgx = / ( ^ # ( [ \d a - f ] { 3 } ) { 1 , 2 } $ ) | ( ^ # ( [ \d a - f ] { 4 } ) { 1 , 2 } $ ) / i;
744745const rgbExecRgx = / r g b \( \s * ( \d + ) \s * , \s * ( \d + ) \s * , \s * ( \d + ) \s * \) / i;
745746const rgbaExecRgx = / r g b a \( \s * ( \d + ) \s * , \s * ( \d + ) \s * , \s * ( \d + ) \s * , \s * ( - ? \d + | - ? \d * .\d + ) \s * \) / i;
@@ -803,7 +804,7 @@ const globals = {
803804
804805const devTools = isBrowser && win . AnimeJSDevTools ;
805806
806- const globalVersions = { version : '4.3.4 ' , engine : null } ;
807+ const globalVersions = { version : '4.3.5 ' , engine : null } ;
807808
808809if ( isBrowser ) {
809810 if ( ! win . AnimeJS ) win . AnimeJS = [ ] ;
@@ -851,11 +852,11 @@ const isSvg = a => isBrowser && a instanceof SVGElement;
851852/**@param {any } a @return {Boolean } */
852853const isHex = a => hexTestRgx . test ( a ) ;
853854/**@param {any } a @return {Boolean } */
854- const isRgb = a => stringStartsWith ( a , 'rgb' ) && a [ a . length - 1 ] === ')' ;
855+ const isRgb = a => stringStartsWith ( a , 'rgb' ) ;
855856/**@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 ) ) ) ;
859860/**@param {any } a @return {Boolean } */
860861const isKey = a => ! globals . defaults . hasOwnProperty ( a ) ;
861862
@@ -3977,7 +3978,7 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
39773978 parent . animations . push ( animation ) ;
39783979 removeWAAPIAnimation ( $el , property ) ;
39793980 addChild ( WAAPIAnimationsLookups , { parent, animation, $el, property, _next : null , _prev : null } ) ;
3980- const handleRemove = ( ) => { removeWAAPIAnimation ( $el , property , parent ) ; } ;
3981+ const handleRemove = ( ) => removeWAAPIAnimation ( $el , property , parent ) ;
39813982 animation . oncancel = handleRemove ;
39823983 animation . onremove = handleRemove ;
39833984 if ( ! parent . persist ) {
@@ -9078,7 +9079,7 @@ class AutoLayout {
90789079 // const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
90799080
90809081 if ( node . isTarget && ( ! node . measuredIsRemoved && oldStateNode . measuredIsVisible || node . measuredIsRemoved && node . measuredIsVisible ) ) {
9081- if ( ! node . isInlined && ( nodeProperties . transform !== 'none' || oldStateNodeProperties . transform !== 'none' ) ) {
9082+ if ( nodeProperties . transform !== 'none' || oldStateNodeProperties . transform !== 'none' ) {
90829083 node . hasTransform = true ;
90839084 transformed . push ( $el ) ;
90849085 }
@@ -9094,7 +9095,7 @@ class AutoLayout {
90949095 if ( ! node . isTarget ) {
90959096 swapping . push ( $el ) ;
90969097 if ( node . sizeChanged && parent && parent . isTarget && parent . sizeChanged ) {
9097- if ( ! node . isInlined && swapAtProps . transform ) {
9098+ if ( swapAtProps . transform ) {
90989099 node . hasTransform = true ;
90999100 transformed . push ( $el ) ;
91009101 }
@@ -9134,7 +9135,7 @@ class AutoLayout {
91349135
91359136 // muteNodeTransition(newNode);
91369137
9137- // Don't animate dimensions and positions of inlined elements
9138+ // Don't animate positions of inlined elements (to avoid text reflow)
91389139 if ( ! newNode . isInlined ) {
91399140 // Display grid can mess with the absolute positioning, so set it to block during transition
91409141 if ( oldNode . measuredDisplay === 'grid' || newNode . measuredDisplay === 'grid' ) $el . style . setProperty ( 'display' , 'block' , 'important' ) ;
@@ -9153,14 +9154,15 @@ class AutoLayout {
91539154 $el . style . left = '0px' ;
91549155 $el . style . top = '0px' ;
91559156 }
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` ;
91639157 }
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` ;
91649166 }
91659167
91669168 // Restore the scroll position if the oldState differs from the current state
@@ -9181,21 +9183,19 @@ class AutoLayout {
91819183 const animatedProps = {
91829184 composition : 'none' ,
91839185 } ;
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- }
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 ;
91999199 }
92009200 this . properties . forEach ( prop => {
92019201 const oldVal = oldNodeState [ prop ] ;
@@ -9217,15 +9217,16 @@ class AutoLayout {
92179217 for ( let i = 0 , l = swapping . length ; i < l ; i ++ ) {
92189218 const $el = swapping [ i ] ;
92199219 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
92209229 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` ;
92299230 $el . style . translate = `${ oldNodeProps . x } px ${ oldNodeProps . y } px` ;
92309231 }
92319232 this . properties . forEach ( prop => {
@@ -9240,14 +9241,15 @@ class AutoLayout {
92409241 const newNode = newState . getNode ( $el ) ;
92419242 const newNodeProps = newNode . properties ;
92429243 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)
92439252 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` ;
92519253 $el . style . translate = `${ newNodeProps . x } px ${ newNodeProps . y } px` ;
92529254 }
92539255 this . properties . forEach ( prop => {
@@ -9280,19 +9282,27 @@ class AutoLayout {
92809282 const transformedLength = transformed . length ;
92819283
92829284 if ( transformedLength ) {
9283- // 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
92849286 for ( let i = 0 ; i < transformedLength ; i ++ ) {
92859287 const $el = transformed [ i ] ;
9286- $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+ }
92879293 $el . style . transform = oldState . getComputedValue ( $el , 'transform' ) ;
92889294 if ( animatedSwap . includes ( $el ) ) {
9289- const node = newState . getNode ( $el ) ;
92909295 node . ease = getFunctionValue ( swapAtParams . ease , $el , node . index , node . total ) ;
92919296 node . duration = getFunctionValue ( swapAtParams . duration , $el , node . index , node . total ) ;
92929297 }
92939298 }
92949299 this . transformAnimation = waapi . animate ( transformed , {
9295- 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+ } ,
92969306 transform : ( /** @type {HTMLElement } */ $el ) => {
92979307 const newValue = newState . getComputedValue ( $el , 'transform' ) ;
92989308 if ( ! animatedSwap . includes ( $el ) ) return newValue ;
@@ -9301,7 +9311,7 @@ class AutoLayout {
93019311 return [ oldValue , getFunctionValue ( swapAtProps . transform , $el , node . index , node . total ) , newValue ]
93029312 } ,
93039313 autoplay : false ,
9304- persist : true ,
9314+ // persist: true,
93059315 ...timingParams ,
93069316 } ) ;
93079317 this . timeline . sync ( this . transformAnimation , 0 ) ;
0 commit comments