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 movement path and drawing path are different upon scroll/resize. #4074

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

Conversation

deepakpixel
Copy link

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

While drawing, the lines are drawn with respect to the browser window (using clientX. clientY). When the canvas is more or less than the browser window line drawn are not accurate and are far away from mouse movement.

Lets make canvas move down by 200px by adding css, canvas{margin-top:200px}
now the line drawn and the mouse movement will be 200px apart.

New behavior

To fix this we have to decrease the top offset from current.x and left offset from current.y. So that, even after scrolling the offsets are fixed and drawn line is exactly below the cursor.

Other information (e.g. related issues)

NA

@deepakpixel deepakpixel changed the title Fix offset when scrolled Mouse movement path and drawing path are different upon scroll/resize. Sep 7, 2021
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.

1 participant