Skip to content

Commit 459156c

Browse files
committed
Add rainbow color animation on keys
1 parent 524a77a commit 459156c

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

01 - JavaScript Drum Kit/assets/css/styles.css

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,54 @@ kbd {
4949
text-transform: uppercase;
5050
letter-spacing: .1rem;
5151
color: #ffc600;
52-
}
52+
}
53+
54+
.rainbow-color {
55+
-webkit-animation: color-change-4x 0.8s linear alternate backwards;
56+
animation: color-change-4x 0.8s linear alternate backwards;
57+
}
58+
59+
/* ----------------------------------------------
60+
* Generated by Animista on 2018-11-14 20:52:57
61+
* w: http://animista.net, t: @cssanimista
62+
* ---------------------------------------------- */
63+
64+
/**
65+
* ----------------------------------------
66+
* animation color-change-4x
67+
* ----------------------------------------
68+
*/
69+
@-webkit-keyframes color-change-4x {
70+
0% {
71+
background: #19dcea;
72+
}
73+
25% {
74+
background: #b22cff;
75+
}
76+
50% {
77+
background: #ea2222;
78+
}
79+
75% {
80+
background: #f5be10;
81+
}
82+
100% {
83+
background: transparent;
84+
}
85+
}
86+
@keyframes color-change-4x {
87+
0% {
88+
background: #19dcea;
89+
}
90+
25% {
91+
background: #b22cff;
92+
}
93+
50% {
94+
background: #ea2222;
95+
}
96+
75% {
97+
background: #f5be10;
98+
}
99+
100% {
100+
background: transparent;
101+
}
102+
}

01 - JavaScript Drum Kit/assets/js/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ handleKeyDown = e => {
1010
audio.currentTime = 0;
1111
audio.play();
1212
key.classList.add('playing');
13+
key.classList.add('rainbow-color');
1314

1415
// listen for transionend so styles can be removed after the transition is done
15-
key.addEventListener('transitionend', () =>
16-
key.classList.remove('playing')
17-
);
16+
key.addEventListener('transitionend', () => key.classList.remove('playing'));
17+
key.addEventListener('animationend', () => key.classList.remove('rainbow-color'));
1818
}
1919
};
2020

21-
window.addEventListener('keydown', handleKeyDown);
21+
window.addEventListener('keydown', handleKeyDown);

01 - JavaScript Drum Kit/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</head>
99
<body>
1010
<div class="keys">
11-
<div data-key="a" class="key">
11+
<div data-key="a" class="key rgb-border">
1212
<kbd>A</kbd> <span class="sound">clap</span>
1313
</div>
1414
<div data-key="s" class="key">

0 commit comments

Comments
 (0)