The CSSOM View GeometryUtils APIs are currently available in Chromium behind the Experimental Web Platform features flag.
- Open
chrome://flags/#enable-experimental-web-platform-featuresin Chrome Canary. - Set Experimental Web Platform features to Enabled.
- Restart Chrome.
Alternatively, start Chromium with:
--enable-experimental-web-platform-features
<div id="target" style="width: 100px; height: 50px; transform: rotate(20deg)">
Test
</div>
<script>
const element = document.getElementById("target");
const quads = element.getBoxQuads();
console.log(quads[0]);
</script>getBoxQuads() returns a DOMQuad describing the transformed geometry of the element.
The implementation also provides the CSSOM View coordinate conversion APIs:
element.convertPointFromNode(point, otherElement);
element.convertRectFromNode(rect, otherElement);
element.convertQuadFromNode(quad, otherElement);These APIs convert geometry between the coordinate systems of different nodes.
CSSOM View Module – GeometryUtils: