From 654a9b4dd802eba9b01ed33f3bc3fade18eac3b2 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 19 Mar 2019 10:21:00 -0500 Subject: [PATCH] chore: clean up listener creation --- packages/entity/traits/graphical.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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; } }