← Back to release summary

Rendering Independent Scroll Offsets

Category
DOM
Type
New or changed feature
Status
In developer trial (Behind a flag) (Chrome 78)
Intent stage
Evaluate readiness to ship

Summary

Stops certain methods from snapping values to physical pixels, specifically scrollTop(), scrollLeft(), scrollX(), scrollY(), scrollTo(), and so on. Currently, calling window.scrollTo(0, 123.678) will snap the scroll offset to the nearest physical pixel. On a device with devicePixelRatio equal to 2 this would be 123.5, which is what is returned after this change.

Motivation

This behavior is surprising to developers as it's not clear why or how their scroll values are being modified. It leads to subtle bugs that only reproduce when used at specific zoom levels or devices with specific screen densities. It also means we don't actually change the scroll offset when the user zooms in and out. Consider a page that's zoomed into 200%, allowing scrolls on 0.5 CSS pixel increments. When we zoom back out to 100%, scrolls get snapped to integer pixels. This causes a real scroll and fires scroll events which leads to unexpected behavior. crbug.com/414283 tracks a number of cases this has bitten web authors and chromium developers alike. This change makes the behavior far more intuitive, making pixel-snapping a rendering artifact.

Standards & signals

Docs: https://github.com/bokand/RenderingIndependentScrollOffsets/blob/master/README.md

Explainers: https://github.com/bokand/RenderingIndependentScrollOffsets/blob/master/README.md

View on chromestatus.com