Skip to content
Permalink
Browse files

Merge pull request #279 from koenbok/domready-interactive

Change the domReady function to use interactive state
  • Loading branch information
koenbok committed Dec 27, 2015
2 parents cc17f24 + 2487d45 commit 91e8b76e90d93f63c5eef1ff2a14468942510b10
Showing with 5 additions and 4 deletions.
  1. +5 −4 framer/Utils.coffee
@@ -406,24 +406,25 @@ Utils.parseFunction = (str) ->
######################################################
# DOM FUNCTIONS

__domCompleteState = "interactive"
__domComplete = []
__domReady = false

if document?
document.onreadystatechange = (event) =>
if document.readyState is "complete"
document.onreadystatechange = (event) ->
if document.readyState is __domCompleteState
__domReady = true
while __domComplete.length
f = __domComplete.shift()()

Utils.domComplete = (f) ->
if document.readyState is "complete"
if __domReady
f()
else
__domComplete.push(f)

Utils.domCompleteCancel = (f) ->
__domComplete = _.without __domComplete, f
__domComplete = _.without(__domComplete, f)

Utils.domValidEvent = (element, eventName) ->
return if not eventName

0 comments on commit 91e8b76

Please sign in to comment.