Permalink
Browse files

Merge pull request #261 from koenbok/context-freeze-restore

Context freeze restore, event cleanup.
  • Loading branch information...
koenbok committed Dec 14, 2015
2 parents 605eb08 + daa0919 commit 304f85adeeec29aaec8efafdcd9af69d95cfbd39
@@ -40,7 +40,7 @@ _contextLayer.style.border = "1px solid grey"
run = (options, callback) ->
context = new Framer.Context(name:"TestRun", parentLayer:_contextLayer)
context = new Framer.Context(name:"TestRun", parent:_contextLayer)
context.run -> _run options, (results) ->
context.reset()
callback(results)
@@ -146,8 +146,7 @@ class exports.Animation extends EventEmitter
stop: (emit=true)->
@options.layer._context._animationList = _.without(
@options.layer._context._animationList, @)
@options.layer.context.removeAnimation(@)
@emit("stop") if emit
Framer.Loop.off("update", @_update)
@@ -175,7 +174,7 @@ class exports.Animation extends EventEmitter
_.keys(@_stateA)
_start: =>
@options.layer._context._animationList.push(@)
@options.layer.context.addAnimation(@)
@emit("start")
Framer.Loop.on("update", @_update)
@@ -35,6 +35,9 @@ class exports.AnimationLoop extends EventEmitter
if Utils.webkitVersion() > 600 and Utils.isFramerStudio()
@raf = false
# To avoid event emitter warning
@maximumListeners = Infinity
start: =>
animationLoop = @
@@ -14,13 +14,10 @@ class exports.BackgroundLayer extends Layer
@sendToBack()
@layout()
@_context.eventManager.wrap(window).addEventListener("resize", @layout)
@_context.domEventManager.wrap(window).addEventListener("resize", @layout)
layout: =>
if @superLayer
@frame = {x:0, y:0, width:@superLayer.width, height:@superLayer.height}
else if @_context._parentLayer
@frame = {x:0, y:0, width:@_context._parentLayer.width, height:@_context._parentLayer.height}
@frame = @superLayer.frame
else
@frame = {x:0, y:0, width:window.innerWidth, height:window.innerHeight}
@frame = @_context.frame
@@ -106,13 +106,13 @@ class exports.DeviceComponent extends BaseClass
@keyboardLayer.classList.add("DeviceKeyboard")
@keyboardLayer.backgroundColor = "transparent"
Framer.CurrentContext.eventManager.wrap(window).addEventListener("resize", @_update)
Framer.CurrentContext.domEventManager.wrap(window).addEventListener("resize", @_update)
# This avoids rubber banding on mobile
for layer in [@background, @phone, @viewport, @content, @screen]
layer.on "touchmove", (event) -> event.preventDefault()
@_context = new Framer.Context(parentLayer:@content, name:"Device")
@_context = new Framer.Context(parent:@content, name:"Device")
_update: =>
Oops, something went wrong.

0 comments on commit 304f85a

Please sign in to comment.