mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Define Item#style before calling #addChild() in #initialize(), to avoid issues with layers.
This commit is contained in:
parent
a3114e5c28
commit
7cf4591a1e
1 changed files with 4 additions and 4 deletions
|
@ -71,19 +71,20 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
_initialize: function(props, point) {
|
||||
// Define this Item's unique id. But allow the creation of internally
|
||||
// used paths with no ids.
|
||||
var internal = props && props.internal === true;
|
||||
var internal = props && props.internal === true,
|
||||
matrix = this._matrix = new Matrix();
|
||||
project = paper.project;
|
||||
if (!internal)
|
||||
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;
|
||||
this._style = new Style(project._currentStyle, 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) {
|
||||
var project = paper.project;
|
||||
// Do not insert into DOM if it's an internal path or
|
||||
// props.insert is false.
|
||||
if (internal || props && props.insert === false) {
|
||||
|
@ -94,7 +95,6 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
(project.activeLayer || new Layer()).addChild(this);
|
||||
}
|
||||
}
|
||||
this._style = new Style(this._project._currentStyle, this);
|
||||
return props ? this._set(props, { insert: true }) : true;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue