Fix: Implement touch events in violent theremin demo #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves issue #126 by enabling touch events in the Violent Theremin demo, making the example usable on mobile device web browsers.
Changes Introduced in This PR:
Replaces
<p>
with<button>
for the start message:AudioContext
to be initialized via a user gesture, such as a button click. This migration allows theAudioContext
to run on mobile devices and avoids the following console warning:.start-message
button is styled to cover the full screen, closely mimicking the previous<p>
element while keeping the text centered.Prevents duplicate
init()
invocations:init()
method is called only once by removing redundantkeydown
event listeners and triggeringinit()
exclusively on the.start-message
button click.init()
method already configures keyboard controls, removingwindow.addEventListener("keydown", init);
did not impact the functionality.Prevents scrolling on
touchmove
events:updatePage()
method as a callback fortouchmove
events within theinit()
method.This PR allows the example to function seamlessly on both desktop and mobile browsers, providing a consistent and smooth experience across devices.