offsetHeight and offsetWidth in CSS grid item wrongly calculated on window resize
Reported by
julianso...@gmail.com,
Jul 12
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36 Example URL: Steps to reproduce the problem: 1. Calculate canvas element width and height through its parent `offsetWidth` and `offsetHeight`, to be both the same size. 2. Update canvas width and height with an `onresize` event listener 3. Canvas' parent dimensions should be automatically set by CSS Grids 4. Resize window What is the expected behavior? The canvas and its parent dimensions must correspond to the CSS Grids rules. If a grid item width is set to be 50% its container width, it must be de same proportion, even on window resize. Then item's `offsetWidth` (Javascript) should be 50% of its container width, also 'offsetWidth' must be the same ratio on resize (this is calculated with an event listener and update every time). What went wrong? Canvas width and height (and its parent) calculation is unexpected. On every resize event offsetWidth and offsetHeight increases indefinitely each time, never decreases as it should. Does it occur on multiple sites: N/A Is it a problem with a plugin? No Did this work before? N/A Does this work in other browsers? N/A Chrome version: 67.0.3396.99 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: Open file for an example
,
Jul 13
Able to reproduce the issue on chrome reported version# 67.0.3396.99 and latest chrome# 69.0.3489.0 using Mac 10.12.6, Ubuntu 14.04 and Windows-10. As this issue is seen from M-60(60.0.3112.0), hence considering this issue as Non-Regression and marking it as Untriaged. Thanks!
,
Jul 16
The very same thing happens on Firefox, so the issue is in the test itself not in the browser. The problem is that the example is setting the size of the canvas (width and height), which is used to recompute the grid columns when there's a resize. I'm attaching a similar example, where the canvas gets resized properly.
,
Jul 17
The reason I set the canvas size through HTML properties is that it is necessary. CSS styles change the pixel ratio. Maybe, the problem is the specs.
,
Jul 17
You can keep the aspect ratio setting "width: 100%" and not setting height (see attachment). Still there are some discussions on CSSWG regarding aspect ratio issues: https://github.com/w3c/csswg-drafts/issues/333 |
|||
►
Sign in to add a comment |
|||
Comment 1 by tkent@chromium.org
, Jul 12