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

What is Framer? Join the Community
Return to index
John Marstall
Posted Dec 13 - Read on Facebook

With help from Sigurd Mannsaker, a little explainer demo on the confusing issue of scoping within Framer loops. Figure this out early and you'll have a much better time with Framer.

2 Comments

Niels van Hoorn

Cool! I wrote our documentation on scope (https://framerjs.com/getstarted/programming/#scope), and even I learned something. For the people wondering why index will ever become 2 in the looping of buttonsA, this is the produced javascript code:
var button, i, index, len;

for (index = i = 0, len = buttonsA.length; i < len; index = ++i) {
. button = buttonsA[index];
. print(index);
. button.onClick(function() {
. return print(index);
. });
}
So after the loop index is 2

Jordan Robert Dobson

Woah. Interesting

Read the entire post on Facebook