diff --git a/src/document/Document.js b/src/document/Document.js index 60ad0313..7b67cab4 100644 --- a/src/document/Document.js +++ b/src/document/Document.js @@ -59,8 +59,8 @@ var Document = this.Document = Base.extend({ this.bounds = Rectangle.create(0, 0, this._size.width, this._size.height); this.context = this.canvas.getContext('2d'); - // Push it onto paper.documents and adjust index in one: - Base.splice(paper.documents, [this]); + // Push it onto paper.documents and set index: + this._index = paper.documents.push(this) - 1; this.activate(); this.layers = []; this.activeLayer = new Layer(); diff --git a/src/item/Layer.js b/src/item/Layer.js index faaa7a52..f2e17549 100644 --- a/src/item/Layer.js +++ b/src/item/Layer.js @@ -20,8 +20,8 @@ var Layer = this.Layer = Group.extend({ initialize: function() { this.children = []; this._document = paper.document; - // Push it onto document.layers and adjust index in one: - Base.splice(this._document.layers, [this]); + // Push it onto document.layers and set index: + this._index = this._document.layers.push(this) - 1; this.activate(); },