-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGestureService.js
52 lines (49 loc) · 1.32 KB
/
GestureService.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const ioHook = require("iohook");
const doAction = require("./action");
const EventRegister = require("./event/EventRegister");
class GestureService {
constructor() {
this.ioHook = ioHook;
this.register = new EventRegister(this.ioHook);
this.isActive = false;
this.register.regist("holdMouseRBtnMove", (e) => {
switch (e.moveDirection) {
case "up":
doAction("taskView");
break;
case "down":
doAction("taskView");
break;
case "left":
doAction("desktopRight");
break;
case "right":
doAction("desktopLeft");
break;
default:
break;
}
});
}
active() {
this.ioHook.start(false);
this.ioHook.disableClickPropagation();
this.isActive = true;
}
pause() {
this.ioHook.stop();
this.ioHook.enableClickPropagation();
this.isActive = false;
}
/**
* 因为iohook会自动load,所以这里不需要load
*/
start() {
this.active();
}
stop() {
this.pause();
this.ioHook.unload();
}
}
module.exports = GestureService;