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

There is a case where "getInfoGridFromMouseTouchEvent" throws an error because X === -1 #215

Open
eddsaura opened this issue Oct 31, 2024 · 0 comments

Comments

@eddsaura
Copy link

So we are having an error that we cannot catch.

In the function

var getInfoGridFromMouseTouchEvent =
    function getInfoGridFromMouseTouchEvent (evt) {
      var canvas = evt.currentTarget
      var rect = canvas.getBoundingClientRect()
      var clientX
      var clientY
      /** Detect if touches are available */
      if (evt.touches) {
        clientX = evt.touches[0].clientX
        clientY = evt.touches[0].clientY
      } else {
        clientX = evt.clientX
        clientY = evt.clientY
      }
      var eventX = clientX - rect.left
      var eventY = clientY - rect.top

      var x = Math.floor(eventX * ((canvas.width / rect.width) || 1) / g)
      var y = Math.floor(eventY * ((canvas.height / rect.height) || 1) / g)

      return infoGrid[x][y]
    }

The value of eventX is -1, so when trying to access to infoGrid[x][y] it just breaks.

When we hover slowly over the canvas looks like the client x is on 440 and the canvas is positioned at 441. Thats strange.

Here you can see the values from debug console :)

image
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

1 participant