-
Notifications
You must be signed in to change notification settings - Fork 171
/
arrow-handler.js
40 lines (32 loc) · 959 Bytes
/
arrow-handler.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
var arrowHandler = {
ismousedown: false,
prevX: 0,
prevY: 0,
arrowSize: 10,
mousedown: function(e) {
var x = e.pageX - canvas.offsetLeft,
y = e.pageY - canvas.offsetTop;
var t = this;
t.prevX = x;
t.prevY = y;
t.ismousedown = true;
},
mouseup: function(e) {
var x = e.pageX - canvas.offsetLeft,
y = e.pageY - canvas.offsetTop;
var t = this;
if (t.ismousedown) {
points[points.length] = ['arrow', [t.prevX, t.prevY, x, y], drawHelper.getOptions()];
t.ismousedown = false;
}
},
mousemove: function(e) {
var x = e.pageX - canvas.offsetLeft,
y = e.pageY - canvas.offsetTop;
var t = this;
if (t.ismousedown) {
tempContext.clearRect(0, 0, innerWidth, innerHeight);
drawHelper.arrow(tempContext, [t.prevX, t.prevY, x, y]);
}
}
};