fix sort error (#4513)

This commit is contained in:
JoneLau
2019-05-29 10:58:53 +08:00
committed by pandamicro
parent ae2dbaf04f
commit af216fa257
+5 -10
View File
@@ -442,16 +442,11 @@ export class UI {
sortList = node.children.slice();
sortList.sort((a, b) => {
const ca = a.getComponent(UIComponent);
const cb = b.getComponent(UIComponent);
if (ca && cb) {
return -(ca.priority - cb.priority);
}
else if (!ca) {
return 1;
} else {
return -1;
}
const aComp = a.getComponent(UIComponent);
const bComp = b.getComponent(UIComponent);
const ca = aComp ? aComp.priority : -1;
const cb = bComp ? bComp.priority : -1;
return ca - cb;
});
return sortList;