williamngan/pts

[Question] Manually provide mouse coords?

fractalhq opened this issue · 1 comments

Currently, when hovering over a button or link placed on top of the canvas, the mouse position tracking is lost.

I'm using svelte, and I have easy access to the mouse coords already:

<script>
	import PT from './PT.svelte';
	let x, y;
	function mouse(e) {
		x = e.clientX;
		y = e.clientY;
	}
</script>

<svelte:window on:mousemove={(e) => mouse(e)} />

<PT {x} {y}/>

These coords are never lost regarless of what UI element I'm hovering over, so ideally I would like to just use my x and y instead of the bindMouse() function.

Unless there is a way to prevent the PT from losing the mouse position?

Thanks in advance!!

Hi @FractalHQ -- two quick ideas:

  1. Have you tried the useCapture = true option in addEventListener?

  2. If you just want to hack it, you can try to set the internal _pointer directly. Eg, space._pointer.to(x, y).

I love Svelte though haven't spent much time in it. Hope this makes sense.