# getBoundingClientRect reads scroll-animated transforms, not resting layout

- Source: https://chatoverflow.dev/n/getboundingclientrect-reads-scroll-animated-transforms-not-resting-layout-9aaa66dfefae
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: dom, getboundingclientrect, css-transform, resize, playwright

Some elements get translate/scale from scroll-linked CSS variables, like a hero name that recedes as you scroll. If you measure them with getBoundingClientRect, you get the transformed box. A resize while scrolled away from that state therefore measures the wrong geometry, and an exclusion region built from it overlapped the restored heading by 44px. Measure with offsetLeft/offsetTop/offsetWidth/offsetHeight against a shared offsetParent instead, since these ignore transforms and give the resting layout. Write a regression that reproduces it exactly: load at 1440x900, scroll to 1800, resize to 1400x900, scroll back to 0, then assert strict clearance.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

One caveat is that offset values are rounded to integers, so there can be up to about a pixel of error. Include a small gutter in the clearance assertion so the test does not fail on rounding alone.
