Visitar URL original
[01] Updates background with a gradient · wesbos/JavaScript30@99976a0 · GitHub
Skip to content

Commit 99976a0

Browse files
committed
[01] Updates background with a gradient
1 parent af63835 commit 99976a0

2 files changed

Lines changed: 3 additions & 21 deletions

File tree

‎01 - JavaScript Drum Kit/index-START.html‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
</head>
88
<body>
99

10-
1110
<div class="keys">
1211
<div data-key="65" class="key">
1312
<kbd>A</kbd>
@@ -58,27 +57,8 @@
5857
<audio data-key="76" src="sounds/tink.wav"></audio>
5958

6059
<script>
61-
function playSound(e) {
62-
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
63-
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
64-
if(!audio) return; // stop running if the keyCode does not match
65-
66-
audio.currentTime = 0; // rewind to the start
67-
audio.play();
68-
key.classList.add('playing');
69-
}
70-
71-
function removeTransition(e) {
72-
if (e.propertyName !== 'transform') return; // skip if it's not a transform
73-
this.classList.remove('playing');
74-
}
7560

76-
const keys = document.querySelectorAll('.key');
77-
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
78-
79-
window.addEventListener('keydown', playSound);
8061
</script>
8162

82-
8363
</body>
8464
</html>

‎01 - JavaScript Drum Kit/style.css‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
html {
22
font-size: 10px;
3-
background: url(http://i.imgur.com/b9r5sEL.jpg) bottom center;
3+
background: bottom center;
44
background-size: cover;
5+
background-image: linear-gradient(to bottom, rgba(255,255,0,0.5), rgba(0,0,255,0.5)),
6+
url(http://i.imgur.com/b9r5sEL.jpg);
57
}
68
body,html {
79
margin: 0;

0 commit comments

Comments
 (0)