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

What is Framer? Join the Community
Return to index
Jon Wood
Posted Feb 12 - Read on Facebook

hey framer fam, I've been running into a programmatic problem for a project. I used a for loop to create 2 types of objects. Where button 1 (red) will animate card 1 (red), so on and so forth for each matching pair.

I know how to animate each layer object within an array, as you can see by tapping white/blue/green elements. I want to animate the card based on the matching button without repeating code. As you can see it somewhat works with the red button/cards.

Any thoughts? Thanks in advance!

2 Comments

Jon Wood

Eric Chao ;) <3

Orfeo Chen

That has something to do with closure in Javascript. Simply put, the code inside the click event handler of button is only evaluated on the event of click. At that time, the variable "i" is already set to 4. Take a look at the fix: https://framer.cloud/MEIoP

Read the entire post on Facebook