JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="drawing"></canvas>
<canvas id="without_offset"></canvas>
CSS
#drawing {
border: 1px solid #000;
position: absolute;
top: 50px;
right: 0;
}
#without_offset {
border: 1px solid #000;
}
JavaScript
var ctx = document.getElementById("drawing").getContext("2d");
$("#drawing").mousemove(function(e) {
ctx.lineTo(e.clientX, e.clientY);
ctx.stroke();
});
var ctx_without_offset = document.getElementById("without_offset").getContext("2d");
$("#without_offset").mousemove(function(e) {
ctx_without_offset.lineTo(e.clientX, e.clientY);
ctx_without_offset.stroke();
});