logoalt Hacker News

maxlohtoday at 3:55 AM7 repliesview on HN

> The details / summary thing absolutely kills me. There’s basically nothing you can’t do with them.

Animating the details element is tricky. By the spec, browsers don’t natively support transitions between display: none and display: block.


Replies

jakelazarofftoday at 4:45 AM

That is no longer true! You can do it in CSS with a combination of `@starting-style` and `transition-behavior: allow-discrete`. [1]

Another gotcha you'll run into is animating the height. A couple other new features (`interpolate-size: allow-keywords` and `::details-content`) will let you get around that. [2]

Modern CSS is awesome.

[1] https://developer.chrome.com/blog/entry-exit-animations

[2] https://nerdy.dev/open-and-close-transitions-for-the-details...

show 4 replies
qudattoday at 4:01 AM

Animating accordions is almost always a bad idea because the content length can make it unbearable.

In general I find animations on the web overused and unnecessary

show 1 reply
danw1979today at 9:57 AM

Does it need animating ?

lelanthrantoday at 8:30 AM

> Animating the details element is tricky. By the spec, browsers don’t natively support transitions between display: none and display: block.

Very hot take; then don't animate them!

Animation in a UI is great - you draw the user's attention to a widget that changed because they might not necessarily notice it otherwise. This improves the UX.

With a details/summary, the animation is not needed and can only make a negative change to the UX. There is no positive change to the UX that animating the details/summary elements would bring. When it is opened it is obvious.

If you really really need to animate the details, instead of animating open/close, instead animate the summary background/text color to indicate that the element has just changed state.

Would I like easy animation of open/close? Sure. Does it improve the UX? Nope.

computerfriendtoday at 4:55 AM

You can put a transition on details > summary.

stephenrtoday at 9:34 AM

> browsers don’t natively support transitions between display: none and display: block.

You say that like it's a bad thing.