MCPcopy
hub / github.com/viliusle/miniPaint / load

Method load

src/js/tools/select.js:40–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38 }
39
40 load() {
41 var _this = this;
42
43 //mouse events
44 document.addEventListener('mousedown', function (e) {
45 _this.dragStart(e);
46 });
47 document.addEventListener('mousemove', function (e) {
48 _this.dragMove(e);
49 });
50 document.addEventListener('mouseup', function (e) {
51 _this.dragEnd(e);
52 });
53
54 // collect touch events
55 document.addEventListener('touchstart', function (e) {
56 _this.dragStart(e);
57 });
58 document.addEventListener('touchmove', function (e) {
59 _this.dragMove(e);
60 });
61 document.addEventListener('touchend', function (e) {
62 _this.dragEnd(e);
63 });
64
65 //keyboard actions
66 document.addEventListener('keydown', (event) => {
67 if (config.TOOL.name != this.name)
68 return;
69 if (this.POP.get_active_instances() > 0) {
70 return;
71 }
72 if (this.Helper.is_input(event.target))
73 return;
74 var k = event.key;
75
76 if (k == "ArrowUp") {
77 this.move(0, -1, event);
78 }
79 else if (k == "ArrowDown") {
80 this.move(0, 1, event);
81 }
82 else if (k == "ArrowRight") {
83 this.move(1, 0, event);
84 }
85 else if (k == "ArrowLeft") {
86 this.move(-1, 0, event);
87 }
88 if (k == "Delete") {
89 if (config.TOOL.name == this.name) {
90 app.State.do_action(
91 new app.Actions.Delete_layer_action(config.layer.id)
92 );
93 }
94 }
95 });
96 document.addEventListener('keyup', (event) => {
97 if (config.TOOL.name != this.name)

Callers

nothing calls this directly

Calls 8

moveMethod · 0.95
addEventListenerMethod · 0.80
get_active_instancesMethod · 0.80
is_inputMethod · 0.80
do_actionMethod · 0.80
dragStartMethod · 0.45
dragMoveMethod · 0.45
dragEndMethod · 0.45

Tested by

no test coverage detected