Skip to content

Commit

Permalink
Merge pull request #393 from koenbok/feature/midX-midY
Browse files Browse the repository at this point in the history
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 9cf0155
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions framer/Utils.coffee
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/tests/LayerTest.coffee
Expand Up @@ -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
Expand Down

0 comments on commit 9cf0155

Please sign in to comment.