Permalink
Browse files

Added trigger when context element is part of the dom

  • Loading branch information...
nvh committed Jan 19, 2018
1 parent 37e97cb commit c404ded4afec80243b3a525be553b3e33788191f
Showing with 9 additions and 0 deletions.
  1. +4 −0 framer/Context.coffee
  2. +5 −0 framer/Layer.coffee
View
@@ -78,6 +78,7 @@ class exports.Context extends BaseClass
@perspectiveOriginX = options.perspectiveOriginX
@perspectiveOriginY = options.perspectiveOriginY
@elementInDOM = false
@reset()
if options.hasOwnProperty("index")
@@ -302,6 +303,8 @@ class exports.Context extends BaseClass
parentElement = @_parent?._element
parentElement ?= document.body
parentElement.appendChild(@_element)
@elementInDOM = true
@_layers?.map (l) -> l.elementInsertedIntoDocument()
Utils.domComplete(@__pendingElementAppend)
@@ -312,6 +315,7 @@ class exports.Context extends BaseClass
if @_element?.parentNode
@_element.parentNode.removeChild(@_element)
@elementInDOM = false
if @__pendingElementAppend
Utils.domCompleteCancel(@__pendingElementAppend)
View
@@ -892,6 +892,11 @@ class exports.Layer extends BaseClass
@bringToFront()
@_context.element.appendChild(@_element)
# This method is called as soon as the @_element is part of the DOM
# If layers are initialized before the DOM is complete,
# the contexts calls this methods on all Layers as soon as it appends itself to the document
elementInsertedIntoDocument: ->
_createHTMLElementIfNeeded: ->
if not @_elementHTML
@_elementHTML = document.createElement "div"

0 comments on commit c404ded

Please sign in to comment.