Fix alt drag (#995)
This commit is contained in:
parent
373d16abe6
commit
7d57d124bd
@ -1330,7 +1330,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
let isResizingElements = false;
|
let isResizingElements = false;
|
||||||
let draggingOccurred = false;
|
let draggingOccurred = false;
|
||||||
let hitElement: ExcalidrawElement | null = null;
|
let hitElement: ExcalidrawElement | null = null;
|
||||||
let elementIsAddedToSelection = false;
|
let hitElementWasAddedToSelection = false;
|
||||||
if (this.state.elementType === "selection") {
|
if (this.state.elementType === "selection") {
|
||||||
const resizeElement = getElementWithResizeHandler(
|
const resizeElement = getElementWithResizeHandler(
|
||||||
globalSceneState.getAllElements(),
|
globalSceneState.getAllElements(),
|
||||||
@ -1386,7 +1386,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
globalSceneState.replaceAllElements(
|
globalSceneState.replaceAllElements(
|
||||||
globalSceneState.getAllElements(),
|
globalSceneState.getAllElements(),
|
||||||
);
|
);
|
||||||
elementIsAddedToSelection = true;
|
hitElementWasAddedToSelection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We duplicate the selected element if alt is pressed on pointer down
|
// We duplicate the selected element if alt is pressed on pointer down
|
||||||
@ -1396,7 +1396,10 @@ export class App extends React.Component<any, AppState> {
|
|||||||
const nextElements = [];
|
const nextElements = [];
|
||||||
const elementsToAppend = [];
|
const elementsToAppend = [];
|
||||||
for (const element of globalSceneState.getAllElements()) {
|
for (const element of globalSceneState.getAllElements()) {
|
||||||
if (this.state.selectedElementIds[element.id]) {
|
if (
|
||||||
|
this.state.selectedElementIds[element.id] ||
|
||||||
|
(element.id === hitElement.id && hitElementWasAddedToSelection)
|
||||||
|
) {
|
||||||
nextElements.push(duplicateElement(element));
|
nextElements.push(duplicateElement(element));
|
||||||
elementsToAppend.push(element);
|
elementsToAppend.push(element);
|
||||||
} else {
|
} else {
|
||||||
@ -2123,7 +2126,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
// If click occurred and elements were dragged or some element
|
// If click occurred and elements were dragged or some element
|
||||||
// was added to selection (on pointerdown phase) we need to keep
|
// was added to selection (on pointerdown phase) we need to keep
|
||||||
// selection unchanged
|
// selection unchanged
|
||||||
if (hitElement && !draggingOccurred && !elementIsAddedToSelection) {
|
if (hitElement && !draggingOccurred && !hitElementWasAddedToSelection) {
|
||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
this.setState(prevState => ({
|
this.setState(prevState => ({
|
||||||
selectedElementIds: {
|
selectedElementIds: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user