fix: attached mouse event listener to window instead of canvas element
This commit is contained in:
@@ -312,7 +312,7 @@ void main() {
|
|||||||
uniforms.iMouse.value = [x, y];
|
uniforms.iMouse.value = [x, y];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
canvas.addEventListener('pointermove', onPointerMove);
|
window.addEventListener('pointermove', onPointerMove);
|
||||||
|
|
||||||
const loop = (t: number) => {
|
const loop = (t: number) => {
|
||||||
rafRef.current = requestAnimationFrame(loop);
|
rafRef.current = requestAnimationFrame(loop);
|
||||||
@@ -357,7 +357,7 @@ void main() {
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
||||||
canvas.removeEventListener('pointermove', onPointerMove);
|
window.removeEventListener('pointermove', onPointerMove);
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
ro.disconnect();
|
ro.disconnect();
|
||||||
if (canvas.parentElement === container) {
|
if (canvas.parentElement === container) {
|
||||||
|
|||||||
Reference in New Issue
Block a user