Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Implement touch events in violent theremin demo #128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mattfsourcecode
Copy link
Contributor

@mattfsourcecode mattfsourcecode commented Oct 16, 2024

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:

  1. Replaces <p> with <button> for the start message:

    • Mobile web browsers enforce stricter protocols for requiring an AudioContext to be initialized via a user gesture, such as a button click. This migration allows the AudioContext to run on mobile devices and avoids the following console warning:
      Screenshot 2024-10-15 at 5 38 27 PM
    • The .start-message button is styled to cover the full screen, closely mimicking the previous <p> element while keeping the text centered.
  2. Prevents duplicate init() invocations:

    • Ensures the init() method is called only once by removing redundant keydown event listeners and triggering init() exclusively on the .start-message button click.
    • Since the init() method already configures keyboard controls, removing window.addEventListener("keydown", init); did not impact the functionality.
    • This change aligns with feedback from @normanr in Add support for touch events to violent theremin demo sprints#3937 (comment).
  3. Prevents scrolling on touchmove events:

    • Disables scrolling caused by touch gestures to maintain functionality on touch screens.
    • Registers the updatePage() method as a callback for touchmove events within the init() method.

This PR allows the example to function seamlessly on both desktop and mobile browsers, providing a consistent and smooth experience across devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for touch events to violent theremin demo
1 participant