Permalink
Browse files

Fix a bug when not providing all values to layer.screenFrame

  • Loading branch information...
nvh committed Mar 6, 2017
1 parent 9223f5c commit db7aea1962634ec6747848e82216c5a5821c4382
Showing with 14 additions and 2 deletions.
  1. +2 −2 framer/Utils.coffee
  2. +12 −0 test/tests/LayerTest.coffee
View
@@ -1014,7 +1014,7 @@ Utils.convertPointToContext = (point = {}, layer, rootContext=false, includeLaye
return point
Utils.convertFrameToContext = (frame = {}, layer, rootContext=false, includeLayer=true) ->
frame = _.defaults(frame, {x: 0, y: 0, width: 100, height: 100})
frame = _.defaults(frame, {x: 0, y: 0, width: Framer.Defaults.Layer.width, height: Framer.Defaults.Layer.height})
corners = Utils.pointsFromFrame(frame)
convertedCorners = corners.map (point) ->
return Utils.convertPointToContext(point, layer, rootContext, includeLayer)
@@ -1045,7 +1045,7 @@ Utils.convertPointFromContext = (point = {}, layer, rootContext=false, includeLa
# convert a frame from the context level to a layer, with rootContext enabled you can make it start from the top context
Utils.convertFrameFromContext = (frame = {}, layer, rootContext=false, includeLayer=true) ->
frame = _.defaults(frame, {x: 0, y: 0, width: 100, height: 100})
frame = _.defaults(frame, {x: 0, y: 0, width: Framer.Defaults.Layer.width, height: Framer.Defaults.Layer.height})
corners = Utils.pointsFromFrame(frame)
convertedCorners = corners.map (point) ->
return Utils.convertPointFromContext(point, layer, rootContext, includeLayer)
@@ -1133,6 +1133,18 @@ describe "Layer", ->
boundingBox.width.should.eql 133
boundingBox.height.should.eql 144
it "should use Framer.Defaults when setting the screen frame", ->
Framer.Defaults.Layer.width = 300
Framer.Defaults.Layer.height = 400
box = new Layer
screenFrame:
x: 123
box.stateCycle()
box.x.should.equal 123
box.width.should.equal 300
box.height.should.equal 400
Framer.resetDefaults()
it "should have the correct canvas frame", ->
layer = new Layer

0 comments on commit db7aea1

Please sign in to comment.