generate real fractional index after z-index actions

This commit is contained in:
Ryan Di
2023-12-05 13:06:00 +08:00
parent d1a9c593cc
commit 84c1de7a03
4 changed files with 100 additions and 24 deletions

View File

@@ -315,11 +315,11 @@ class Scene {
"insertElementAtIndex can only be called with index >= 0",
);
}
const nextElements = [
const nextElements = normalizeFractionalIndicies([
...this.elements.slice(0, index),
...elements,
...this.elements.slice(index),
];
]);
this.replaceAllElements(nextElements);
}
@@ -328,7 +328,9 @@ class Scene {
if (element.frameId) {
this.insertElementAtIndex(element, this.getElementIndex(element.frameId));
} else {
this.replaceAllElements([...this.elements, element]);
this.replaceAllElements(
normalizeFractionalIndicies([...this.elements, element]),
);
}
};