Permalink
Browse files

Merge pull request #373 from koenbok/page-add-fix

ScrollComponent Parent Page Fix
  • Loading branch information...
koenbok committed Jun 30, 2016
2 parents adf5b33 + c434f4f commit 340612e81551afc7ff5961a853e8e023f1b7b44c
@@ -1,19 +0,0 @@
rk4 = new Framer.SpringRK4Animator
friction: 5
tension: 90
values = rk4.values(1/60*2)
# Draw a stupid graph
graph = new Layer
point: Align.center
for index, value of values
new Layer
parent: graph
size: 6
borderRadius: 6
x: parseInt(index) * (graph.width / values.length)
y: value * (graph.height / 2)
@@ -9,8 +9,8 @@
"selectedHand" : "",
"updateDelay" : 0.3,
"deviceScale" : 1,
"codeFolds" : [
"{91, 233}"
"foldedCodeRanges" : [
],
"orientation" : 0
}
@@ -105,17 +105,17 @@ class exports.Layer extends BaseClass
layerPropertyIgnore(options, "size", ["width", "height"])
layerPropertyIgnore(options, "frame", ["x", "y", "width", "height"])
# Backwards compatibility for superLayer
if not options.hasOwnProperty("parent") and options.hasOwnProperty("superLayer")
options.parent = options.superLayer
delete options.superLayer
super Defaults.getDefaults("Layer", options)
# Add this layer to the current context
@_context.addLayer(@)
@_id = @_context.layerCounter
# Backwards compatibility for superLayer
if not options.parent and options.hasOwnProperty("superLayer")
options.parent = options.superLayer
# Insert the layer into the dom or the parent element
if not options.parent
@_insertElement() if not options.shadow
@@ -167,9 +167,9 @@ class exports.Layer extends BaseClass
# Matrix properties
@define "x", layerProperty(@, "x", "webkitTransform", 0, _.isNumber,
layerPropertyPointTransformer, {depends: ["width", "height", "parent"]})
layerPropertyPointTransformer, {depends: ["width", "height"]})
@define "y", layerProperty(@, "y", "webkitTransform", 0, _.isNumber,
layerPropertyPointTransformer, {depends: ["width", "height", "parent"]})
layerPropertyPointTransformer, {depends: ["width", "height"]})
@define "z", layerProperty(@, "z", "webkitTransform", 0, _.isNumber)
@define "scaleX", layerProperty(@, "scaleX", "webkitTransform", 1, _.isNumber)
@@ -291,7 +291,7 @@ class exports.Layer extends BaseClass
# matrix of layer transforms with perspective applied
@define "matrix3d",
get: ->
parent = @superLayer or @context
parent = @parent or @context
ppm = Utils.perspectiveMatrix(parent)
return new Matrix()
.multiply(ppm)
@@ -436,8 +436,8 @@ class exports.Layer extends BaseClass
# Get the centered frame for its parent
if @parent
frame = @frame
Utils.frameSetMidX(frame, parseInt((@parent.width / 2.0) - @superLayer.borderWidth))
Utils.frameSetMidY(frame, parseInt((@parent.height / 2.0) - @superLayer.borderWidth))
Utils.frameSetMidX(frame, parseInt((@parent.width / 2.0) - @parent.borderWidth))
Utils.frameSetMidY(frame, parseInt((@parent.height / 2.0) - @parent.borderWidth))
return frame
else
frame = @frame
@@ -714,7 +714,7 @@ class exports.Layer extends BaseClass
throw Error "Layer.parent needs to be a Layer object"
# Cancel previous pending insertions
Utils.domCompleteCancel @__insertElement
Utils.domCompleteCancel(@__insertElement)
# Remove from previous parent children
if @_parent
@@ -106,3 +106,29 @@ describe "ScrollComponent", ->
it "should set content clip to true", ->
scroll = new ScrollComponent()
scroll.content.clip.should.equal true
it "should set the right content size for added pages by constructor", ->
# Constructors depend on different things for size, align and parent. Sometimes
# these dependencies can get messed up when adding something to a ScrollComponent
# this a was a case sent in by one of our users: http://share.framerjs.com/mn3ffub6u81i/
allImgCont = []
imgWrapW = 801
imgWrapGut = 200
numImg = 2
page = new PageComponent
width: 400, height: 400
scrollVertical: false
contentInset: {top: 267, right: imgWrapGut}
for i in [1..numImg]
imgWrapper = new Layer
width: page.width - imgWrapGut, height: imgWrapW
borderRadius: 8
x: (page.width + 32) * i
parent: page.content
page.contentFrame().width.should.equal 1064

0 comments on commit 340612e

Please sign in to comment.