Permalink
Browse files

Add layer.perspective, layer.point

  • Loading branch information...
koenbok committed Oct 6, 2014
1 parent 2db13aa commit 00ab257f278607632efe820e63d1f3ca36bf5462
Showing with 34 additions and 3 deletions.
  1. +0 −1 framer/Config.coffee
  2. +23 −2 framer/Layer.coffee
  3. +3 −0 framer/LayerStyle.coffee
  4. +8 −0 test/tests/LayerTest.coffee
View
@@ -23,7 +23,6 @@ body {
-webkit-overflow-scrolling: touch;
-webkit-box-sizing: border-box;
-webkit-user-select: none;
-webkit-perspective: 1000;
}
.framerLayer input,
View
@@ -145,6 +145,8 @@ class exports.Layer extends BaseClass
@define "originY", layerProperty @, "originY", "webkitTransformOrigin", 0.5, _.isNumber
# @define "originZ", layerProperty @, "originZ", "WebkitTransformOrigin", 0.5
@define "perspective", layerProperty @, "perspective", "webkitPerspective", 0, _.isNumber
@define "rotationX", layerProperty @, "rotationX", "webkitTransform", 0, _.isNumber
@define "rotationY", layerProperty @, "rotationY", "webkitTransform", 0, _.isNumber
@define "rotationZ", layerProperty @, "rotationZ", "webkitTransform", 0, _.isNumber
@@ -216,13 +218,20 @@ class exports.Layer extends BaseClass
##############################################################
# Geometry
@define "point",
get: -> _.pick(@, ["x", "y"])
set: (point) ->
return if not point
for k in ["x", "y"]
@[k] = point[k] if point.hasOwnProperty(k)
@define "frame",
get: -> _.pick(@, ["x", "y", "width", "height"])
set: (frame) ->
return if not frame
for k in ["x", "y", "width", "height"]
if frame.hasOwnProperty(k)
@[k] = frame[k]
@[k] = frame[k] if frame.hasOwnProperty(k)
@define "minX",
get: -> @x
@@ -570,6 +579,16 @@ class exports.Layer extends BaseClass
_.filter @_context._animationList, (animation) =>
animation.options.layer == @
animatingProperties: ->
properties = {}
for animation in @animations()
for propertyName in _.keys(animation._stateA)
properties[propertyName] = animation
return properties
animateStop: ->
_.invoke(@animations(), "stop")
@@ -613,6 +632,8 @@ class exports.Layer extends BaseClass
get: ->
@_draggable ?= new LayerDraggable @
@_draggable
set: ->
throw Error "You can't set the draggable object"
##############################################################
## SCROLLING
View
@@ -126,6 +126,9 @@ exports.LayerStyle =
# Todo: Origin z is in pixels. I need to read up on this.
# "#{layer._properties.originX * 100}% #{layer._properties.originY * 100}% #{layer._properties.originZ * 100}%"
webkitPerspective: (layer) ->
"#{layer._properties.perspective}"
pointerEvents: (layer) ->
if layer._properties.ignoreEvents
return "none"
@@ -262,6 +262,14 @@ describe "Layer", ->
testBorderRadius(layer, "50%")
it "should set perspective", ->
layer = new Layer
layer.perspective = 500
layer.style["-webkit-perspective"].should.equal("500")
describe "Filter Properties", ->

0 comments on commit 00ab257

Please sign in to comment.