Commit ad21712f authored by Ryan LeFevre's avatar Ryan LeFevre

Change children to a function for consistency

parent 33021c04
......@@ -8,4 +8,4 @@ console.log(psd.header.export());
// console.log("Finished!");
// });
console.log(psd.tree().children[0].children[0].nextSibling().export());
\ No newline at end of file
console.log(psd.tree().children()[0].children()[0].nextSibling().export());
\ No newline at end of file
......@@ -10,7 +10,7 @@ module.exports = class Node extends Module
constructor: (@layer, @parent = null) ->
@layer.node = @
@children = []
@_children = []
@name = @layer.name
......@@ -82,11 +82,11 @@ module.exports = class Node extends Module
updateDimensions: ->
return if @isLayer()
child.updateDimensions() for child in @children
child.updateDimensions() for child in @_children
return if @isRoot()
nonEmptyChildren = @children.filter((c) -> not c.isEmpty())
nonEmptyChildren = @_children.filter((c) -> not c.isEmpty())
@left = _.min(nonEmptyChildren.map((c) -> c.left)) or 0
@top = _.min(nonEmptyChildren.map((c) -> c.top)) or 0
@bottom = _.max(nonEmptyChildren.map((c) -> c.bottom)) or 0
......
......@@ -7,16 +7,18 @@ module.exports =
isRoot: -> @depth() is 0
children: -> @_children
ancestors: ->
return [] if not @parent? or @parent.isRoot()
return @parent.ancestors().concat [@parent]
hasChildren: -> @children.length > 0
hasChildren: -> @_children.length > 0
childless: -> not @hasChildren()
siblings: ->
return [] unless @parent?
@parent.children
@parent.children()
nextSibling: ->
return null unless @parent?
......@@ -31,7 +33,7 @@ module.exports =
hasSiblings: -> @siblings().length > 1
onlyChild: -> not @hasSiblings()
descendants: -> _.flatten @children.map((n) -> n.subtree())
descendants: -> _.flatten @_children.map((n) -> n.subtree())
subtree: -> [@].concat @descendants()
......
......@@ -8,9 +8,9 @@ module.exports = class Group extends Node
@get('blendingMode') is 'passthru'
isEmpty: ->
return false unless child.isEmpty() for child in @children
return false unless child.isEmpty() for child in @_children
export: ->
_.merge super(),
type: 'group'
children: @children.map((c) -> c.export())
\ No newline at end of file
children: @_children.map((c) -> c.export())
\ No newline at end of file
......@@ -30,7 +30,7 @@ module.exports = class Root extends Node
fillOpacity: -> 255
export: ->
children: @children.map((c) -> c.export())
children: @_children.map((c) -> c.export())
document:
width: @width
height: @height
......@@ -50,9 +50,9 @@ module.exports = class Root extends Node
currentGroup = new Group(layer, _.last(parseStack))
else if layer.isFolderEnd()
parent = parseStack.pop()
parent.children.push currentGroup
parent.children().push currentGroup
currentGroup = parent
else
currentGroup.children.push new Layer(layer, currentGroup)
currentGroup.children().push new Layer(layer, currentGroup)
@updateDimensions()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment