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

What is Framer? Join the Community
Return to index
Jordan Robert Dobson
Posted Jul 07 - Read on Facebook

Layer Events: Create & Destroy

Example Code:

Joshua Tucker asked me if there was a way to listen for an event when a new layer is created.

I dug around this morning and found a way to listen to create & destroy events for any layer at the root or as a sublayer of another layer. This is helpful for when the "change:subLayers" event won't suffice.

Let me know if you have any questions or concerns... or even better ways to do this reliably.

Click the circle to fire the destroy event.



Jordan Robert Dobson

Make sure to check out the code... and try adding a few layers yourself.

This could be super useful if you wanted to do something to a layer every time one is created. :D


Haven't looked at your source code. But the easiest way maybe by inheriting Framer's layer and then dispatching the event our self.

Jordan Robert Dobson

That's also an option if you want to subclass. Irwansyah.

Jordan Robert Dobson

Check out the source and you'll see it applies to any subclass of Layer

Pete Schaffner

Very nice Jordan Robert Dobson ... bookmarking this one. Thanks for sharing!

Read the entire post on Facebook