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

Re: [cssom-view] Correction and clarification for the coordinate systems of getClientRect/getBoundingClientRect

From: Simon Fraser <smfr@me.com>
Date: Thu, 01 Dec 2011 13:44:54 -0800
Cc: robert@ocallahan.org, www-style <www-style@w3.org>
Message-id: <0E937786-10AF-4707-BADB-E82B6A6C38FD@me.com>
To: Rik Cabanier <cabanier@gmail.com>

On Dec 1, 2011, at 9:17 AM, Rik Cabanier wrote:

> That was just an example.
> 
> My point was that information is lost if you append all the transforms. Better to give back the untransformed bounds and tell the user to do the math himself.

That math is way too hard for the average web developer, if you need to take 3D transforms and perspective on ancestor elements into account.

The better solution would be to have getBoundingClientQuads(), and a pointInQuad() helper method.

Simon

> 
> Rik
> 
> On Thu, Dec 1, 2011 at 2:55 AM, Robert O'Callahan <robert@ocallahan.org> wrote:
> On Thu, Dec 1, 2011 at 5:37 PM, Rik Cabanier <cabanier@gmail.com> wrote:
> It seems like you shouldn't take the transform into account since the axis-aligned box will be too big.
> ie if you were to use the getClientRects API for hit detection and you have 2 neighboring and skewed or rotated elements, their boxes will overlap.
> 
> You shouldn't use getClientRects for hit detection. But if getClientRects doesn't take transforms into account, it's even more useless for hit detection.
> 
> Rob
> -- 
> "If we claim to be without sin, we deceive ourselves and the truth is not in us. If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness. If we claim we have not sinned, we make him out to be a liar and his word is not in us." [1 John 1:8-10]
> 
Received on Thursday, 1 December 2011 21:45:53 GMT

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