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

What is Framer? Join the Community
Return to index
Black Ray
Posted Sep 15 - Read on Facebook

A question about #Module & #CoffeeScript.
Is it possible to add a custom properties for Layer?
Thanks!

15 Comments

Alexis Morin

Subclassing is an option.

Irwansyah

layerA.style =
border: "5px solid red"

Angus Zhu

Just layerA.someProperty

Irwansyah

Fardin Shikhiyev it is CoffeeScript, influenced a lot by Python

Jordan Robert Dobson

The best path is the custom property that was just added.

Jordan Robert Dobson

foo = new Layer width: 10, custom: bar: 400, bat: 42

Jordan Robert Dobson

So in your example...

layerA = new Layer
x: 100
custom:
border: "5px solid red"

That's using the new custom property that gets tracked in the class constructor.

Works with .copy() too.

Chris Camargo

Is there documentation for layer.custom yet?

Jordan Robert Dobson

No. I don't think they are planning on pushing it out publicly. It think they will just be recommending it if people ask.

Mike Feldstein

It looks like Black Ray is expecting this to actually change the border, which the new 'custom' property wont' do. The custom property is just for storing data to use later. If you want to actually set a CSS Style like border, you need to do it in a separate call, as Irwansyah mentioned above: layer.style = border: "5px solid red"

Black Ray

WOW! That's an undocumented feature, like we just found a hidden gem!

Black Ray

Jordan Robert Dobson Mike Feldstein Irwansyah

Mike Feldstein

im pretty unclear what you're trying to do there. You can wrap everything in the 'custom' property (http://share.framerjs.com/px5ndqqtol5z/), but all those things look like they're trying to be functional. Are you just trying to store these properties for later in a non-functional way?

Irwansyah

You can take out @define function located at BaseClass and modify that function to accept a class so that you can add a property on Layer class and then you can pass the value of that property on the options. Is that you want?

Matthäus Schreder

It works for me like this

Read the entire post on Facebook