Created
September 26, 2013 22:15
-
-
Save jfsiii/6721340 to your computer and use it in GitHub Desktop.
*sort of* like getBoundingClientRect() but it takes transforms into account.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRenderedRectangle(element, root) { | |
if (!root) root = document; | |
var width = element.offsetWidth, | |
height = element.offsetHeight, | |
topLeft = webkitConvertPointFromPageToNode(root, webkitConvertPointFromNodeToPage(element, new WebKitPoint(0, 0))), | |
topRight = webkitConvertPointFromPageToNode(root, webkitConvertPointFromNodeToPage(element, new WebKitPoint(width, 0))), | |
bottomLeft = webkitConvertPointFromPageToNode(root, webkitConvertPointFromNodeToPage(element, new WebKitPoint(0, height))), | |
bottomRight = webkitConvertPointFromPageToNode(root, webkitConvertPointFromNodeToPage(element, new WebKitPoint(width, height))); | |
return [topLeft, topRight, bottomRight, bottomLeft]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment