-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.js
74 lines (62 loc) · 1.49 KB
/
animation.js
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
/*
* animation.js
*
* Handles all extra animations for the NEAT app.
* It is not part of the NEAT app namespace because it doesn't require any
* of it. It has its own namespace.
*
* @author Stephen Robinson
* @since: Mar 5, 2015
*/
var animation = animation || {};
//A dict containing all spinners with keys being the containing element's id.
animation.spinners = {};
/*
* createSpinner
* Creates a spinner inside the given id
*
* @author Stephen Robinson
* @since: Mar 5, 2015
*/
animation.createSpinner = function(id) {
var elt = document.getElementById(id);
if (animation.spinners[id] == undefined) {
//Create a new spinner
//based from code at http://fgnass.github.io/spin.js/
var opts = {
lines: 11,
length: 11,
width: 4,
radius: 8,
corners: 1,
rotate: 0,
direction: 1,
color: '#000',
speed: 1,
trail: 60,
shadow: false,
hwaccel: false,
className: 'spinner',
zIndex: 2e9,
top: '50%',
left: '50%'
};
animation.spinners[id] = new Spinner(opts).spin(elt);
} else {
//Restart old spinner
animation.spinners[id].spin(elt);
}
}
/*
* stopSpinners
*
* Stops and hides all spinners.
*
* @author Stephen Robinson
* @since: Mar 5, 2015
*/
animation.stopSpinners = function() {
for (id in animation.spinners) {
animation.spinners[id].stop();
}
}