Permalink
Browse files

Fixed midpoint and added some tests

  • Loading branch information...
nvh committed Jan 18, 2018
1 parent fed1f13 commit 6d165dd8637db730251febb172d25d5073f57b84
Showing with 48 additions and 6 deletions.
  1. +8 −6 framer/Layer.coffee
  2. +40 −0 test/tests/LayerTest.coffee
View
@@ -520,12 +520,14 @@ class exports.Layer extends BaseClass
x: @midX
y: @midY
set: (input) ->
if input.x?
input.midX = input.x
delete input.x
if input.y?
input.midY = input.y
delete input.y
if not _.isNumber input
input = _.pick(input, ["x", "y", "midX", "midY"])
if input.x? and not input.midX?
input.midX = input.x
delete input.x
if input.y? and not input.midY?
input.midY = input.y
delete input.y
input = layerPropertyPointTransformer(input, @, "midPoint")
@_setGeometryValues(input, ["midX", "midY"])
@@ -1544,6 +1544,46 @@ describe "Layer", ->
layerA.x.should.equal 137
layerA.y.should.equal 283
describe "midPoint", ->
it "should accept a midX/midY value", ->
l = new Layer
midPoint:
midX: 123
midY: 459
l.midX.should.equal 123
l.midY.should.equal 459
it "should accept a x/y value", ->
l = new Layer
midPoint:
x: 123
y: 459
l.midX.should.equal 123
l.midY.should.equal 459
it "should accept a single number", ->
l = new Layer
midPoint: 234
l.midX.should.equal 234
l.midY.should.equal 234
it "should pick midX/midY over x/y", ->
l = new Layer
midPoint:
midX: 123
midY: 459
x: 653
y: 97
l.midX.should.equal 123
l.midY.should.equal 459
it "should not change the object passed in", ->
l =
x: 100
y: 200
m = new Layer
midPoint: l
m.midX.should.equal l.x
m.midY.should.equal l.y
l.x.should.equal 100
l.y.should.equal 200
describe "CSS", ->
it "classList should work", ->

0 comments on commit 6d165dd

Please sign in to comment.