W3C home > Mailing lists > Public > www-style@w3.org > April 2011

Re: [cssom] Element size/positioning information

From: Gérard Talbot <www-style@gtalbot.org>
Date: Tue, 12 Apr 2011 18:29:29 -0700
Message-ID: <352e50b98b295e13985a8d18896b781b.squirrel@cp3.shieldhost.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "www-style list" <www-style@w3.org>

Le Mar 12 avril 2011 17:31, Tab Atkins Jr. a écrit :
> Now, the mouse part of the discussion.
> Currently, there is one interoperable bit of location information
> returned by mouse events - the position relative to the viewport.
> Unfortunately, it's exposed via the unintuitive name of 'clientX' and
> 'clientY'.
> Some browsers expose other information - IE and Webkit expose
> offsetX/Y which is relative to the element itself

I have said that Opera 9+ also supports offsetX/Y in one of my previous

, which is a very
> useful bit of information.  It's not perfect, though - if you want to
> listen to mouse events on an ancestor

An element can have "n" ancestors within its containment hierarchy; a leaf
element often has many ancestors (containment or positioning). If you want
to listen to mouse events on the kth ancestor of an element, then you
would register an event listener for that (kth ancestor) element. There is
no serious difficulty with what you say and want to do.

> (or on window)

On a window, then you would use clientX/Y.

 and still get
> coordinates relative to a chosen element (for example, if you're
> drawing into a canvas, and want to still track the mouse when it's
> outside the canvas), then you have to switch back to using clientX/Y
> and subtracting the element's own position.


> All told, there appear to be three pieces of information that we want to
> expose:
> 1. Mouse coordinates relative to the viewport.

clientX/Y (also x/y according to CSSOM)

> 2. Mouse coordinates relative to an element's layout box(es)

By layout boxes, you mean offsetWidth/offsetHeight or you mean
clientWidth/clientHeight? You want to include or exclude borders?

CSS 2.1 Test suite RC6, March 23rd 2011

Contributions to CSS 2.1 test suite

Web authors' contributions to CSS 2.1 test suite
Received on Wednesday, 13 April 2011 01:30:01 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:45 UTC