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

What is Framer? Join the Community
Return to index
Ethan Miller
Posted Jun 20 - Read on Facebook

It would be great if layer.copy() copied styles as well. Not sure what the rationale is for not copying those, but it would be super useful!

We're working on a project that has a page layout engine with dynamic text, fonts, etc, and we occasionally need to copy pages around.


Eelco Lempsink

Hi Ethan – Good point, I filed an issue for this. For now, you can define a helper function to make a copy including style. See:

Ethan Miller

Ah thanks. I had been trying that approach, but realized all the child objects have styles as well :) I was thinking about making a dupe of the layer.copy() method that adds style blocks as it's copying all the children since it's already doing that loop.

Jordan Robert Dobson

You can always place them in the custom...

Jordan Robert Dobson = {}

Jordan Robert Dobson

those will always get copied.

Ethan Miller

Interesting! I'll try that

Jordan Robert Dobson

Yeah. Store it in there then you always have a reference to it. And then apply what's inside of custom when you need it.

That's the hack is consistently use.

Careful though as I'm not positive if the clone is deep or not. Just make sure you aren't just cloning a reference to an object inside custom but actually cloning the values.

That has tripped me up a few times.

Read the entire post on Facebook