🐛 Fix issue that mac users can not move workflow

This commit is contained in:
Jan Oberhauser
2019-07-17 07:26:44 +02:00
parent 5dd9544b1e
commit 3b6013f6f4
2 changed files with 26 additions and 11 deletions

View File

@@ -8,9 +8,24 @@ export const moveNodeWorkflow = mixins(nodeIndex).extend({
moveLastPosition: [0, 0],
};
},
mounted () {
computed: {
controlKeyCode (): string {
if (this.isMacOs) {
return 'Meta';
}
return 'Control';
},
isMacOs (): boolean {
return /(ipad|iphone|ipod|mac)/i.test(navigator.platform);
},
},
methods: {
isCtrlKeyPressed (e: MouseEvent | KeyboardEvent): boolean {
if (this.isMacOs) {
return e.metaKey;
}
return e.ctrlKey;
},
moveWorkflow (e: MouseEvent) {
const offsetPosition = this.$store.getters.getNodeViewOffsetPosition;
@@ -23,7 +38,7 @@ export const moveNodeWorkflow = mixins(nodeIndex).extend({
this.moveLastPosition[1] = e.pageY;
},
mouseDownMoveWorkflow (e: MouseEvent) {
if (e.ctrlKey === false) {
if (this.isCtrlKeyPressed(e) === false) {
// We only care about it when the ctrl key is pressed at the same time.
// So we exit when it is not pressed.
return;