refactor: opt

This commit is contained in:
cha0s 2021-02-07 02:40:58 -06:00
parent 841c8c9c52
commit 9fafe9cda8

View File

@ -266,13 +266,14 @@ export default () => class Visible extends decorate(Trait) {
} }
onZIndexChanged(zIndex) { onZIndexChanged(zIndex) {
if (!this.#container) {
return;
}
this.#usingAutoZIndex = AUTO_ZINDEX === zIndex; this.#usingAutoZIndex = AUTO_ZINDEX === zIndex;
if (!this.#usingAutoZIndex) { if (!this.#usingAutoZIndex) {
if (this.#container) {
this.#container.zIndex = zIndex; this.#container.zIndex = zIndex;
} }
} }
}
packets() { packets() {
const {isVisible, opacity, rotation} = this.stateDifferences(); const {isVisible, opacity, rotation} = this.stateDifferences();
@ -335,11 +336,9 @@ export default () => class Visible extends decorate(Trait) {
} }
this.#container.position = this.entity.position; this.#container.position = this.entity.position;
if (this.#usingAutoZIndex) { if (this.#usingAutoZIndex) {
if (this.#container) {
this.#container.zIndex = this.entity.y; this.#container.zIndex = this.entity.y;
} }
} }
}
get visibleScaleX() { get visibleScaleX() {
return this.state.visibleScale[0]; return this.state.visibleScale[0];