This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Daniel Caine
Posted Dec 04 - Read on Facebook

Hi guys,

I'm not the greatest at Javascript (understatement), and I'm trying to figure out how to loop through an existing layer group, and re-create the individual groups, up to a certain point.

The code below shows how to create new layers which run vertically down a newsfeed:

# Create and style the cards within a for-loop
for i in [0...10]
layer = new Layer
backgroundColor: "#fff",
width: scroll.width - 48, height: 400
x: 24, y: (400 + 32) * i
borderRadius: 6, superLayer: scroll.content

layer.style.boxShadow = "0 1px 6px rgba(0,0,0,0.2)"

But I'm looking at removing the styling code and simply re-insert an existing layer group which has been imported from Sketch.

Any ideas?

Thanks!

4 Comments

Sergey Voronov

check this http://share.framerjs.com/6r81oilqfdan/ i was importing from sketch, then playing with sublayers in parent layer via loop - for child in sketch.contactList.subLayers
child.scale=Utils.modulate(child.screenFrame.y,[0,400],[0.8,1],true)

Sergey Voronov

at slack it will be easier to help - there we can share snippets and more people sitting online helping each other https://framer-slack-signup.herokuapp.com

Daniel Caine

Ok thing I just messaged you. @mamezito, right?

Sergey Voronov

yeap

Read the entire post on Facebook