Skip to content

Commit

Permalink
Merge branch 'master' of github.com:koenbok/Framer
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Mar 31, 2016
2 parents 0c1d135 + c264dd8 commit 5c1930f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
20 changes: 9 additions & 11 deletions framer/Layer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class exports.Layer extends BaseClass

# Private setting for canceling of click event if wrapped in moved draggable
@_cancelClickEventInDragSession = true
@_cancelClickEventInDragSessionVelocity = 0.1

# We have to create the element before we set the defaults
@_createElement()
Expand Down Expand Up @@ -608,16 +609,10 @@ class exports.Layer extends BaseClass
if currentValue == value
return @emit "load"

# Todo: this is not very nice but I wanted to have it fixed
# defaults = Defaults.getDefaults "Layer", {}

# console.log defaults.backgroundColor
# console.log @_defaultValues?.backgroundColor

# if defaults.backgroundColor == @_defaultValues?.backgroundColor
# @backgroundColor = null

@backgroundColor = null
# Unset the background color only if it’s the default color
defaults = Defaults.getDefaults "Layer", {}
if @backgroundColor?.isEqual(defaults.backgroundColor)
@backgroundColor = null

# Set the property value
@_setPropertyValue("image", value)
Expand Down Expand Up @@ -944,7 +939,10 @@ class exports.Layer extends BaseClass
if eventName in [Events.Click,
Events.Tap, Events.TapStart, Events.TapEnd,
Events.LongPress, Events.LongPressStart, Events.LongPressEnd]
return if @_parentDraggableLayer()?.draggable.isMoving
if @_parentDraggableLayer()
velocity = @_parentDraggableLayer()?.draggable.velocity
return if Math.abs(velocity.x) > @_cancelClickEventInDragSessionVelocity
return if Math.abs(velocity.y) > @_cancelClickEventInDragSessionVelocity

# Always scope the event this to the layer and pass the layer as
# last argument for every event.
Expand Down
38 changes: 16 additions & 22 deletions test/tests/LayerTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,28 @@ describe "Layer", ->
layer.name.should.equal "Test"
layer._element.getAttribute("name").should.equal "Test"

# it "should handle background color with image", ->
it "should handle background color with image", ->

# # We want the background color to be there until an images
# # is set UNLESS we set another backgroundColor explicitly
# We want the background color to be there until an images
# is set UNLESS we set another backgroundColor explicitly

# imagePath = "static/test.png"

# layer = new Layer image:imagePath
# layer.backgroundColor.should.equal ""

# layer = new Layer
# layer.image = imagePath
# layer.backgroundColor.should.equal ""
imagePath = "../static/test.png"

# layer = new Layer backgroundColor:"rgba(255,0,0,1)"
# layer.image = imagePath
# layer.backgroundColor = "rgba(255,0,0,1)"
# layer.backgroundColor.should.not.equal ""
layer = new Layer image:imagePath
assert.equal layer.backgroundColor.color, null

# layer = new Layer backgroundColor:"red"
# layer.image = imagePath
# layer.backgroundColor.should.equal "red"
layer = new Layer
layer.image = imagePath
assert.equal layer.backgroundColor.color, null

# layer = new Layer
# layer.backgroundColor = "red"
# layer.image = imagePath
# layer.backgroundColor.should.equal "red"
layer = new Layer backgroundColor:"red"
layer.image = imagePath
Color.equal(layer.backgroundColor, new Color("red")).should.be.true

layer = new Layer
layer.backgroundColor = "red"
layer.image = imagePath
Color.equal(layer.backgroundColor, new Color("red")).should.be.true

it "should set visible", ->

Expand Down

0 comments on commit 5c1930f

Please sign in to comment.