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

MouseConstraint preventing clicks on buttons on mobile. #1283

Open
MichaelPriebe opened this issue Mar 27, 2024 · 2 comments
Open

MouseConstraint preventing clicks on buttons on mobile. #1283

MichaelPriebe opened this issue Mar 27, 2024 · 2 comments

Comments

@MichaelPriebe
Copy link

<html>
  <body>
    <div id="mouse">
      <button id="button">Test</button>
    </div>
  </body>
</html>

<script>
  import Matter from "matter-js";

  document.querySelector("#button")!.addEventListener("click", console.log);

  const engine = Matter.Engine.create();
  Matter.Composite.add(
    engine.world,
    Matter.MouseConstraint.create(engine, {
      mouse: Matter.Mouse.create(document.querySelector("#mouse")!),
    }),
  );
</script>

I cant seem to click on the button on mobile when there is a MouseConstraint. Shouldn't at least nothing happen when there is no body at the location you touch, especially in this example when there is no bodies at all?

@JeffreyArts
Copy link

I don’t see how/where the matterJS is being placed with this dummy code. So I can’t verify if the problem is associated with an overlaying canvas element.

Nor do I understand why there is an explanation mark at the end of mouse: Matter.Mouse.create(

@ggorlen
Copy link

ggorlen commented Apr 2, 2024

@JeffreyArts Presumably, the !s are TypeScript, but you're right it's unclear because TS doesn't work in <script> tags. A complete, runnable example is missing here.

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

No branches or pull requests

3 participants