File: event.html

package info (click to toggle)
node-zrender 5.4.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,624 kB
  • sloc: javascript: 1,259; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download | duplicates (3)
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>
    <meta charset="utf-8" />
    <title>Event</title>
    <script src="../dist/zrender.js"></script>
</head>
<body>
    <div id="main" style="width:1000px;height:500px;"></div>
    <script type="text/javascript">
        var zr = zrender.init(document.getElementById('main'));
        var circle1 = new zrender.Circle({
            shape: {
                cx: 20,
                cy: 20,
                r: 30
            },
            style: {
                fill: 'blue'
            },
            draggable: true
        });

        var circle2 = new zrender.Circle({
            shape: {
                cx: 300,
                cy: 300,
                r: 100
            }
        });

        circle1.on('mouseover', function () {
            zr.dom.style.cursor = 'move';
        });
        circle1.on('mouseout', function () {
            zr.dom.style.cursor = 'default';
        });

        circle2.on('dragenter', function () {
            this.setStyle('fill', 'red');
        }).on('dragleave', function () {
            this.setStyle('fill', 'black');
        }).on('drop', function () {
            this.setStyle('fill', 'green');
        });

        zr.add(circle2);
        zr.add(circle1);
    </script>
</body>
</html>