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

What is Framer? Join the Community
Return to index
Fran Pérez
Posted Nov 26 - Read on Facebook

This is driving me crazy: I have a simple loop animation triggered by a toggle action, so click it would start the loop and click it again would stop it. My problem is that I can't figure out how to stop the loop… any ideas?

8 Comments

Koen Bok

I was trying to make a good example but there is definitely a bug here that I need to look into. In your example, one thing you shouldn't do is keep adding "end" events to an animation with every start because they will all get called.

Koen Bok

I'll look into this a bit more and get back to you.

Fran Pérez

Oh nice, thank you. I couldn't figure what was happening :)

Gadzhi Kharkharov

One way to do this (not sure if it's best) would be to define a true/false variable before your function and add if statements inside your animation function. Then you can switch the true/false state of that variable with your utils.cycle.

Fran Pérez

Yes Gadzhi, that is also a good alternative, but I'd like to keep the code complexity as simple as possible. Let's hope Koen fix it soon :)

Koen Bok

Even with a change in Framer you won't really get around Ghadzis suggestion I think.

Fran Pérez

Koen sorry, I don't understand what you mean…

Koen Bok

Sorry. If you listen for the end event of an animation it's forever until you unlisten. So instead of starting the next animation immediately you want to check if the animation is still looping with a variable like Gadzhi suggests.

Read the entire post on Facebook