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 Jul 03 - Read on Facebook

How do you guys call an animation (layer.animate) from within an event that is constantly firing, but just once, when certain condition is met for the first time?

I've noticed that when you call an animation repeatedly it behaves oddly :(

7 Comments

Fran Pérez

I know you can use .isAnimating to check, but was wondering if there is a pattern I should be using instead.

Jonas Treub

You could use the once function of lodash: https://lodash.com/docs#once

Jonas Treub

Framer includes lodash

Fran Pérez

Thanks Jonas, will try this :)

Sigurd Tapio Mannsåker

Lodash is awesome :) you could also add a boolean to your layer, essentially mylayer.hasanimated = true, and then mylayer.animate() unless mylayer.hasanimated. If you need it to animate again later, just not immediately, you may also want to consider lodash's debounce/throttle functions. Very handy.

Blaine Billingsley

Does that mean everything in that documentation ships with framer,

Read the entire post on Facebook