mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Various optimizations around Project#view.
This commit is contained in:
parent
00a7588a3a
commit
0743f1b7b8
5 changed files with 11 additions and 5 deletions
|
@ -155,7 +155,8 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{
|
||||||
* @type View
|
* @type View
|
||||||
*/
|
*/
|
||||||
getView: function() {
|
getView: function() {
|
||||||
return this.project && this.project.getView();
|
var project = this.project;
|
||||||
|
return project && project._view;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,5 +58,9 @@ var PaperScopeItem = Base.extend(Emitter, /** @lends PaperScopeItem# */{
|
||||||
this._scope[this._reference] = null;
|
this._scope[this._reference] = null;
|
||||||
this._scope = null;
|
this._scope = null;
|
||||||
return true;
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
getView: function() {
|
||||||
|
return this._scope.getView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getView: function() {
|
getView: function() {
|
||||||
return this._project.getView();
|
return this._project._view;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -302,7 +302,7 @@ var Style = Base.extend(new function() {
|
||||||
* @type View
|
* @type View
|
||||||
*/
|
*/
|
||||||
getView: function() {
|
getView: function() {
|
||||||
return this._project.getView();
|
return this._project._view;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
|
|
|
@ -132,8 +132,9 @@ var View = Base.extend(Emitter, /** @lends View# */{
|
||||||
View._views.splice(View._views.indexOf(this), 1);
|
View._views.splice(View._views.indexOf(this), 1);
|
||||||
delete View._viewsById[this._id];
|
delete View._viewsById[this._id];
|
||||||
// Unlink from project
|
// Unlink from project
|
||||||
if (this._project._view === this)
|
var project = this._project;
|
||||||
this._project._view = null;
|
if (project._view === this)
|
||||||
|
project._view = null;
|
||||||
/*#*/ if (__options.environment == 'browser') {
|
/*#*/ if (__options.environment == 'browser') {
|
||||||
// Uninstall event handlers again for this view.
|
// Uninstall event handlers again for this view.
|
||||||
DomEvent.remove(this._element, this._viewEvents);
|
DomEvent.remove(this._element, this._viewEvents);
|
||||||
|
|
Loading…
Reference in a new issue