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

What is Framer? Join the Community
Return to index
Matt Reyer
Posted Jun 27 - Read on Facebook

Is it possible to remove an event listener from a layer?

For example, if i call layer.on(Events.Click, function(){ ... }); at the beginning, can I remove it later?

6 Comments

Koen Bok

Yes, just use layer.off(Events.Click, function(){ ... });

Johannes Eckert

What can you use the callback function in .off for?

Koen Bok

You want to pass the one you _don't_ want to listen to anymore.

Johannes Eckert

Huh? I always just write layer.off(Events.Click) if I remember correctly and that was always enough to stop all events. What's the difference?

Koen Bok

Multiple functions can listen to a single event. So you remove them all by not passing a specific function. Not a problem if there is only one (often).

Johannes Eckert

I see. Clever.

Read the entire post on Facebook