Skip to content

Commit 7c76edd

Browse files
committed
fixed incremental z positioning
1 parent 4866770 commit 7c76edd

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/core/CoreNode.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,8 +1893,6 @@ export class CoreNode extends EventEmitter {
18931893
const inRttCluster =
18941894
this.props.rtt === true || this.parentHasRenderTexture === true;
18951895
const children = this.children;
1896-
const min = this.zIndexMin;
1897-
const max = this.zIndexMax;
18981896
const zIndex = node.zIndex;
18991897
const autosizeTarget = this.autosizer || this.parentAutosizer;
19001898
let attachToAutosizer = autosizeTarget !== null;
@@ -1932,13 +1930,14 @@ export class CoreNode extends EventEmitter {
19321930

19331931
children.push(node);
19341932

1935-
if (min !== max || (zIndex !== min && zIndex !== max)) {
1936-
if (zIndex < min) {
1937-
this.zIndexMin = zIndex;
1938-
}
1939-
if (zIndex > max) {
1940-
this.zIndexMax = zIndex;
1941-
}
1933+
if (zIndex < this.zIndexMin) {
1934+
this.zIndexMin = zIndex;
1935+
}
1936+
if (zIndex > this.zIndexMax) {
1937+
this.zIndexMax = zIndex;
1938+
}
1939+
1940+
if (this.zIndexMax !== this.zIndexMin) {
19421941
this.zIndexSortList.push(node);
19431942
this.setUpdateType(UpdateType.SortZIndexChildren);
19441943
}

src/core/lib/collectionUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ export const incrementalRepositionByZIndex = (
7373

7474
//binary search for correct insertion position
7575
let left = 0;
76-
let right = nodes.length;
76+
let right = currentIndex === nodes.length - 1 ? currentIndex : nodes.length;
7777

7878
while (left < right) {
7979
const mid = (left + right) >>> 1;
80-
if (nodes[mid]!.props.zIndex <= targetZIndex) {
80+
const target = nodes[mid]!;
81+
if (target.props.zIndex <= targetZIndex) {
8182
left = mid + 1;
8283
} else {
8384
right = mid;

0 commit comments

Comments
 (0)