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

Re: [css3-2d-transforms] [css3-3d-transforms] MouseEvent coordinates after CSS3 transform?

From: L. David Baron <dbaron@dbaron.org>
Date: Sat, 23 Jul 2011 08:13:12 -0700
To: Denilson Figueiredo de Sรก <denilsonsa@gmail.com>
Cc: www-style@w3.org
Message-ID: <20110723151312.GA32002@pickering.dbaron.org>
On Friday 2011-07-22 17:41 -0300, Denilson Figueiredo de Sรก wrote:
> If this is the case, then I believe we need some kind of DOM
> interface that convert coordinates. Maybe something like:
> 
> Element.convertCoordinates(x, y, referenceElement);
> 
> It would convert the x,y coordinates that are originally relative to
> referenceElement into coordinates relative to Element.

I absolutely agree that we should have such an API.  Browsers
already know how to do this sort of conversion (for handling
events), and exposing it via an API would allow authors to write
coordinate conversion code that's resilient to the addition of new
features.

I'd also like a similar API for converting coordinates from an
event, since that's one of the most common use cases.

To quote from a private email that I wrote yesterday about the need
to propose such an API (describing a few options that we have):
 
# So currently we have an elementFromPoint method on the document
# object.
# 
# We probably want methods taking:
#   (event, element) -> (x, y, z)
#   (ref_element, ref_x, ref_y, element) -> (x, y, z)
# 
# The return value would probably be an object with .x, .y, and .z
# properties.
# 
# Probably we want the |this| on these methods to represent either the
# origin (event or ref_element) or destination (element) coordinate
# spaces, so they'd actually have one fewer parameter.  So in other
# words, they could have syntax something like:
#   ref_element.toCoordinates(element, ref_x, ref_y)
#   event.toCoordinates(element)
# or,
#   element.coordinatesFrom(ref_element, ref_x, ref_y)
#   element.coordinatesFrom(event)
# although I think those are probably horrible names.

I'm not sure if the way I'm thinking about 3-D here is correct.  It
would also be great if somebody could think of clear, consise names
that made it clear which way the conversion was happening.

-David

-- 
๐„ž   L. David Baron                         http://dbaron.org/   ๐„‚
๐„ข   Mozilla Corporation               http://www.mozilla.com/   ๐„‚
Received on Saturday, 23 July 2011 15:13:37 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:42 GMT