Skip to content

Commit

Permalink
Stylize startbutton, use addEventListener instead of onclick attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbartnett committed Jun 11, 2020
1 parent f2f4e0f commit 67fe032
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
13 changes: 8 additions & 5 deletions multi-track/index.html
Expand Up @@ -15,7 +15,7 @@
So provide a simple button to get things started.
-->
<button id="startbutton" onclick="initDemo()">Click me first</button>
<button id="startbutton">Press to load tracks</button>

<div class="wrapper">
<section id="tracks">
Expand Down Expand Up @@ -65,7 +65,11 @@

// for cross browser compatibility
const AudioContext = window.AudioContext || window.webkitAudioContext;
let audioCtx = null;
let audioCtx = null;

// Provide a start button so demo can load tracks from an event handler for cross-browser compatibility
const startButton = document.querySelector('#startbutton');
console.log(startButton);

// select all list elements
const trackEls = document.querySelectorAll('li');
Expand Down Expand Up @@ -115,8 +119,7 @@
return trackSource;
}


function initDemo() {
startButton.addEventListener('click', () => {
if (audioCtx != null) {
return;
}
Expand Down Expand Up @@ -157,7 +160,7 @@
})
})
})
}
});

</script>
</body>
Expand Down
14 changes: 14 additions & 0 deletions multi-track/style.css
Expand Up @@ -31,6 +31,20 @@ body {
color: var(--black);
}

#startbutton {
width: 12vw;
line-height: 3;
background-color: var(--boxMain);
border: var(--border); border-radius: var(--borderRad);
position: absolute;
top: 1px;
left: 1px;
}

#startbutton:hover {
background-color: var(--boxSecond);
}

.wrapper {
display: flex;
justify-content: center;
Expand Down

0 comments on commit 67fe032

Please sign in to comment.