Created
November 12, 2018 15:36
-
-
Save tomhodgins/dbd29269e628870f3c6aa670035918dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option A | |
window.addEventListener('touchstart', strike) | |
window.addEventListener('mousedown', strike) | |
window.addEventListener('touchmove', slide) | |
window.addEventListener('mousemove', slide) | |
window.addEventListener('touchend', release) | |
window.addEventListener('mouseup', release) | |
document.querySelector('select').addEventListener( | |
'change', | |
event => oscillator.type = event.target.value | |
) | |
document.querySelector('[type="range"]').addEventListener( | |
'input', | |
event => volume = event.target.value | |
) | |
// Option B | |
[ | |
{ | |
target: window, | |
event: 'touchstart', | |
action: strike | |
}, | |
{ | |
target: window, | |
event: 'mousedown', | |
action: strike | |
}, | |
{ | |
target: window, | |
event: 'touchmove', | |
action: slide | |
}, | |
{ | |
target: window, | |
event: 'mousemove', | |
action: slide | |
}, | |
{ | |
target: window, | |
event: 'touchend', | |
action: release | |
}, | |
{ | |
target: window, | |
event: 'mouseup', | |
action: release | |
}, | |
{ | |
target: document.querySelector('select'), | |
event: 'change', | |
action: event => oscillator.type = event.target.value | |
}, | |
{ | |
target: document.querySelector('[type="range"]'), | |
event: 'input', | |
action: event => volume = event.target.value | |
} | |
].forEach(action => | |
action.target.addEventListener(action.event, action.action) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment