feat(editor): Move canvas by holding Space or Middle mouse button (#5719)
* ⚡ Implemented canvas move on space+drag * ⚡ Added middle mouse key canvas move * ⚡ Handling cursor changes when moving canvas with middle mouse button * 💄 Consolidate naming
This commit is contained in:
committed by
GitHub
parent
6242cac53b
commit
19dded18c9
@@ -141,8 +141,8 @@ export const mouseSelect = mixins(deviceSupportHelpers).extend({
|
||||
|
||||
return returnNodes;
|
||||
},
|
||||
mouseDownMouseSelect(e: MouseEvent) {
|
||||
if (this.isCtrlKeyPressed(e) === true) {
|
||||
mouseDownMouseSelect(e: MouseEvent, moveButtonPressed: boolean) {
|
||||
if (this.isCtrlKeyPressed(e) === true || moveButtonPressed) {
|
||||
// We only care about it when the ctrl key is not pressed at the same time.
|
||||
// So we exit when it is pressed.
|
||||
return;
|
||||
|
||||
@@ -27,8 +27,8 @@ export const moveNodeWorkflow = mixins(deviceSupportHelpers).extend({
|
||||
this.moveLastPosition[0] = x;
|
||||
this.moveLastPosition[1] = y;
|
||||
},
|
||||
mouseDownMoveWorkflow(e: MouseEvent) {
|
||||
if (this.isCtrlKeyPressed(e) === false) {
|
||||
mouseDownMoveWorkflow(e: MouseEvent, moveButtonPressed: boolean) {
|
||||
if (this.isCtrlKeyPressed(e) === false && !moveButtonPressed) {
|
||||
// We only care about it when the ctrl key is pressed at the same time.
|
||||
// So we exit when it is not pressed.
|
||||
return;
|
||||
@@ -39,7 +39,10 @@ export const moveNodeWorkflow = mixins(deviceSupportHelpers).extend({
|
||||
return;
|
||||
}
|
||||
|
||||
this.uiStore.nodeViewMoveInProgress = true;
|
||||
// Don't indicate move start just yet if middle button is pressed
|
||||
if (e.button !== 1) {
|
||||
this.uiStore.nodeViewMoveInProgress = true;
|
||||
}
|
||||
|
||||
const [x, y] = getMousePosition(e);
|
||||
|
||||
@@ -73,6 +76,11 @@ export const moveNodeWorkflow = mixins(deviceSupportHelpers).extend({
|
||||
return;
|
||||
}
|
||||
|
||||
// Signal that moving canvas is active if middle button is pressed and mouse is moved
|
||||
if (e.button === 1) {
|
||||
this.uiStore.nodeViewMoveInProgress = true;
|
||||
}
|
||||
|
||||
if (e.buttons === 0) {
|
||||
// Mouse button is not pressed anymore so stop selection mode
|
||||
// Happens normally when mouse leave the view pressed and then
|
||||
|
||||
Reference in New Issue
Block a user