🐛 Fix issue that it starts select mode when mac users try to move workflow

This commit is contained in:
Jan Oberhauser 2019-07-17 12:03:55 +02:00
parent 85d9cc4eb8
commit 40b17c59f6

View file

@ -11,6 +11,11 @@ export const mouseSelect = mixins(nodeIndex).extend({
selectBox: document.createElement('span'),
};
},
computed: {
isMacOs (): boolean {
return /(ipad|iphone|ipod|mac)/i.test(navigator.platform);
},
},
mounted () {
this.createSelectBox();
},
@ -28,6 +33,12 @@ export const mouseSelect = mixins(nodeIndex).extend({
// document.body.appendChild(this.selectBox);
this.$el.appendChild(this.selectBox);
},
isCtrlKeyPressed (e: MouseEvent | KeyboardEvent): boolean {
if (this.isMacOs) {
return e.metaKey;
}
return e.ctrlKey;
},
showSelectBox (event: MouseEvent) {
// @ts-ignore
this.selectBox.x = event.pageX;
@ -97,7 +108,7 @@ export const mouseSelect = mixins(nodeIndex).extend({
return returnNodes;
},
mouseDownMouseSelect (e: MouseEvent) {
if (e.ctrlKey === true) {
if (this.isCtrlKeyPressed(e) === true) {
// We only care about it when the ctrl key is not pressed at the same time.
// So we exit when it is pressed.
return;