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: Mon, 11 Apr 2011 18:26:26 -0700
Message-ID: <6183d5fc02abfbc77e748879f1a7281e.squirrel@cp3.shieldhost.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "www-style list" <www-style@w3.org>

Le Lun 11 avril 2011 14:35, Tab Atkins Jr. a écrit :

> Mouse Positioning
> =================
> On a closely related tangent, the mouse events expose .clientX and
> .clientY properties which are relative to the viewport.  If you're
> trying to find the position of the mouse relative to an element (for
> example, if you're drawing something to a <canvas> where the mouse
> is), you have to find the position of the element relative to the
> viewport and subtract the two positions.  I think this is a good
> candidate for being made easier, so you can just request the mouse
> coords relative to an element.  Again, all of the boxes of an element
> are potential targets for being measured relative to.

offsetX and offsetY properties seem to be what you are looking for here
(and it is covered by CSSOM spec):
reports/returns X/Y mouse coordinate within the target element




(you'll need IE6+ or Opera 7+ to view this)

> Thoughts?

Yes. I suggest you first search a bit tutorials or articles or interactive
demos about those properties. I know Peter-Paul Koch has done something. I
remember others (Garrett Smith - DHTMLkitchen) having a demo or tutorial,

Those properties (evt.layerX, offsetX, scrollX, etc.) have all been
tested, demo-ed interactively.

Another one:


And there are bug reports/enhancement requests to implement some like
evt.offsetY in Gecko browsers, others into webkit.

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 Tuesday, 12 April 2011 01:26:57 UTC

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