Last active
August 11, 2021 16:14
-
-
Save dhinesh03/e5a43efa300829bf6879cff2b394e94c to your computer and use it in GitHub Desktop.
Svelte- sample code to capture mouse coordinates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
let m = { x: 0, y: 0 }; | |
function handleMousemove(event) { | |
m.x = event.clientX; | |
m.y = event.clientY; | |
} | |
</script> | |
<div on:mousemove={handleMousemove}> | |
The mouse position is {m.x} x {m.y} | |
</div> | |
<style> | |
div { width: 100%; height: 100%; } | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment