chore: clean up listener creation

This commit is contained in:
cha0s 2019-03-19 10:21:00 -05:00
parent d250d94f3b
commit 654a9b4dd8

View File

@ -28,23 +28,22 @@ class GraphicalBase extends Trait {
} }
listeners() { listeners() {
const listeners = {};
const trackPosition = this.params.get('trackPosition'); const trackPosition = this.params.get('trackPosition');
if (!trackPosition || !this._container.isValid) { if (trackPosition && this._container.isValid) {
return {}; listeners.traitAdded = (trait) => {
}
return {
traitAdded: (trait) => {
if ('positioned' === trait.constructor.type()) { if ('positioned' === trait.constructor.type()) {
this._container.position = this.entity.position; this._container.position = this.entity.position;
} }
}, };
xChanged: (x) => { listeners.xChanged = (x) => {
this._container.x = x; this._container.x = x;
}, };
yChanged: (y) => { listeners.yChanged = (y) => {
this._container.y = y; this._container.y = y;
}, };
} }
return listeners;
} }
} }