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

What is Framer? Join the Community
Return to index
Guus Baggermans
Posted May 20 - Read on Facebook

Hi guys, I'm having trouble with Coffeescript: I want to use the iterator of the loop to reference a layer in an Array. When I print the index it works fine, but when I use it to assign the snapToPage() function it always returns a fixed number. Is there any way to do this?

for button, index in allButtons
# print index
button.on Events.Click, ->
page.snapToPage(pages[index])

2 Comments

Benjamin Den Boer

Hey Guus Baggermans - you could use "this" to check which of the buttons within your allButtons array is being clicked on, and then match that with one of the pages that you'd like to snap to. Works well as long as you aren't working with 10+ pages. :-)

Guus Baggermans

Hey Benjamin, that looks like a nice workaround for now. I built this in the mean time, which is a hack that works because of the way the buttons are spaced :)

Read the entire post on Facebook