Make scene functions return array instead of mutate array

- Not all functions were changes; so the given argument was a new array to some
This commit is contained in:
Gasim Gasimzada 2020-01-09 12:19:55 +04:00
parent 299e7e9099
commit 2ef809fe5d
3 changed files with 101 additions and 67 deletions

View file

@ -25,20 +25,20 @@ export function setSelection(
selectionX2 >= elementX2 &&
selectionY2 >= elementY2;
});
return elements;
}
export function clearSelection(elements: ExcalidrawElement[]) {
elements.forEach(element => {
element.isSelected = false;
});
return elements;
}
export function deleteSelectedElements(elements: ExcalidrawElement[]) {
for (let i = elements.length - 1; i >= 0; --i) {
if (elements[i].isSelected) {
elements.splice(i, 1);
}
}
return elements.filter(el => !el.isSelected);
}
export function getSelectedIndices(elements: ExcalidrawElement[]) {