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

What is Framer? Join the Community
Return to index
Paul Rich
Posted Aug 09 - Read on Facebook

Hey,

how to pass the right index to the method?

for key, index in sketch.keypad.subLayers
key.onTap ->
addAmount(index)

Now is always the last digit of iteration for each sublayers (

1 Comments

Kevyn Arnott

In this case, the event will happen after the loop has finished, so the index will always be the last index. You'll need to store the index for each layer, so that when it's clicked it'll trigger the right amount. To do this write "key.amount = index" before the event inside the loop. Then on the tap event, write "addAmount(@.amount)", and that'll give you the right amount.

Read the entire post on Facebook