mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Define Project#isEmpty()
This commit is contained in:
parent
ea62b570f3
commit
da9e1f8de7
3 changed files with 14 additions and 2 deletions
|
@ -38,7 +38,7 @@ var PaperScopeItem = Base.extend(Callback, /** @lends PaperScopeItem# */{
|
||||||
if (!this._scope)
|
if (!this._scope)
|
||||||
return false;
|
return false;
|
||||||
var prev = this._scope[this._reference];
|
var prev = this._scope[this._reference];
|
||||||
if (prev && prev != this)
|
if (prev && prev !== this)
|
||||||
prev.fire('deactivate');
|
prev.fire('deactivate');
|
||||||
this._scope[this._reference] = this;
|
this._scope[this._reference] = this;
|
||||||
this.fire('activate', prev);
|
this.fire('activate', prev);
|
||||||
|
|
|
@ -830,7 +830,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
* no children, a {@link TextItem} with no text content and a {@link Path}
|
* no children, a {@link TextItem} with no text content and a {@link Path}
|
||||||
* with no segments all are considered empty.
|
* with no segments all are considered empty.
|
||||||
*
|
*
|
||||||
* @type Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
isEmpty: function() {
|
isEmpty: function() {
|
||||||
return !this._children || this._children.length == 0;
|
return !this._children || this._children.length == 0;
|
||||||
|
|
|
@ -92,6 +92,18 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
||||||
this.symbols = [];
|
this.symbols = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether the project has any content or not. Note that since
|
||||||
|
* projects by default are created with one empty layer, this returns alos
|
||||||
|
* {@code true} if that layer exists but is itself empty.
|
||||||
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
isEmpty: function() {
|
||||||
|
return this.layers.length <= 1
|
||||||
|
&& (!this.activeLayer || this.activeLayer.isEmpty());
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes this project from the {@link PaperScope#projects} list, and also
|
* Removes this project from the {@link PaperScope#projects} list, and also
|
||||||
* removes its view, if one was defined.
|
* removes its view, if one was defined.
|
||||||
|
|
Loading…
Reference in a new issue