I'm building a function that's supposed to let a layer work like an on and off switch, dropping every layer that is higher than it in the array and then, when clicked again, return all the layers to their original position. I managed to make it target the right layers when turning it on, but I can't get it turn off (close back) Can someone please point me in the right direction to get this code to work. Thank you.
layers=[]
layerNames=[]
indexL=0
for i in [0...5]
layer=layers[i]=new Layer
y:230*i
do (layers,i)->
clickD=false
layers[i].onClick ->
for l,index in layers
if @.index<l.index
layers[index].animate
properties:
y:230*index+300
clickD=true
else if @.index<l.index and clickD!=false
layers[index].animate
properties:
y:230*index
else
layers[index].animate
properties:
y:230*index
Framer link:https://framer.cloud/xcxXg/