diff --git a/01 - JavaScript Drum Kit/app.js b/01 - JavaScript Drum Kit/app.js new file mode 100644 index 0000000000..ab02e0834a --- /dev/null +++ b/01 - JavaScript Drum Kit/app.js @@ -0,0 +1,21 @@ + + + + +function playSound(e){ + const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`); + const key = document.querySelector(`.key[data-key="${e.keyCode}"]`); + if(!audio)return;//stop function from running all together + audio.currentTime = 0;// rewind to start + audio.play(); + key.classList.add('playing'); + } +function removeTransition(e){ + if(e.propertyName !== 'transform') + return;//skip if its not a transform + this.classList.remove('playing') +} + +const keys = document.querySelectorAll('.key'); +keys.forEach(key => key.addEventListener('transitionend', removeTransition)); +window.addEventListener('keydown', playSound); diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..a46e616b15 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -57,7 +57,8 @@ - diff --git a/01 - JavaScript Drum Kit/index.html b/01 - JavaScript Drum Kit/index.html index a18f2bc2ca..8fef0e6bc2 100644 --- a/01 - JavaScript Drum Kit/index.html +++ b/01 - JavaScript Drum Kit/index.html @@ -77,6 +77,7 @@ keys.forEach(key => key.addEventListener('transitionend', removeTransition)); window.addEventListener('keydown', playSound); + diff --git a/01 - JavaScript Drum Kit/style.css b/01 - JavaScript Drum Kit/style.css index 3e0a320b37..48a36ca69a 100644 --- a/01 - JavaScript Drum Kit/style.css +++ b/01 - JavaScript Drum Kit/style.css @@ -23,7 +23,7 @@ body,html { margin:1rem; font-size: 1.5rem; padding:1rem .5rem; - transition:all .07s; + transition:all 0.07s; width:100px; text-align: center; color:white; @@ -32,7 +32,7 @@ body,html { } .playing { - transform:scale(1.1); + transform:scale(2.1); border-color:#ffc600; box-shadow: 0 0 10px #ffc600; } diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 259280d228..459595dadf 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -9,9 +9,9 @@
-
-
-
+
hour
+
min
+
sec
@@ -54,20 +54,48 @@ height: 100%; transform: translateY(-3px); /* account for the height of the clock hands */ } - .hand { width:50%; height:6px; - background:black; position: absolute; + background: black; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: ; + transition-timing-function: cubic-bezier(.1, 2.7, .58, 1); } -