mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Found a clean way for Layer#initialize() to call this.base() too, without implicitely calling paper.project.activeLayer.appendTop.
This commit is contained in:
parent
9f1172f24a
commit
b461368b18
3 changed files with 9 additions and 9 deletions
|
@ -18,7 +18,10 @@ var Item = this.Item = Base.extend({
|
|||
beans: true,
|
||||
|
||||
initialize: function() {
|
||||
paper.project.activeLayer.appendTop(this);
|
||||
// If _project is already set, the item was already moved into the DOM
|
||||
// hierarchy. Used by Layer, where it's added to project.layers instead
|
||||
if (!this._project)
|
||||
paper.project.activeLayer.appendTop(this);
|
||||
this._style = PathStyle.create(this);
|
||||
this.setStyle(this._project.getCurrentStyle());
|
||||
},
|
||||
|
|
|
@ -17,14 +17,11 @@
|
|||
var Layer = this.Layer = Group.extend({
|
||||
beans: true,
|
||||
|
||||
initialize: function() {
|
||||
// TODO: Isn't there a way to call this.base() here and then move the
|
||||
// layer into layers instead?
|
||||
this._children = [];
|
||||
this._namedChildren = {};
|
||||
initialize: function(items) {
|
||||
this._project = paper.project;
|
||||
// Push it onto project.layers and set index:
|
||||
this._index = this._project.layers.push(this) - 1;
|
||||
this.base.apply(this, arguments);
|
||||
this.activate();
|
||||
},
|
||||
|
||||
|
|
|
@ -23,15 +23,15 @@ var Project = this.Project = Base.extend({
|
|||
this._scope = paper;
|
||||
// Push it onto this._scope.projects and set index:
|
||||
this._index = this._scope.projects.push(this) - 1;
|
||||
this._currentStyle = PathStyle.create(null);
|
||||
this._selectedItems = {};
|
||||
this._selectedItemCount = 0;
|
||||
// Activate straight away so paper.project is set, as required by
|
||||
// Layer and DoumentView constructors.
|
||||
this.activate();
|
||||
this.layers = [];
|
||||
this.symbols = [];
|
||||
this.activeLayer = new Layer();
|
||||
this._selectedItems = {};
|
||||
this._selectedItemCount = 0;
|
||||
this._currentStyle = PathStyle.create(null);
|
||||
},
|
||||
|
||||
getCurrentStyle: function() {
|
||||
|
|
Loading…
Reference in a new issue