-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradient_animation.js
158 lines (149 loc) · 3.67 KB
/
gradient_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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
var granimInstance;
var is_cleared = true;
var icon_play_pause;
new Vidage('#VidageVideo'); //create playing video
//init granim and all states
function init_granim() {
granimInstance = new Granim({
element: '#canvas-image',
name: 'basic-gradient',
direction: 'radial',
isPaused: false,
opacity: [1, 1],
stateTransitionSpeed: 1,
isPausedWhenNotInView: false,
states : {
"default-state": {
gradients: [
['#ff0000', '#fff'],
['#0000ff', '#fff'],
['#0000ff', '#fff']
],
transitionSpeed: 5000,
loop: true
},
"police-state": {
gradients: [
['#ff0000', '#fff'],
['#0000ff', '#fff']
],
transitionSpeed: 85,
loop: true
},
"camera-state": {
gradients: [
['#fff', '#fff'],
['#fff', '#ffff00'],
['#ffff00', '#ffff00'],
['#fff', '#ffff00'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#ffff00'],
['#ffff00', '#ffff00'],
['#fff', '#ffff00'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#fff'],
['#fff', '#ffff00'],
['#ffff00', '#ffff00'],
['#fff', '#ffff00'],
['#fff', '#fff'],
],
transitionSpeed: 50,
loop: true
},
"fire-state": {
gradients: [
['#e2224c', '#e27822'],
['#e27822', '#e27822']
],
transitionSpeed: 1000,
loop: true
}
}
});
}
function change_granim(){
if(!granimInstance){
init_granim();
is_cleared=false;
}
else{
if(granimInstance.isPaused){
granimInstance.play();
}
if(is_cleared==true){
is_cleared=false;
granimInstance.play();
}
}
icon_play_pause = document.getElementById("status_play");
icon_play_pause.classList.add("icon-play");
icon_play_pause.classList.remove("icon-pause");
}
function clear_choise(){
document.getElementById("href-fashion").className = "";
document.getElementById("href-police").className = "";
document.getElementById("href-camera").className = "";
document.getElementById("href-fire").className = "";
document.getElementById("href-pause").className = "";
document.getElementById("href-clear").className = "";
};
function gradient_fashion(){
clear_choise();
document.getElementById("href-fashion").className = "choise";
change_granim();
granimInstance.changeState('default-state');
}
function gradient_police(){
clear_choise();
document.getElementById("href-police").className = "choise";
change_granim();
granimInstance.changeState('police-state');
}
function gradient_camera(){
clear_choise();
document.getElementById("href-camera").className = "choise";
change_granim();
granimInstance.changeState('camera-state');
}
function gradient_fire(){
clear_choise();
document.getElementById("href-fire").className = "choise";
change_granim();
granimInstance.changeState('fire-state');
}
function gradient_pause(){
clear_choise();
icon_play_pause = document.getElementById("status_play");
icon_play_pause.classList.add("icon-pause");
icon_play_pause.classList.remove("icon-play");
if(granimInstance){
granimInstance.pause();
}
if(is_cleared){
document.getElementById("href-clear").className = "choise";
}
document.getElementById("href-pause").className = "choise";
}
function gradient_clear(){
clear_choise();
document.getElementById("href-clear").className = "choise";
if(granimInstance){
is_cleared=true;
granimInstance.clear();
}
icon_play_pause = document.getElementById("status_play");
icon_play_pause.classList.add("icon-pause");
icon_play_pause.classList.remove("icon-play");
document.getElementById("href-pause").className = "choise";
}