Skip to content

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

Description

@eddsaura

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions