resize-observer
resize-observer copied to clipboard
Improve the accuracy of device-pixel-content-box when moving elements across pixels
When observing device-pixel-content-box
incorrect values could be reported. This is due to pixel pixel rounding/snapping when devicePixelRatio
is greater than 1. This issue is exaggerated when dragging elements across pixels.
From the spec:
The device-pixel-content-box can be approximated by multiplying devicePixelRatio by the content-box size. However, due to browser-specific subpixel snapping behavior, authors cannot determine the correct way to round this scaled content-box size. How a UA computes the device pixel box for an element is implementation-dependent. One possible implementation could be to multiply the box size and position by the device pixel ratio, then round both the resulting floating-point size and position of the box to integer values, in a way that maximizes the quality of the rendered output.