opt: only sort container when necessary
This commit is contained in:
parent
ca28e52231
commit
6e5d5384e1
|
@ -103,15 +103,22 @@ export class Container extends Renderable {
|
|||
}
|
||||
|
||||
renderTick(elapsed) {
|
||||
let needsSort = false;
|
||||
for (const child of this._children) {
|
||||
if (0 !== child.zIndex) {
|
||||
needsSort = true;
|
||||
}
|
||||
for (let i = 0; i < this._children.length; i++) {
|
||||
const child = this._children[i];
|
||||
if (child instanceof Container) {
|
||||
child.renderTick(elapsed);
|
||||
}
|
||||
}
|
||||
let needsSort = false;
|
||||
let currentZ = -Infinity;
|
||||
for (let i = 0; i < this._children.length; i++) {
|
||||
const child = this._children[i];
|
||||
if (currentZ > child.zIndex) {
|
||||
needsSort = true;
|
||||
break;
|
||||
}
|
||||
currentZ = child.zIndex;
|
||||
}
|
||||
if (!needsSort) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user