Skip to content

Instantly share code, notes, and snippets.

@dhinesh03
Last active August 11, 2021 16:14
Show Gist options
  • Save dhinesh03/e5a43efa300829bf6879cff2b394e94c to your computer and use it in GitHub Desktop.
Save dhinesh03/e5a43efa300829bf6879cff2b394e94c to your computer and use it in GitHub Desktop.
Svelte- sample code to capture mouse coordinates
<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