diff --git a/packages/core/signal.mjs b/packages/core/signal.mjs index 8d410aba..6d903c06 100644 --- a/packages/core/signal.mjs +++ b/packages/core/signal.mjs @@ -97,10 +97,12 @@ export const time = signal(id); */ let _mouseY = 0, _mouseX = 0; -document.onmousemove = (e) => { - _mouseY = e.clientY / document.body.clientHeight; - _mouseX = e.clientX / document.body.clientWidth; -}; +if (typeof window !== 'undefined') { + document.onmousemove = (e) => { + _mouseY = e.clientY / document.body.clientHeight; + _mouseX = e.clientX / document.body.clientWidth; + }; +} export const mousey = signal(() => _mouseY); export const mousex = signal(() => _mouseX); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 82d63c4d..0c14000b 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -565,6 +565,27 @@ exports[`runs examples > example "_euclidRot" example index 20 1`] = ` ] `; +exports[`runs examples > example "_mouseY" example index 0 1`] = ` +[ + "[ 0/1 → 1/4 | note:C3 ]", + "[ 1/4 → 1/2 | note:C3 ]", + "[ 1/2 → 3/4 | note:C3 ]", + "[ 3/4 → 1/1 | note:C3 ]", + "[ 1/1 → 5/4 | note:C3 ]", + "[ 5/4 → 3/2 | note:C3 ]", + "[ 3/2 → 7/4 | note:C3 ]", + "[ 7/4 → 2/1 | note:C3 ]", + "[ 2/1 → 9/4 | note:C3 ]", + "[ 9/4 → 5/2 | note:C3 ]", + "[ 5/2 → 11/4 | note:C3 ]", + "[ 11/4 → 3/1 | note:C3 ]", + "[ 3/1 → 13/4 | note:C3 ]", + "[ 13/4 → 7/2 | note:C3 ]", + "[ 7/2 → 15/4 | note:C3 ]", + "[ 15/4 → 4/1 | note:C3 ]", +] +`; + exports[`runs examples > example "accelerate" example index 0 1`] = ` [ "[ 0/1 → 2/1 | s:sax accelerate:0 ]",