Last active
August 29, 2015 14:03
-
-
Save colelawrence/e6d51ff3afa53db34636 to your computer and use it in GitHub Desktop.
Wait for an element to calculate a offsetWidth before a calculation
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
do renderBouncer = -> | |
if inlineImgEl.offsetWidth isnt 0 | |
inlineImgEl.style.height = (inlineImgEl.offsetWidth / ratio) + "px" | |
else if inlineImgEl.renderOffsetWidthTries++ > 20 | |
inlineImgEl.style.height = (width / ratio) + "px" | |
else | |
setTimeout(renderBouncer, 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment