mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Implement Project#clear().
This commit is contained in:
parent
885d75296d
commit
1b61e4333c
2 changed files with 11 additions and 0 deletions
|
@ -73,6 +73,9 @@ var Layer = this.Layer = Group.extend(/** @lends Layer# */{
|
|||
if (this._parent)
|
||||
return this.base(notify);
|
||||
if (this._index != null) {
|
||||
if (this._project.activeLayer === this)
|
||||
this._project.activeLayer = this.getNextSibling()
|
||||
|| this.getPreviousSibling();
|
||||
Base.splice(this._project.layers, null, this._index, 1);
|
||||
// Tell project we need a redraw. This is similar to _changed()
|
||||
// mechanism.
|
||||
|
|
|
@ -85,6 +85,14 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
* @function
|
||||
*/
|
||||
|
||||
// DOCS: Project#clear()
|
||||
|
||||
clear: function() {
|
||||
for (var i = 0; i < this.layers.length; i++)
|
||||
this.layers[i].remove();
|
||||
this.symbols = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes this project from the {@link PaperScope#projects} list, and also
|
||||
* removes its view, if one was defined.
|
||||
|
|
Loading…
Reference in a new issue