opt: internal

This commit is contained in:
cha0s 2022-04-01 12:14:26 -05:00
parent cf90676890
commit 06ef49fa68

View File

@ -212,14 +212,14 @@ export default class Container extends Renderable {
return;
}
let needsSort = false;
let currentZ = this.$$children[0].zIndex;
let currentZ = this.$$children[0].$$zIndex;
for (let i = 0; i < this.$$children.length; i++) {
const child = this.$$children[i];
if (currentZ > child.zIndex) {
if (currentZ > child.$$zIndex) {
needsSort = true;
break;
}
currentZ = child.zIndex;
currentZ = child.$$zIndex;
}
if (!needsSort) {
return;
@ -240,14 +240,7 @@ export default class Container extends Renderable {
child.sort();
}
}
this.$$children.sort((l, r) => {
if (l.zIndex !== r.zIndex) {
return l.zIndex - r.zIndex;
}
const lIndex = this.$$children.indexOf(l);
const rIndex = this.$$children.indexOf(r);
return lIndex - rIndex;
});
this.$$children.sort((l, r) => l.$$zIndex - r.$$zIndex);
if (!this.container.isFake) {
this.container.children = this.$$children.map((child) => child.internal);
}