socket.io
socket.io copied to clipboard
Mouse movement path and drawing path are different upon scroll/resize.
The kind of change this PR does introduce
- [x] 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