Permalink
Browse files

Merge branch 'master' of github.com:koenbok/Framer

  • Loading branch information...
koenbok committed Mar 31, 2016
2 parents 0c1d135 + c264dd8 commit 5c1930f443a4ee554ef11fd7457b92dac5a30cb1
Showing with 25 additions and 33 deletions.
  1. +9 −11 framer/Layer.coffee
  2. +16 −22 test/tests/LayerTest.coffee
View
@@ -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()
@@ -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)
@@ -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.
@@ -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", ->

0 comments on commit 5c1930f

Please sign in to comment.