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

What is Framer? Join the Community
Return to index
Rohan K
Posted Feb 07 - Read on Facebook

I have created a class by extending layer, so the objects of this class have all the same properties as layers plus a few extras. Is it possible to convert layers imported using sketch to objects of my class? I want to do this so i can avoid having to specify properties like x,y,image, height, width for layers as sketch already defines those.

3 Comments

Jordan Robert Dobson

You might be able to use the JSON created from an import and apply to your layers.

Also Isaac share with me a way that he is modifying layers that might help you out... he's doing it for animation however.

Isaac Weinhausen

I wrote a method for the Layer object that'll recursively traverse your imported layers. I used it for setting up hierarchical layer references (Framer creates an object with the layers you import, but the reference structure is flat. This is fine in most cases, but sometimes you want to explicitly reference a layer via it's parent-child relationship.)... Anyways, you could use this manipulating each layer imported from Sketch. https://gist.github.com/isaacw/86f820aae18b8fb5d350f334caf6a2a4

Andreas Wahlström

Depending on what you're trying to achieve, maybe this could help: https://github.com/awt2542/createClass-for-Framer

Read the entire post on Facebook