forked from awt2542/createClass-for-Framer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateClassModule.coffee
30 lines (30 loc) · 1.03 KB
/
createClassModule.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
exports.createClass = (layer, destroy) ->
class Temp extends Layer
constructor: (options={}) ->
options.size ?= layer.size
options.image ?= layer.image
super options
for subLayer in layer.descendants
if subLayer.children.length > 0
@parentItem = new Layer
name: subLayer.name
image: subLayer.image
backgroundColor: subLayer.backgroundColor
frame: subLayer.frame
superLayer: @
for child in subLayer.children
@[child.name] = new Layer
name: child.name
image: child.image
backgroundColor: child.backgroundColor
frame: child.frame
superLayer: @parentItem
else if subLayer.parent is layer
@[subLayer.name] = new Layer
name: subLayer.name
image: subLayer.image
frame: subLayer.frame
backgroundColor: subLayer.backgroundColor
superLayer: @
if destroy is true
layer.destroy()