mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix #991: Make sure items get fully removed in removeChildren()
This commit is contained in:
parent
1cb291690d
commit
9f90659fdb
4 changed files with 19 additions and 10 deletions
|
@ -41,7 +41,7 @@
|
||||||
var connections = new Group();
|
var connections = new Group();
|
||||||
function generateConnections(paths) {
|
function generateConnections(paths) {
|
||||||
// Remove the last connection paths:
|
// Remove the last connection paths:
|
||||||
connections.children = [];
|
connections.removeChildren();
|
||||||
|
|
||||||
for (var i = 0, l = paths.length; i < l; i++) {
|
for (var i = 0, l = paths.length; i < l; i++) {
|
||||||
for (var j = i - 1; j >= 0; j--) {
|
for (var j = i - 1; j >= 0; j--) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDiagram() {
|
function renderDiagram() {
|
||||||
project.activeLayer.children = [];
|
project.activeLayer.removeChildren();
|
||||||
var diagram = voronoi.compute(sites, bbox);
|
var diagram = voronoi.compute(sites, bbox);
|
||||||
if (diagram) {
|
if (diagram) {
|
||||||
for (var i = 0, l = sites.length; i < l; i++) {
|
for (var i = 0, l = sites.length; i < l; i++) {
|
||||||
|
|
|
@ -2528,14 +2528,21 @@ new function() { // Injection scope for hit-test functions shared with project
|
||||||
var owner = this._getOwner(),
|
var owner = this._getOwner(),
|
||||||
project = this._project,
|
project = this._project,
|
||||||
index = this._index;
|
index = this._index;
|
||||||
if (owner && index != null) {
|
if (owner) {
|
||||||
// Only required for layers, but not enough to merit an override.
|
// Handle index separately from owner: There are situations where
|
||||||
if (project._activeLayer === this)
|
// the item is already removed from its list through Base.splice()
|
||||||
project._activeLayer = this.getNextSibling()
|
// and index set to undefined, but the owner is still set,
|
||||||
|| this.getPreviousSibling();
|
// e.g. in #removeChildren():
|
||||||
|
if (index != null) {
|
||||||
|
// Only required for layers but not enough to merit an override.
|
||||||
|
if (project._activeLayer === this)
|
||||||
|
project._activeLayer = this.getNextSibling()
|
||||||
|
|| this.getPreviousSibling();
|
||||||
|
Base.splice(owner._children, null, index, 1);
|
||||||
|
}
|
||||||
|
// Handle named children separately from index:
|
||||||
if (this._name)
|
if (this._name)
|
||||||
this._removeNamed();
|
this._removeNamed();
|
||||||
Base.splice(owner._children, null, index, 1);
|
|
||||||
this._installEvents(false);
|
this._installEvents(false);
|
||||||
// Notify self of the insertion change. We only need this
|
// Notify self of the insertion change. We only need this
|
||||||
// notification if we're tracking changes for now.
|
// notification if we're tracking changes for now.
|
||||||
|
|
|
@ -855,8 +855,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
||||||
// should not set this.
|
// should not set this.
|
||||||
updateMatrix: true
|
updateMatrix: true
|
||||||
});
|
});
|
||||||
for (var i = 0, l = children.length; i < l; i++)
|
for (var i = 0, l = children.length; i < l; i++) {
|
||||||
children[i].draw(ctx, param);
|
children[i].draw(ctx, param);
|
||||||
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
|
||||||
// Draw the selection of the selected items in the project:
|
// Draw the selection of the selected items in the project:
|
||||||
|
@ -866,8 +867,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
||||||
var items = this._selectedItems,
|
var items = this._selectedItems,
|
||||||
size = this._scope.settings.handleSize,
|
size = this._scope.settings.handleSize,
|
||||||
version = this._updateVersion;
|
version = this._updateVersion;
|
||||||
for (var id in items)
|
for (var id in items) {
|
||||||
items[id]._drawSelection(ctx, matrix, size, items, version);
|
items[id]._drawSelection(ctx, matrix, size, items, version);
|
||||||
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue