Closed mercmobily closed 1 year ago
As noted in my comment, requestAnimationFrame
can be used to wait until all elements have updated. This will only not be ideal if you need to make a series of changes that may need to depend on each other, each of which would have to wait for requestAnimationFrame
. The reason this is not ideal is because there would then be likely undesirable screen paints before the chain of work is complete.
Does your use case fall into this category?
I updated the original issue, I think I had missed something important.
I think requestAnimationFrame
will probably cover most cases. My main gripe with this are two things:
I have done zero work with animation (I know right... I am a server guy at heart... really) and this function is really for:
The
window.requestAnimationFrame()
method tells the browser that you wish to perform an animation and requests that the browser calls a specified function to update an animation before the next repaint. The method takes a callback as an argument to be invoked before the repaint. Note: Your callback routine must itself call requestAnimationFrame() again if you want to animate another frame at the next repaint. requestAnimationFrame() is 1 shot. You should call this method whenever you're ready to update your animation onscreen. This will request that your animation function be called before the browser performs the next repaint. The number of callbacks is usually 60 times per second, but will generally match the display refresh rate in most web browsers as per W3C recommendation
Which is not exactly overlapping with "Wait till all elements have done their updating"...
Sorry if I wasn't overly helpful. I hope I am voicing other developer's questions as well.
This is a meta-issue to replace closed ones. AS per sorvell's comment,
Steve's takle on the issue didn't make it into the main tree.
While proposing possible solution, Steve mentioned this:
One note I want to stress here is that
Since the original tickets were submitted (#400 and #365), ResizeObserver has been polyfilled although I am not sure about performance.
@justinfagnani I hope this summary nails it.