prototypejs/prototype

Position.within fails when parent dom tree contains css transformations

qsiebers opened this issue · 2 comments

Position.within fails to take into account transformations performed by the CSS transform properties. The cause is probably located within Element.cumulativeOffset.

I'm not sure on how to fix this, or if it's even wanted.

Yeah, not sure there's much to do about that. Last time I checked (though it's been a few years) there wasn't a reliable way to figure out where an element was on the screen with transforms taken into account. Properties like offsetLeft don't "see" transforms, and even stuff like getBoundingClientRect didn't behave uniformly across browsers when transforms are applied.

But I should check again, so I'll leave this open for now.

It seems you can use window.getComputedStyle() to get the transformation matrix. You can then calculate the new transformed position of the element. I think I'll change my own workaround to use the translate values provided by the matrix.

It might be a nice feature to use all the transformation matrix information in calculating correct location, although this would hardly be optimal unless there is a way to get this information directly from the browser.