Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Commit 60cd758

Browse files
CapitanMorganyotamberk
authored andcommitted
add example for network on Load animation. (#2476)
1 parent 067a6e8 commit 60cd758

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<title>Network | On Load Animation</title>
6+
<script type="text/javascript" src="../../../dist/vis.js"></script>
7+
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
8+
<style type="text/css">
9+
#mynetwork {
10+
width: 600px;
11+
height: 400px;
12+
border: 1px solid lightgray;
13+
}
14+
</style>
15+
</head>
16+
<body>
17+
<h2>Vis.js network onLoad animation</h2>
18+
<p>easeIn functions accelerate from zero velocity.</p>
19+
<p>easeOut functions decelerate to zero velocity.</p>
20+
<p>easeInOut functions accelerate from zero till halfway then after the halfway point they decrease until zero.</p>
21+
<div>
22+
Onload Animation Easing Function -
23+
<select id="easingFunction">
24+
<option value="linear">linear</option>
25+
<option value="easeInQuad">easeInQuad</option>
26+
<option value="easeOutQuad">easeOutQuad</option>
27+
<option value="easeInOutQuad">easeInOutQuad</option>
28+
<option value="easeInCubic">easeInCubic</option>
29+
<option value="easeOutCubic">easeOutCubic</option>
30+
<option value="easeInOutCubic">easeInOutCubic</option>
31+
<option value="easeInQuart">easeInQuart</option>
32+
<option value="easeOutQuart">easeOutQuart</option>
33+
<option value="easeInOutQuart">easeInOutQuart</option>
34+
<option value="easeInQuint">easeInQuint</option>
35+
<option value="easeOutQuint">easeOutQuint</option>
36+
<option value="easeInOutQuint">easeInOutQuint</option>
37+
</select>
38+
<button onClick="createNetwork(document.getElementById('easingFunction').value);">Demo Easing Function</button>
39+
</div>
40+
<p>For more information on easing functions check out <a href="http://easings.net/">easings.net</a></p>
41+
<div id="mynetwork"></div>
42+
<script type="text/javascript">
43+
document.getElementById("easingFunction").selectedIndex = 0;
44+
function createNetwork(easingType) {
45+
var nodes = new vis.DataSet([
46+
{id: 1, label: 'Node 1'},
47+
{id: 2, label: 'Node 2'},
48+
{id: 3, label: 'Node 3'},
49+
{id: 4, label: 'Node 4'},
50+
{id: 5, label: 'Node 5'}
51+
]);
52+
53+
var edges = new vis.DataSet([
54+
{from: 1, to: 3},
55+
{from: 1, to: 2},
56+
{from: 2, to: 4},
57+
{from: 2, to: 5}
58+
]);
59+
60+
var container = document.getElementById('mynetwork');
61+
var data = {
62+
nodes: nodes,
63+
edges: edges
64+
};
65+
var options = {};
66+
var network = new vis.Network(container, data, options);
67+
network.once("beforeDrawing", function() {
68+
network.focus(2, {
69+
scale: 12
70+
});
71+
});
72+
network.once("afterDrawing", function() {
73+
network.fit({
74+
animation: {
75+
duration: 3000,
76+
easingFunction: easingType
77+
}
78+
});
79+
});
80+
}
81+
createNetwork("linear");
82+
</script>
83+
</body>
84+
</html>
85+

0 commit comments

Comments
 (0)