mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Define Item ids immediately, not on first request.
This commit is contained in:
parent
4748bb48e8
commit
1ed6d46ce3
1 changed files with 6 additions and 3 deletions
|
@ -26,6 +26,8 @@
|
|||
*/
|
||||
var Item = this.Item = Base.extend(/** @lends Item# */{
|
||||
initialize: function() {
|
||||
// Define this Item's unique id.
|
||||
this._id = ++Item._id;
|
||||
// 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)
|
||||
|
@ -59,8 +61,6 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
|
|||
* @bean
|
||||
*/
|
||||
getId: function() {
|
||||
if (this._id == null)
|
||||
this._id = Item._id = (Item._id || 0) + 1;
|
||||
return this._id;
|
||||
},
|
||||
|
||||
|
@ -197,8 +197,11 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
|
|||
|
||||
setStyle: function(style) {
|
||||
this._style.initialize(style);
|
||||
}
|
||||
},
|
||||
|
||||
statics: {
|
||||
_id: 0
|
||||
}
|
||||
}, new function() { // Injection scope to produce getter setters for properties
|
||||
// We need setters because we want to call _changed() if a property was
|
||||
// modified.
|
||||
|
|
Loading…
Reference in a new issue