How to get screen position of CSS3-3d transformed elements?

混江龙づ霸主 提交于 2019-11-28 23:25:48

Have you tried using getBoundingClientRect()?

I've used it successfully in the past to calculate the dimensions of elements that have been transformed with the transform property.

The problem is, that the CSS3 transformations doesn't actually change the position of the elements in anyway. Of course the browsers "know" that they are repositioned, because it renders them, but this information is not provided back to the DOM/API.

The only thing I can think of, is to calculate the positions based on the transformations yourself, since these are "simple" matrix transformations.

Unfortunately Algebra class has been too long ago, that I can't tell you anymore how to do it - only that it is possible.

Using getBoundingClientRect is a good idea but will only give you the coordinates of the rectangle that contains your shape, not the exact coordinates of the 4 topleft, bottomright, bottomleft, topright corners.

You'd only be able to do this by taking each of those non-transformed coordinates and applying the transform via javascript.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!