Stanko / react-animate-height

Lightweight React component for animating height using CSS transitions. Slide up/down the element, and animate it to any specific height.
https://muffinman.io/react-animate-height
MIT License
756 stars 53 forks source link

Version 3 - animation stop working after the first action #138

Closed Bdragon93 closed 1 year ago

Bdragon93 commented 1 year ago

Code example https://codesandbox.io/s/react-animate-height-animate-height-when-content-changes-forked-ky6cvt?file=/src/index.js

Expected behavior

Possible Solution

Steps to Reproduce (for bugs)

  1. Click "add" button to add the 1st item.
  2. Click "add" button to add more items.

Your Environment

Additional context

Stanko commented 1 year ago

Hey @Bdragon93, In version 3 onAnimationEnd was renamed to onHeightAnimationEnd, to avoid collision with the native method. https://github.com/Stanko/react-animate-height#breaking-changes

Just swap it, and the example you added should start working: https://codesandbox.io/s/react-animate-height-animate-height-when-content-changes-forked-eggitr

Cheers!

Stanko commented 1 year ago

P.S. Please be aware that AnimateHeight wasn't made with this specific usecase in mind. Having fixed height can result in content being cut off when user changes window size.

Bdragon93 commented 1 year ago

@Stanko Great thanks, that was my bad, I was switching versions for testing and forgot to adjust that prop then. However, would be helpful if you remove onAnimationEnd totally, no error when I pass the old named (wrong) prop and it even work for the first time as I mentioned

Stanko commented 1 year ago

It is a native event, so it gets handy sometimes: https://developer.mozilla.org/en-US/docs/Web/API/Element/animationend_event