7 Replies
i want the transition to happen smoothly just like it is in the second part
https://pastecord.com/iwahoninox.typescript
here's the full snippet
You can use a
details
tag to achieve the reveal behaviour without all the js (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details)
you can then transition the height. You can’t do this by default, you have to use interpolate-size
(https://developer.mozilla.org/en-US/docs/Web/CSS/interpolate-size#) to allow for this. The only downside is this hasn’t got great support yet, so the transition would most likely have to be done using a js libraryMDN Web Docs
: The Details disclosure element - HTML: HyperText Markup Language ...
The HTML element creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label must be provided using the element.
MDN Web Docs
interpolate-size - CSS: Cascading Style Sheets | MDN
The interpolate-size CSS property allows you to enable animations and transitions between a value and an intrinsic size value such as auto, fit-content, or max-content.
i still wanna animate it via js, if it's possible, if checked, i toggle the paragraph to be animated, else it stays shut
please, don't
if you do, don't use
setInterval
that's the worst thing you can do
also, you're running the setInterval
at 10ms, and you try to do everything within those 10ms
which means, you're aiming for 100fps, but browsers don't always render at 100fps
you will be lucky if you get 60fps, which is 1000/60 milliseconds
if you really really want to animate with javascript, at least use requestAnimationFrame
how to use that requestAnimationFrame
you call
requestAnimationFrame
and it runs the function
the examples in mdn show it