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