nkbt/react-collapse

An option to keep the node (not return null) when the height is zero

sompylasar opened this issue · 6 comments

This is required when applying CSS transitions (e.g. for background color).
When unmounted (null returned from render), the node loses its CSS state so when re-mounted, it gets fresh CSS state, and the transitions start over.

nkbt commented

I reckon that makes sense. Keen to PR?

nkbt commented

New opt-in feature to keep collapsed content keepCollapsedContent (defaults to false)

keep-collapsed

@nkbt Yay that's perfect! Thanks!

nkbt commented

Just a thought — any reason not to default this to true? Using this module for a client project (w/ Gatsby) and I noticed that before enabling this, there was some noticeable jumping in the animation right around when I assume the element was being destroyed. After I enabled this, the animation became super smooth.