mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Shift drag to add to selection (#355)
* Shift drag to add to selection * Inlined variable
This commit is contained in:
parent
4c62cbf57e
commit
bc2bae2a9a
3 changed files with 24 additions and 14 deletions
|
@ -4,7 +4,7 @@ export {
|
|||
getSelectedIndices,
|
||||
deleteSelectedElements,
|
||||
someElementIsSelected,
|
||||
setSelection,
|
||||
getElementsWithinSelection,
|
||||
getSelectedAttribute
|
||||
} from "./selection";
|
||||
export {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ExcalidrawElement } from "../element/types";
|
||||
import { getElementAbsoluteCoords } from "../element";
|
||||
|
||||
export function setSelection(
|
||||
export function getElementsWithinSelection(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
selection: ExcalidrawElement
|
||||
) {
|
||||
|
@ -11,22 +11,22 @@ export function setSelection(
|
|||
selectionX2,
|
||||
selectionY2
|
||||
] = getElementAbsoluteCoords(selection);
|
||||
elements.forEach(element => {
|
||||
return elements.filter(element => {
|
||||
const [
|
||||
elementX1,
|
||||
elementY1,
|
||||
elementX2,
|
||||
elementY2
|
||||
] = getElementAbsoluteCoords(element);
|
||||
element.isSelected =
|
||||
|
||||
return (
|
||||
element.type !== "selection" &&
|
||||
selectionX1 <= elementX1 &&
|
||||
selectionY1 <= elementY1 &&
|
||||
selectionX2 >= elementX2 &&
|
||||
selectionY2 >= elementY2;
|
||||
selectionY2 >= elementY2
|
||||
);
|
||||
});
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
export function clearSelection(elements: readonly ExcalidrawElement[]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue