Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1.45 KB

readme.md

File metadata and controls

43 lines (30 loc) · 1.45 KB

JavaScript 30

I took the JavaScript 30 Day Challenge by @wesbos.
I encourage you to grab the course at https://JavaScript30.com.
Wes writes some of the best tutorials whether you're just learning or looking for a refresh.

Since I deviated a bit from the course material, I decided to post my solutions as alternatives.
Each of my solutions have been added in my github with file name index-ARIOS.html.
I welcome PRs or suggestions. Sharing is caring, afterall.
Enjoy and follow me on Twitter! @stpColabr8nLstn


The only major deviation here is that I opted to use keyup rather than listening for the end of transform.

Original Solution:

  function removeTransition(e) {
    if (e.propertyName !== 'transform') return;
    e.target.classList.remove('playing');
  }

  const keys = Array.from(document.querySelectorAll('.key'));
  keys.forEach(key => key.addEventListener('transitionend', removeTransition));

My Solution:

  function endSound (e) {
    const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
    if(!key) return;
    key.classList.remove('playing');
  }

  window.addEventListener('keyup', endSound);