-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvg_practice.html
51 lines (45 loc) · 1.14 KB
/
svg_practice.html
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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="main-container"></div>
<script src="./bower_components/raphael/raphael.js"></script>
<script>
var
paper,
circle,
canvas;
paper = Raphael(document.querySelector('.main-container'), 640, 400);
setBGColor(paper.canvas, '#efefef');
circle = paper.circle(320, 200, 50);
circle.attr('fill', '#f00');
circle.attr('stroke', '#fff');
// setTimeout(function() {
// circle.animate({
// cx: 10, cy: 10
// }, 1000, 'linear', function() { console.log('done animating'); });
// }, 1000);
circle.drag(
dHandle, null, null,
circle, null, null
// dHandle.bind(circle, 'start'),
// dHandle.bind(circle, 'end')
);
function dHandle(dx, dy, x, y) {
var
currentX = this.attr('x'),
currentY = this.attr('y');
this.animate({
cx: x,
cy: y
}, 1);
}
function setBGColor(elem, color) {
if (elem.style === undefined || elem.style.backgroundColor === undefined) return;
elem.style.backgroundColor = color;
}
</script>
</body>
</html>