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

What is Framer? Join the Community
Return to index
Chris Camargo
Posted Nov 05 - Read on Facebook

*SOLVED* Hi folks! Total Framer JS newbie here. First question: I've setup a layer with a series of states. I have a button that triggers the first state change, and I'd like each state change after that to be triggered automatically, until all states have been exhausted.

The problem I have is that using something like:

layerA.on Events.AnimationEnd, ->
layerA.states.next()

will produce a never-ending loop. Any suggestions on how I can run through the states, then stop once it's reached the final state?

6 Comments

Brandon Souba
Brandon Souba

Here is one that ends after the animations are complete:

Chris Camargo

Thank you so much, Brandon! Didn't realize I could specify the state when calling next(), but putting this together with the documentation, your solution makes sense; just limit the array to the state you want next! :D

Brandon Souba

No worries, sure there is a cleaner way, but this is fairly straightforward

Chris Camargo

True. This approach useful when you only need to worry about a handful of states (my case). This could get a lot uglier as more states are added.

Read the entire post on Facebook