Created
April 3, 2016 15:43
-
-
Save allenhwkim/86f498bef85e65f36189e00c746d4167 to your computer and use it in GitHub Desktop.
Get real width and height using getComputedStyle
This file contains hidden or 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
// ref. https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | |
function getStyle(elem, prop) { | |
var styles = window.getComputedStyle(elem, null); | |
var value = styles.getPropertyValue(prop); | |
if (!value) { | |
throw "Could not get style for " + prop; | |
} | |
return value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment