-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
54 lines (45 loc) · 1.54 KB
/
script.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
(function(){
var heart = document.querySelector('.heart-container');
var parts = document.querySelectorAll('.heart');
var campo = document.querySelector('#nome');
var nome = '';
var animar = function animar() {
nome = campo.value.toString().toLowerCase();
switch(nome){
case 'beatriz':
Array.prototype.forEach.call(parts, function (part) {
part.style.WebkitTransition = 'background 0.5s';
part.style.MozTransition = 'background 0.5s';
part.style.background = '#FF3F3F';
});
heart.className = 'heart-container heart-animate-fast';
break;
case 'palmeiras':
Array.prototype.forEach.call(parts, function (part) {
part.style.WebkitTransition = 'background 0.5s';
part.style.MozTransition = 'background 0.5s';
part.style.background = '#22F340';
});
heart.className = 'heart-container heart-animate-slow';
break;
case 'felipe':
case 'gabriel':
Array.prototype.forEach.call(parts, function (part) {
part.style.WebkitTransition = 'background 0.5s';
part.style.MozTransition = 'background 0.5s';
part.style.background = '#656DFF';
});
heart.className = 'heart-container heart-animate';
break;
default:
Array.prototype.forEach.call(parts, function (part) {
part.style.WebkitTransition = 'background 0.5s';
part.style.MozTransition = 'background 0.5s';
part.style.background = '#CCC';
});
heart.className = 'heart-container';
}
}
campo.addEventListener('keyup', animar);
campo.addEventListener('paste', animar);
}());