W3C home > Mailing lists > Public > public-css-archive@w3.org > September 2017

[csswg-drafts] [cssom-view] offsetTop/Left spec seems to be pretty confused when scrolling is involved

From: Boris Zbarsky via GitHub <sysbot+gh@w3.org>
Date: Mon, 25 Sep 2017 20:37:04 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-260406834-1506371812-sysbot+gh@w3.org>
bzbarsky has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] offsetTop/Left spec seems to be pretty confused when scrolling is involved ==
Simple testcase:

    <div id="parent" style="overflow:scroll; height: 100px; position: relative">
      <div id="spacer" style="height: 200px"></div>
      <div id="child" style="border: 1px solid green"></div>
    </div>

Load this, scroll the scrollable div all the way down, examine "child.offsetTop".  It comes back as "200" in browsers.  The spec at <https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop>, on the other hand says:

> Return the result of subtracting the y-coordinate of the top padding edge of the first CSS layout box associated with the offsetParent of the element from the y-coordinate of the top border edge of the first CSS layout box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors.

and in this case this is definitely not 200.  The spec is wrong and needs to be fixed, afaict.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1832 using your GitHub account
Received on Monday, 25 September 2017 20:36:55 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:26:43 UTC