[Vuejs]-How can I get the relative mouse position on image click (Vue 3)

0👍

You could subtract the current mouse position minus the x and y position of your image.
Something like:

Check this example

onimgClick(event) { const target = event.target; const bounds = target.getBoundingClientRect(); const posX = event.clientX - bounds.x; const posY = event.clientY - bounds.y; console.log(posX, posY); },

Leave a comment