forked from iVis-at-Bilkent/cytoscape.js-node-editing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
115 lines (89 loc) · 2.42 KB
/
demo.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE>
<html>
<head>
<title>cytoscape-node-editing.js demo</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<script src="https://code.jquery.com/jquery-3.1.0.slim.min.js"></script>
<script src="https://cdn.rawgit.com/konvajs/konva/1.6.3/konva.min.js"></script>
<script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script>
<!-- for testing with local version of cytoscape.js -->
<!--<script src="../cytoscape.js/build/cytoscape.js"></script>-->
<script src="cytoscape-node-editing.js"></script>
<style>
body {
font-family: helvetica neue, helvetica, liberation sans, arial, sans-serif;
font-size: 14px;
}
#cy {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 999;
}
h1 {
opacity: 0.5;
font-size: 1em;
font-weight: bold;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function(){
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
style: [
{
selector: 'node',
style: {
'content': 'data(name)',
'textValign': 'center'
}
},
{
selector: 'edge',
style: {
'target-arrow-shape': 'triangle'
}
},
{
selector: ':selected',
style: {
}
}
],
layout: { name: 'grid', rows: 2, cols: 2},
wheelSensitivity: 0.1,
elements: {
nodes: [
{ data: { id: 'j', name: 'Aspected Resize' }, classes: "fixedAspectRatioResizeMode" },
{ data: { id: 'e', name: 'Full Resize' } },
{ data: { id: 'k', name: 'No Resize' }, classes: "noResizeMode" }
],
edges: [
{ data: { source: 'j', target: 'e' } },
{ data: { source: 'j', target: 'k' } },
{ data: { source: 'e', target: 'j' } },
{ data: { source: 'e', target: 'k' } },
{ data: { source: 'k', target: 'j' } },
{ data: { source: 'k', target: 'e' } }
]
}
});
cy.nodeEditing({
resizeToContentCueImage: 'resizeCue.svg'
});
cy.on("nodeediting.resizestart", function (e, type) {
console.log(type);
});
cy.on("nodeediting.resizeend", function (e, type) {
document.body.style.cursor = 'initial';
});
});
</script>
</head>
<body>
<h1>cytoscape-node-editing demo</h1>
<div id="cy"></div>
</body>
</html>