0

In Framer Studio (Coffeescript), whenever I click a layer, it's copied into another one (which is kind of a "checklist" layer if you will). I'm trying to append a copied layer right below the previous one that has been clicked. How would you do that ? How do get the previous layer that has been clicked? Is it even possible?

Thank you very much for your help.

Best regards,

1 Answers1

1

I think it could be by two ways.

First way is using subLayers and list of subLayers is relied on time being added.

bg = new BackgroundLayer
upper = new Layer
    width: 750, backgroundColor: "red", superLayer: bg
lower = new Layer
    width: 750, y: 100,     backgroundColor: "blue", superLayer: bg

lower.on Events.Click, (e, layer) ->
    parent = layer.superLayer
    index = parent.subLayers.indexOf layer
    prev = parent.subLayers[index-1] if ~index
    print prev

Another way is more simple. Store layers into array, and find within that.

layers = [new Layer, new Layer(x:150)]
layers[1].on Events.Click, (e, layer) ->
    index = layers.indexOf layer
    prev = layers[index-1] if ~index
    print prev
seoh
  • 353
  • 1
  • 13