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

Mouse over location has offset #5

Open
svcninja opened this issue Aug 26, 2016 · 2 comments
Open

Mouse over location has offset #5

svcninja opened this issue Aug 26, 2016 · 2 comments

Comments

@svcninja
Copy link

Div inside another div, the mouse interaction with the constellation has a x offset

@mrghosh
Copy link

mrghosh commented Aug 26, 2018

I am also facing the issue.

@ghost
Copy link

ghost commented Feb 7, 2020

I also discovered this problem. You can replace the two lines of code as follows so the mouse interaction is properly located.

      // Mouse event listeners
      this.canvas.addEventListener(
        "mousemove",
        function(e) {
          this.mouseParticle.x =
            // e.clientX - this.canvas.offsetLeft; << replace this
            e.clientX - this.canvas.getBoundingClientRec().left; 
          this.mouseParticle.y =
            // e.clientY - this.canvas.offsetTop; << replace this
            e.clientY - this.canvas.getBoundingClientRec().top;
        }.bind(this)
      );

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

2 participants