Coder Social home page Coder Social logo

drum-kit's Introduction

JavaScript Drum Kit

JS Drum Kit is a drum kit website built with Vanilla JavaScript.
It's designed for you to play the drum kit using designated keys on the keyboard, so the website only works on PC at the moment.

Table of contents

Overview

Screenshots

Demo video:

js-drum-kit-demo-vid.mov

Demo Link

πŸ’» Live Site URL

About the Project

Status

βœ… Completed & Deployed

Built with

  • HTML
  • CSS
  • Vanilla JS

Reflection

This was a quick and easy project built as I started taking the JavaScript 30 course by Wes Bos. Project goals included using just Vanilla JS to build a website. I decided to build first before listening to lectures because that’s how I learn best.

Some features to highlight in this project are:

using the currentTime property to reset the audio whenever the audio is supposed to reset before it finishes playing the whole sound

/* function */
function playAudio(e) {
  // find the key element that matches the key pressed
  const pressedKey = document.querySelector(`.key[data-key="${e.keyCode}"]`);

  // find the audio element that matches the key pressed
  const audioToPlay = document.querySelector(`audio[data-key="${e.keyCode}"]`);

  // if pressedKey exists:
  //--1. add "playing" class then remove
  pressedKey?.classList.add("playing");
  //--2. play the corresponding audio
  if (!audioToPlay) return;
  // ❗️ make audio play again from start if key is pressed again before audio ends
  //---a. reset audio
  else audioToPlay.currentTime = 0;
  //---b. play audio
  audioToPlay.play();
}

using transitionend event in an event listener to toggle a class instead of using setTimeout()

// toggle 'playing' class
window.addEventListener("transitionend", e => {
  if (e.propertyName !== "transform") return;
  e.target.classList.remove("playing");
});

The technologies implemented in this project are HTML, CSS, and Vanilla JavaScript. It was a quick but super fun project and I got to work with audio elements for the first time!

Author

Soojeong Park @codingsooj

drum-kit's People

Contributors

soojeong-park-ca avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.