stephenscaff / read-smore

A little Read More JS thing
https://stephenscaff.github.io/read-smore/
MIT License
28 stars 7 forks source link

Height Animation #12

Closed newkind closed 1 year ago

newkind commented 2 years ago

Quick question about animating content block height. Do you have any ideas what would be the best way to animate the text after clicking the "less" button since the DOM elements that will be truncated are being removed instantly?

Thanks for the great script!

stephenscaff commented 1 year ago

Sorry for the late reply.

I understand what you're getting at, but this script made the design decision to toggle between 2 states where the content is actually truncated - not just hidden. So, animating height wouldn't be easily feasible.

The script was built for larger production apps where height animations wouldn't be desirable - ie: user comments, production descriptions, etc.

If you need height animation, an easy move is to just set a max height on your content, hide the overflow, and transition between an arbitrarily large max-height on active state.

Closing this as the feature request isn't aligned with the lib.

Thanks for reaching out.