Permalink
Browse files

Fixed bug where measuring element was created before the dom is ready

  • Loading branch information...
nvh committed Jul 7, 2017
1 parent 1cb646c commit 687d7c2c73574998febf0f5be9ccbff7ad0009ab
Showing with 9 additions and 2 deletions.
  1. +9 −2 framer/TextLayer.coffee
View
@@ -11,14 +11,14 @@ _measureElement = null
getMeasureElement = (constraints={}) ->
if not _measureElement
shouldCreateElement = not _measureElement
if shouldCreateElement
_measureElement = document.createElement("div")
_measureElement.id = "_measureElement"
_measureElement.style.position = "fixed"
_measureElement.style.visibility = "hidden"
_measureElement.style.top = "-10000px"
_measureElement.style.left = "-10000px"
window.document.body.appendChild(_measureElement)
while _measureElement.hasChildNodes()
_measureElement.removeChild(_measureElement.lastChild)
@@ -30,6 +30,13 @@ getMeasureElement = (constraints={}) ->
else
_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 687d7c2

Please sign in to comment.