You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to this Math.round, element sizes are changed from their actual size while animating, causing flex elements with text to wrap.
Screen.Recording.2024-01-19.at.17.35.30.mov
For example, here I have a flex item with three elements. The first and third element are fixed in width, while the middle text element's width is dynamic. When rendered, it measures up to 245.17px. Once the element is removed and auto-animate starts fading it out, it sets width: 245px for whatever reason, causing the text inside to wrap to the next line. Removing the round in the code above fixes this.
The text was updated successfully, but these errors were encountered:
Are you sure that’s due to rounding? I would be thrilled if it was because we could fix it, but up till now my working hypothesis is this: some "paints" take 2 paints and some take 1. Text is particularly tricky because the browser itself doesnt know how big/wide the text will be until it has painted it. So it paints, measures it, then paints again. Unfortunately autoanimate is only informed of the first paint (which wrapped) and thus sets the size to that instead of the second paint. Ive looked for a way around this but been unable to find one.
This tends to happen with things were the width of the item is determined by its context, like width-less flex items, table cells (those have other issues too), floats, etc.
If you can demonstrate that it is indeed a rounding issue I would be thrilled to accept a PR or look into it further!
It looks to be. If I break just as the element is fading out and check its size in the inspector, its width has been rounded down, and if I remove the rounding from the line I mentioned it works fine. I don't know why the rounding was added originally so I'm hesitant to create a PR, but it works a lot better without it for my specific case!
https://github.com/formkit/auto-animate/blame/b62aa87b0ce6b90c92fb7ebb06a3da49f74b7f77/src/index.ts#L428
Due to this
Math.round
, element sizes are changed from their actual size while animating, causing flex elements with text to wrap.Screen.Recording.2024-01-19.at.17.35.30.mov
For example, here I have a flex item with three elements. The first and third element are fixed in width, while the middle text element's width is dynamic. When rendered, it measures up to
245.17px
. Once the element is removed and auto-animate starts fading it out, it setswidth: 245px
for whatever reason, causing the text inside to wrap to the next line. Removing the round in the code above fixes this.The text was updated successfully, but these errors were encountered: