perf: remove extraneous check

This commit is contained in:
cha0s 2019-05-02 22:18:30 -05:00
parent 0f1bf3df59
commit ed33d9c90d

View File

@ -94,13 +94,6 @@ export class Visible extends decorate(Trait) {
this.entity.visibleScale = I.List(scale);
}
shouldSynchronizePosition() {
if (!this._container) {
return false;
}
return this._container && this.trackPosition;
}
synchronizePosition() {
if (!this.entity.is('positioned')) {
return;
@ -133,7 +126,7 @@ export class Visible extends decorate(Trait) {
}
listeners() {
const listeners = {
return {
isVisibleChanged: () => {
if (!this._container) {
@ -153,6 +146,16 @@ export class Visible extends decorate(Trait) {
this.translateVisibleAabb();
},
traitAdded: (type) => {
if (-1 === [
'visible',
'positioned',
].indexOf(type)) {
return;
}
this.synchronizePosition();
},
visibleScaleChanged: () => {
const scale = this.entity.visibleScale;
this._visibleScale = [scale.get(0), scale.get(1)];
@ -163,18 +166,6 @@ export class Visible extends decorate(Trait) {
},
};
if (this.shouldSynchronizePosition()) {
listeners.traitAdded = (type) => {
if (-1 === [
'visible',
'positioned',
].indexOf(type)) {
return;
}
this.synchronizePosition();
};
}
return listeners;
}
methods() {
@ -188,9 +179,7 @@ export class Visible extends decorate(Trait) {
}
renderTick(elapsed) {
if (this.shouldSynchronizePosition()) {
this.synchronizePosition();
}
this.synchronizePosition();
}
translateVisibleAabb() {