diff --git a/packages/entity/traits/graphical.js b/packages/entity/traits/graphical.js index e25ab8d..f920e46 100644 --- a/packages/entity/traits/graphical.js +++ b/packages/entity/traits/graphical.js @@ -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; } }