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() {
const listeners = {};
const trackPosition = this.params.get('trackPosition');
if (!trackPosition || !this._container.isValid) {
return {};
}
return {
traitAdded: (trait) => {
if (trackPosition && this._container.isValid) {
listeners.traitAdded = (trait) => {
if ('positioned' === trait.constructor.type()) {
this._container.position = this.entity.position;
}
},
xChanged: (x) => {
};
listeners.xChanged = (x) => {
this._container.x = x;
},
yChanged: (y) => {
};
listeners.yChanged = (y) => {
this._container.y = y;
},
};
}
return listeners;
}
}