-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.js
More file actions
71 lines (65 loc) · 1.54 KB
/
Copy pathtemp.js
File metadata and controls
71 lines (65 loc) · 1.54 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var shadowBall = new Konva.Rect({
x: 0,
y: 0,
shapeType: 'shadow',
width: blockSnapSize * 6,
height: blockSnapSize * 3,
fill: '#FF7B17',
opacity: 0.6,
stroke: '#CF6412',
strokeWidth: 3,
dash: [20, 2]
});
function newBall(x, y, width, height, layer, stage, innerText) {
let circle = new Konva.Rect({
x: x,
y: y,
x_prev: x,
y_prev: y,
shapeType: 'rectangle',
width: blockSnapSize * 6,
height: blockSnapSize * 3,
fill: '#fff',
stroke: '#ddd',
strokeWidth: 1,
shadowColor: 'black',
shadowBlur: 2,
shadowOffset: {x : 1, y : 1},
shadowOpacity: 0.4,
draggable: true
});
circle.add(new Konva.Text({
text: innerText
fontSize: 18,
fontFamily: 'Calibri',
fill: '#000',
width: 130,
padding: 5,
align: 'center'
}));
circle.on('dragstart', (e) => {
shadowRectangle.show();
shadowRectangle.moveToTop();
rectangle.moveToTop();
rectangle.position({
x_prev: rectangle.x,
y_prev: rectangle.y
});
});
circle.on('dragend', (e) => {
rectangle.position({
x: Math.round(rectangle.x() / blockSnapSize) * blockSnapSize,
y: Math.round(rectangle.y() / blockSnapSize) * blockSnapSize
});
stage.batchDraw();
shadowRectangle.hide();
});
circle.on('dragmove', (e) => {
shadowCircle.position({
x: Math.round(rectangle.x() / blockSnapSize) * blockSnapSize,
y: Math.round(rectangle.y() / blockSnapSize) * blockSnapSize
});
stage.batchDraw();
});
layer.add(circle);
}