Rendering Independent Scroll Offsets

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.

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.

Documentation

Specification

No public standards discussion

Status in Chromium

Blink>Scroll


Behind a flag (tracking bug) in:

  • Chrome for desktop release 78
  • Chrome for Android release 78
  • Android WebView release 78

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

  • No public signals
  • No public signals
  • No public signals
  • No signals

Owner

Last updated on 2019-10-09