react-animate-height icon indicating copy to clipboard operation
react-animate-height copied to clipboard

Element no longer animates up and down when using "auto"

Open WhereCanI opened this issue 1 year ago • 9 comments

react-animate-height no longer animate up and down when used with React. It is the same problem with the demos provided here: https://muffinman.io/react-animate-height/#demo-3. They no longer animate up and down pending on the content.

Expected behavior Animating from height 0 to height "auto".

Your Environment

  • Version used: 3.2.2
  • OS: Windows 11
  • Browser Firefox 118 & Chrome 117

Additional context I have checked that the container is following the guidelines, and I have even tried removing all styling such as padding, margin, display, flex from parent containers. Nothing seem to work to make react-animate-height animate from 0 to "auto".

WhereCanI avatar Sep 28 '23 11:09 WhereCanI

Hey, I’m not near my laptop, but if I understood correctly, you want to animate height on content change.

That is not supported out of the box, but it can be achieved by using ResizeObserver.

Check the documentation for the code example: https://github.com/Stanko/react-animate-height#animate-height-on-content-change

Cheers!

Stanko avatar Sep 28 '23 17:09 Stanko

No, it's not what I mean. What I mean is that I no longer can make it animate from 0 to auto. It used to be able to do that, but now it won't do it no matter how I add it to my React projects.

I have tried to troubleshoot by making sure there are no CSS that can break the calculation. But it does not make a difference.

I have a suspicion that it might break the animation if the change between 0 and auto is triggering React to rerender.

WhereCanI avatar Oct 04 '23 09:10 WhereCanI

Please create provide a sandbox (https://codesandbox.io/), because I have no idea what the problem actually is.

Stanko avatar Oct 09 '23 14:10 Stanko

I faced same issue but there was because i used '0%' instead of 0 as number

eseQ avatar Feb 15 '24 11:02 eseQ

Hi, is this being looked into? I think I'm facing the same problem as described. I'm upgrading from v2.0.7 to v3.2.3 and the animation when opening/closing is no longer there

For example:

<AnimateHeight height={props.isExpanded ? 'auto' : 0} duration={3000} delay={2000}>
    <MyStuff....>
</AnimateHeight>

just flicks between open and close, with no smooth animation

IsabellaRey avatar Mar 28 '24 16:03 IsabellaRey

Hey, I'm not working on it as I can't reproduce it.

Can you please try to fork this codepen to recreate the issue you are having https://codepen.io/stanko/pen/NWmaGjX

Once I know what is wrong I'll look into fixing it.

Cheers!

Stanko avatar Mar 28 '24 19:03 Stanko

I'm a colleague of @IsabellaRey - turns out that we're using a virtual desktop in which the Windows setting "Animation effects" was disabled by default. Your codepen above works if Animation effects is on, but not if it is off (unlike 2.0.7 which works either way). I presume this is due to a change in how the animation is produced?

edwiles avatar Apr 02 '24 15:04 edwiles

Hi @edwiles, That is correct, the library respects user's preferences to reduce motion. The actual code is here:

https://github.com/Stanko/react-animate-height?tab=readme-ov-file#reduced-motion

I won't be providing a way around it, as it would break accessibility.

Hope that makes sense, cheers!

Stanko avatar Apr 02 '24 16:04 Stanko

Hey @WhereCanI Could it be that you also had "reduce motion" option enabled?

Stanko avatar Apr 04 '24 12:04 Stanko

I'm closing this issue for now, if you can create a way to replicate it, I'll dig deeper. Thank you!

Stanko avatar May 15 '24 12:05 Stanko