page zoom rounding error offsetHeight/Width properties
Reported by
seddon.r...@gmail.com,
Apr 30 2016
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Firefox/45.0 Steps to reproduce the problem: 1. Set browser zoom to >=125% 2. Measure #modernizr element on https://codepen.io/anon/pen/QNZeyW and it returns 6px instead of 7px What is the expected behavior? To return 7px no matter what zoom level is set What went wrong? offsetHeight returns 6px Did this work before? N/A Chrome version: Version 50.0.2661.94 (64-bit) Channel: stable OS Version: OS X 10.9.5 Flash Version: Shockwave Flash 21.0 r0 See https://bugs.chromium.org/p/chromium/issues/detail?id=447902 same issue but for scrollHeight.
,
May 2 2016
Confirmed on Linux and Mac. I am getting 6px on zoom levels 110 and 125 and 7px on others. Chrome version - 50.0.2661.86
,
May 18 2016
On jsbin: http://jsbin.com/rebulon Same as codepen, but also logs to screen on resize. And you don't need to create an account on codepen to see output (grrr). Here is the link to the originating Modernizr issue: https://github.com/Modernizr/Modernizr/issues/1935
,
May 23 2016
,
May 23 2016
offsetHeight and offsetWidth returns the snapped height and width respectively and as such will change by up to a pixel depending on the zoom level as the element will need to be rounded (or snapped) to the nearest device pixel. For stable measurements use getBoundingClientRect instead.
,
May 28 2016
Seems not even getBoundingClientRect gives a stable value of what I would expect at different zoom levels. |
||||
►
Sign in to add a comment |
||||
Comment 1 by karandeepb@chromium.org
, May 2 2016