mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Avoid issues with _matrix being undefined when items are created and added in a certain sequence.
Closes #279.
This commit is contained in:
parent
fc02c58ddb
commit
550749d057
1 changed files with 6 additions and 4 deletions
|
@ -69,6 +69,12 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
_initialize: function(props, point) {
|
_initialize: function(props, point) {
|
||||||
// Define this Item's unique id.
|
// Define this Item's unique id.
|
||||||
this._id = Item._id = (Item._id || 0) + 1;
|
this._id = Item._id = (Item._id || 0) + 1;
|
||||||
|
// Handle matrix before everything else, to avoid issues with
|
||||||
|
// #addChild() calling _changed() and accessing _matrix already.
|
||||||
|
var matrix = this._matrix = new Matrix();
|
||||||
|
if (point)
|
||||||
|
matrix.translate(point);
|
||||||
|
matrix._owner = this;
|
||||||
// If _project is already set, the item was already moved into the DOM
|
// 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
|
// hierarchy. Used by Layer, where it's added to project.layers instead
|
||||||
if (!this._project) {
|
if (!this._project) {
|
||||||
|
@ -83,10 +89,6 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._style = new Style(this._project._currentStyle, this);
|
this._style = new Style(this._project._currentStyle, this);
|
||||||
var matrix = this._matrix = new Matrix();
|
|
||||||
if (point)
|
|
||||||
matrix.translate(point);
|
|
||||||
matrix._owner = this;
|
|
||||||
return props ? this._set(props, { insert: true }) : true;
|
return props ? this._set(props, { insert: true }) : true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue