Add basic code for fine-grained change tracking, as required by on-the fly SVG DOM manipulation.

This commit is contained in:
Jürg Lehni 2011-09-22 10:32:17 +02:00
parent a2358a0fc0
commit 6052e94a2a
2 changed files with 16 additions and 0 deletions

View file

@ -54,6 +54,19 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
// If this item is a symbol's definition, notify it of the change too
if (this._parentSymbol)
this._parentSymbol._changed(flags);
// Have project keep track of changed items, so they can be iterated.
// This can be used for example to update the SVG tree. Needs to be
// activated in Project
if (this._project._changes) {
var entry = this._project._changesById[this._id];
if (entry) {
entry.flags |= flags;
} else {
entry = { item: this, flags: flags };
this._project._changesById[this._id] = entry;
this._project._changes.push(entry);
}
}
},
/**

View file

@ -55,6 +55,9 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{
this.layers = [];
this.symbols = [];
this.activeLayer = new Layer();
// Change tracking, not in use for now. Activate once required:
// this._changes = [];
// this._changesById = {};
},
_needsRedraw: function() {