Permalink
Browse files

More sensible naming of ScrollComponent instances in layer panel

  • Loading branch information...
nvh committed Aug 1, 2016
1 parent ca22880 commit 15027e5c01dc83d1bde4f15893e265ab9f99b5ad
Showing with 8 additions and 14 deletions.
  1. +3 −8 framer/Components/ScrollComponent.coffee
  2. +5 −6 test/tests/ScrollComponentTest.coffee
@@ -422,7 +422,6 @@ wrapComponent = (instance, layer, options = {correct:true}) ->
if options.correct is true
if layer.children.length is 0 and not isPageComponent
wrapper = new Layer
wrapper.name = instance.constructor.name
wrapper.frame = layer.frame
layer.parent = wrapper
layer.x = layer.y = 0
@@ -434,14 +433,10 @@ wrapComponent = (instance, layer, options = {correct:true}) ->
scroll.parent = layer.parent
scroll.index = layer.index
# Copy over the name
if isPageComponent
scroll.name = instance.constructor.name
else if layer.name and layer.name isnt ""
if layer.name? and not isPageComponent
scroll.name = layer.name
else if layer.__framerInstanceInfo?.name
scroll.__framerInstanceInfo ?= {}
scroll.__framerInstanceInfo?.name = layer.__framerInstanceInfo.name
scroll.__framerInstanceInfo ?= {}
scroll.__framerInstanceInfo?.name = instance.constructor.name
# If we have an image set, it makes way more sense to add it to the
# background of the wrapper then the content.
@@ -107,21 +107,21 @@ describe "ScrollComponent", ->
scroll = new ScrollComponent()
scroll.content.clip.should.equal true
it "should copy over __framerInstanceInfo", ->
it "should set the name of the constructor to __framerInstanceInfo", ->
aap = new Layer
aap.__framerInstanceInfo = {name: "aap"}
bla = new Layer
parent: aap
scroll = ScrollComponent.wrap(aap)
scroll.__framerInstanceInfo.name.should.equal "aap"
scroll.__framerInstanceInfo.name.should.equal "ScrollComponent"
it "should not copy over framerInstanceInfo to name", ->
aap = new Layer
aap.__framerInstanceInfo = {name: "aap"}
bla = new Layer
parent: aap
scroll = ScrollComponent.wrap(aap)
scroll.name.should.not.equal "aap"
scroll.name.should.equal ""
it "should set the right content size for added pages by constructor", ->
@@ -141,11 +141,10 @@ describe "ScrollComponent", ->
contentInset: {top: 267, right: imgWrapGut}
for i in [1..numImg]
imgWrapper = new Layer
width: page.width - imgWrapGut, height: imgWrapW
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 15027e5

Please sign in to comment.