Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c69d2af

Browse files
committed
progress
1 parent 2516cfb commit c69d2af

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

01 - JavaScript Drum Kit/index-START.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,23 @@
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

6060
<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; // Stops function on non-valid buttons
65+
audio.currentTime = 0;
66+
audio.play();
67+
key.classList.add('playing');
68+
}
6169

70+
function removeTransition(e) {
71+
if(e.propertyName !== "transform") return; // skip if not 'transform'
72+
this.classList.remove('playing');
73+
}
74+
75+
const keys = document.querySelectorAll('.key');
76+
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
77+
window.addEventListener('keydown', playSound);
6278
</script>
6379

6480

02 - JS and CSS Clock/index-START.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,33 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
/*transition: all 0.05s;*/
67+
/*transition-timing-function: cubic-bezier(0.1, 2.5, 0.5, 1);;*/
6468
}
6569

6670
</style>
6771

6872
<script>
73+
const secondHand = document.querySelector('.second-hand');
74+
const minuteHand = document.querySelector('.min-hand');
75+
const hourHand = document.querySelector('.hour-hand');
6976

77+
function setDate() {
78+
const now = new Date();
79+
const seconds = now.getSeconds();
80+
const secondsDegree = ((seconds / 60) * 360) + 90;
81+
const minutes = now.getMinutes()
82+
const minutesDegree = ((minutes / 60) * 360) + 90;
83+
const hours = now.getHours();
84+
const hoursDegree = ((hours / 12) * 360) + 90;
85+
secondHand.style.transform = `rotate(${secondsDegree}deg)`;
86+
minuteHand.style.transform = `rotate(${minutesDegree}deg)`;
87+
hourHand.style.transform = `rotate(${hoursDegree}deg)`;
7088

89+
}
90+
setInterval(setDate, 1000);
7191
</script>
7292
</body>
7393
</html>

0 commit comments

Comments
 (0)