You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AFAICT, ResizeObserver is specifically designed to be slow to respond. So, if you use it to, for example, resize a canvas animation, you end up with situations like this
Screen.Recording.2023-11-06.at.15.19.00.mov
Above the page is using ResizeObserver events to adjust the size of the canvas. notice the image gets stretched and distorted because the frequency of events from ResizeObserver is too slow to keep up with the size of the canvas.
Compare to this animation which looking up the size to make the canvas via element.clientWidth and element.clientHeight
Screen.Recording.2023-11-06.at.15.19.26.mov
This one does respond in time to update the canvas as the page resizes
The problem is, only ResizeObserver returns correct sizes via devicePixelContentBoxSize so if you want a pixel perfect display you're stuck with the first behavior instead of the second. That seems undesirable.
You could workaround the issue by some complicated solution where you first use some non-correct means like clientWidth and clientHeight or getBoundingClientRect and then try to update your incorrect guess with the correct data from ResizeObserver and devicePixelContentBoxSize but the fact that you'd have to jump through these hoops seems to suggest maybe the spec needs a revisit?
The text was updated successfully, but these errors were encountered:
AFAICT, ResizeObserver is specifically designed to be slow to respond. So, if you use it to, for example, resize a canvas animation, you end up with situations like this
Screen.Recording.2023-11-06.at.15.19.00.mov
Above the page is using
ResizeObserver
events to adjust the size of the canvas. notice the image gets stretched and distorted because the frequency of events fromResizeObserver
is too slow to keep up with the size of the canvas.Compare to this animation which looking up the size to make the canvas via
element.clientWidth
andelement.clientHeight
Screen.Recording.2023-11-06.at.15.19.26.mov
This one does respond in time to update the canvas as the page resizes
The problem is, only
ResizeObserver
returns correct sizes viadevicePixelContentBoxSize
so if you want a pixel perfect display you're stuck with the first behavior instead of the second. That seems undesirable.You could workaround the issue by some complicated solution where you first use some non-correct means like
clientWidth
andclientHeight
orgetBoundingClientRect
and then try to update your incorrect guess with the correct data fromResizeObserver
anddevicePixelContentBoxSize
but the fact that you'd have to jump through these hoops seems to suggest maybe the spec needs a revisit?The text was updated successfully, but these errors were encountered: