Reputation: 43833
In this solution in javascript
I can get the mouse location when it's first pressed and first clicked, but how can I get the location while its being pressed down?
Thanks
Upvotes: 1
Views: 74
Reputation: 121
You can get any instance of mouse coordinate inside <canvas>
. In this case, planting other tags inside <canvas>
limited and could be done only via {position: absolute}
.
Code example:
canvas.addEventListener('mousemove', getPoint);
function getPoint(e){
const [x, y] = [e.offsetX, e.offsetY];
const offsetX = document.getElementById('offsetX');
offsetX.textContent = `Offset X: ${x}`;
const offsetY = document.getElementById('offsetY');
offsetY.textContent = `Offset Y: ${y}`;
};
Working example: http://codepen.io/462960/pen/RpVJwa
Upvotes: 0
Reputation: 1413
You can track every movement mouse, like this Track mouse movement and add logic for tracking only if before was mouse click down a stop when mouse was click up.
Upvotes: 1