Re: [cssom] Element size/positioning information

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
email.

, 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.

No.

>
> 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?


Gérard
-- 
CSS 2.1 Test suite RC6, March 23rd 2011
http://test.csswg.org/suites/css2.1/20110323/html4/toc.html

Contributions to CSS 2.1 test suite
http://www.gtalbot.org/BrowserBugsSection/css21testsuite/

Web authors' contributions to CSS 2.1 test suite
http://www.gtalbot.org/BrowserBugsSection/css21testsuite/web-authors-contributions-css21-testsuite.html

Received on Wednesday, 13 April 2011 01:30:01 UTC