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

On 12/1/11 11:08 PM, Yehuda Katz wrote:
>
> Yehuda Katz
> (ph) 718.877.1325
>
>
> On Thu, Dec 1, 2011 at 2:00 PM, Tab Atkins Jr. <jackalmage@gmail.com 
> <mailto:jackalmage@gmail.com>> wrote:
>
>     On Thu, Dec 1, 2011 at 1:57 PM, Yehuda Katz <wycats@gmail.com
>     <mailto:wycats@gmail.com>> wrote:
>     > On Thu, Dec 1, 2011 at 1:53 PM, Tab Atkins Jr.
>     <jackalmage@gmail.com <mailto:jackalmage@gmail.com>> wrote:
>     >> On Thu, Dec 1, 2011 at 1:44 PM, Simon Fraser <smfr@me.com
>     <mailto:smfr@me.com>> wrote:
>     >> > 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.
>     >>
>     >> We've had this discussion before.  There's a bunch of
>     information and
>     >> variants of rects and quads that *might* be useful to expose.
>      Someone
>     >> needs to sit down and spend the time to figure out *what* to expose
>     >> and how to do it all sanely.  I don't think adding things piecemeal
>     >> will give us a good result in the end.
>     >
>     > Unfortunately, this means that for the forseeable future, doing hit
>     > detection and direct manipulation on transformed elements (very,
>     very common
>     > on mobile devices) will continue to be complicated, error-prone, and
>     > somewhat outside the reach of the average developer :(
>
>     Yes.  But the alternative is accumulating a bunch of crufty legacy
>     methods that hinder development of a proper API.  We don't need
>     perfection, but we need something better than throwing use-cases at
>     the wall and solving them each individually.
>
>     This isn't something that'll take long to do, if someone is willing to
>     spend the time on it.  The past thread on www-style between me and roc
>     already got a good start on it.
>
>
> Agreed. Unfortunately, I do not feel personally qualified to answer 
> the bigger question ;)
>
CSSMatrix is a big help on using those transform properties in the meantime.

I've done affine transforms from native css through to Canvas bitmaps.
It requires several offset calcs and a few multiplications.

I was very glad to have CSSMatrix to help with that.

-Charles

Received on Friday, 2 December 2011 08:14:53 UTC