Permalink
Browse files

Merge pull request #393 from koenbok/feature/midX-midY

Change midX and midY to be at x and y when frame is 0
  • Loading branch information...
koenbok committed Aug 1, 2016
2 parents 582615b + 8097d79 commit 9cf0155ddc7e5e8fd0ff0445c09e91fb4efd4045
Showing with 14 additions and 4 deletions.
  1. +4 −4 framer/Utils.coffee
  2. +10 −0 test/tests/LayerTest.coffee
View
@@ -772,9 +772,9 @@ Utils.frameGetMinX = (frame) -> frame.x
Utils.frameSetMinX = (frame, value) -> frame.x = value
Utils.frameGetMidX = (frame) ->
if frame.width is 0 then 0 else frame.x + (frame.width / 2.0)
if frame.width is 0 then frame.x else frame.x + (frame.width / 2.0)
Utils.frameSetMidX = (frame, value) ->
frame.x = if frame.width is 0 then 0 else value - (frame.width / 2.0)
frame.x = if frame.width is 0 then value else value - (frame.width / 2.0)
Utils.frameGetMaxX = (frame) ->
if frame.width is 0 then 0 else frame.x + frame.width
@@ -785,9 +785,9 @@ Utils.frameGetMinY = (frame) -> frame.y
Utils.frameSetMinY = (frame, value) -> frame.y = value
Utils.frameGetMidY = (frame) ->
if frame.height is 0 then 0 else frame.y + (frame.height / 2.0)
if frame.height is 0 then frame.y else frame.y + (frame.height / 2.0)
Utils.frameSetMidY = (frame, value) ->
frame.y = if frame.height is 0 then 0 else value - (frame.height / 2.0)
frame.y = if frame.height is 0 then value else value - (frame.height / 2.0)
Utils.frameGetMaxY = (frame) ->
if frame.height is 0 then 0 else frame.y + frame.height
@@ -146,6 +146,16 @@ describe "Layer", ->
# layer.style.webkitTransform.should.equal "matrix(1, 0, 0, 1, 100, 0)"
layer.style.webkitTransform.should.equal "translate3d(100px, 50px, 0px) scale3d(1, 1, 1) skew(0deg, 0deg) skewX(0deg) skewY(0deg) translateZ(0px) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translateZ(0px)"
it "should handle midX and midY when width and height are 0", ->
box = new Layer
midX:200
midY:300
width: 0
height: 0
box.x.should.equal 200
box.y.should.equal 300
it "should set scale", ->
layer = new Layer

0 comments on commit 9cf0155

Please sign in to comment.