mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Optimize Emitter._installEvents()
Check for #_eventTypes first, no need to do anything if they don't exist.
This commit is contained in:
parent
922a502ee2
commit
0f084eaf02
1 changed files with 11 additions and 9 deletions
|
@ -107,16 +107,18 @@ var Emitter = {
|
||||||
fire: '#emit',
|
fire: '#emit',
|
||||||
|
|
||||||
_installEvents: function(install) {
|
_installEvents: function(install) {
|
||||||
var handlers = this._callbacks,
|
var types = this._eventTypes,
|
||||||
|
handlers = this._callbacks,
|
||||||
key = install ? 'install' : 'uninstall';
|
key = install ? 'install' : 'uninstall';
|
||||||
for (var type in handlers) {
|
if (types) {
|
||||||
if (handlers[type].length > 0) {
|
for (var type in handlers) {
|
||||||
var types = this._eventTypes,
|
if (handlers[type].length > 0) {
|
||||||
entry = types && types[type],
|
var entry = types[type],
|
||||||
func = entry && entry[key];
|
func = entry && entry[key];
|
||||||
if (func)
|
if (func)
|
||||||
func.call(this, type);
|
func.call(this, type);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue