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

What is Framer? Join the Community
Return to index
Ed Lea
Posted Aug 14 - Read on Facebook

I'd like to modify values passed in to my Layer class extension. So if I pass in width, I'd like to have a method that multiplies that by a factor that I also pass in.

The idea behind this is that I want to pass @1x values but for Framer to draw them @3x or @2x depending on what device I'm previewing in.

https://gist.github.com/ed-lea/2b079e4319eaacda53b7

8 Comments

Isaac Weinhausen

Nice! I wonder if this is something you could also write as a mixin? Layer is a great example of a class that I'd like to add a little functionality, but would prefer not having to actually extend it. Just a thought. Still trying to wrap my head around OOP in Coffee Script and best practices.

Jordan Robert Dobson

Isaac that's pretty much the way to do it. I don't think there is a way to enhance or monkey patch it.

Jordan Robert Dobson

At least I haven't found a clean way to do the @define get: set: on an existing class. I've looked a few times for ways to go about this too. Let me know if you find anything.

Jordan Robert Dobson

Pete Schaffner - Did you ever find a way to do this?

Pete Schaffner

Isaac: check out my Material module. It exposes both a new class and adds the ability to mixin "Material props" to Layer (or whatever): https://github.com/peteschaffner/framer-material/blob/master/app.coffee#L416

Pete Schaffner
Jordan Robert Dobson

Awesome Pete... Thanks for sharing.

Ed Lea

thanks everyone for the input. I don't think I achieved everything as generically as I had hoped, but for my specific case I'm doing this http://share.framerjs.com/0a1q21466bik/

Read the entire post on Facebook