Permalink
Browse files

Make sure measeelement is in the document before measering

  • Loading branch information...
jonastreub committed Jul 24, 2017
1 parent 369b1c8 commit bb2ef1407e2ebcf9b04644b3a629cb7a64d3b956
Showing with 7 additions and 6 deletions.
  1. +7 −6 framer/StyledText.coffee
View
@@ -10,6 +10,13 @@ getMeasureElement = (constraints={}) ->
_measureElement.style.visibility = "hidden"
_measureElement.style.top = "-10000px"
_measureElement.style.left = "-10000px"
# This is a trick to call this function before the document ready event
if not window.document.body
document.write(_measureElement.outerHTML)
_measureElement = document.getElementById("_measureElement")
else
window.document.body.appendChild(_measureElement)
while _measureElement.hasChildNodes()
_measureElement.removeChild(_measureElement.lastChild)
@@ -22,12 +29,6 @@ getMeasureElement = (constraints={}) ->
_measureElement.style.width = "#{constraints.width}px" if constraints.width
_measureElement.style.height = "#{constraints.height}px" if constraints.height
# This is a trick to call this function before the document ready event
if not window.document.body
document.write(_measureElement.outerHTML)
_textSizeNode = document.getElementById("_measureElement")
else
window.document.body.appendChild(_measureElement)
return _measureElement
class InlineStyle

0 comments on commit bb2ef14

Please sign in to comment.