I'm currently working on implementing a CSS transition within an accordion element that I am creating with Angular 7. To ensure proper display of the content inside, I have opted to use overflow-y: visible;
as I will not be using this element personally.
Due to the use of overflow, I find myself referencing max-height
instead of height
for my transition effect. Some sources suggest setting the max-height
to a significantly high value in order to accommodate for the overflow. However, this can result in awkward animations depending on the content.
To address this issue, I considered dynamically setting the max-height
based on the actual content height after the element is rendered and populated. While it does work using a setTimeout
within ngAfterViewInit()
, there seems to be a delay in calculating the scrollHeight
.
This led me to wonder if there is a specific point when the browser calculates the scrollHeight
and if there is a way to capture that event without relying on arbitrary time values with setTimeout()
.
Just exploring this conceptually, no need for specific code examples here. Appreciate any insights you may have. Thanks!