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

What is Framer? Join the Community
Return to index
Michael Bing
Posted Apr 27 - Read on Facebook

Hi all. I am trying to create a grid, which is all good. But when i want to add interaction to each block, it says it can't find block variable. What am i doing wrong here.

componentContainer = new Layer
backgroundColor: "transparent"
width: 1427, height: 1048

componentContainer.center()

rows = 3
cols = 4
size = 290
margin = 89

[0...rows].map (rows) ->
[0...cols].map (cols) ->
componentBlock = new Layer
y: rows * (size + margin)
x: cols * (size + margin)
backgroundColor: "white"
width: size
height: size
componentBlock.superLayer = componentContainer

componentBlock[0].on Events.Click, ->
componentBlock.animate
properties: {scale: 2}

5 Comments

Cemre Güngör

the blocks you create are all overwriting each other. you need to do componentblock[rows][cols]=new layer.. you probably need to initialize the arrays though

Jordan Robert Dobson

Before the loop create an empty array. Store them in there at correct indexes.

Balraj Chana
Michael Bing

Thank you so much to all of you. Balraj, you rock ;)

Balraj Chana

You're welcome Michael :)

Read the entire post on Facebook