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

What is Framer? Join the Community
Return to index
Emin İnanç Ünlü
Posted Apr 21 - Read on Facebook

As I see, layer.copy() doesn't copy the events the layer has. Do you have any workaround for that? I need to duplicate a group of layers with their events attached to but couldn't do that.

6 Comments

Ben Rodenhäuser
Emin İnanç Ünlü

Hey thanks Ben Rodenhäuser, this would work for some cases but in my case the view group is really complex and it's hard to do that in this way.

Chris Camargo

Emin, why would it be hard to do this way? You said you need to duplicate a group of layers... Are they already grouped in some logical way? Stored in an array? If not, you can add them to an array, and loop over its contents, applying that function to each layer you're copying.

Chris Camargo

I guess my next question would be: How are you latching on to them to make copies? Could you not use the same method to also attach the event as Ben's shown?

Emin İnanç Ünlü

Chris Camargo, It's a bit long to describe. But when I was writing it, you made me think maybe it can be still managed. So I will experiment on it some first and then let you know, thanks. : )

Jörg Lehmann

You can use a custom class that extends Layer, and define the events within the Class:

http://share.framerjs.com/fzl0s03a5lie/

Read the entire post on Facebook