Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

ui: fix Cannot access 'mouseMoveListenerAttached' before initialization

Abdullah Attaa0e6266d287a
diff --git a/packages/ui/src/utils/position.ts b/packages/ui/src/utils/position.ts
index 40834036a..29ed9a216 100644
--- a/packages/ui/src/utils/position.ts
+++ b/packages/ui/src/utils/position.ts
@@ -27,6 +27,7 @@ type PositionData = {
};
const mousePosition: PositionData = { x: 0, y: 0, actualX: 0, actualY: 0 };
+let mouseMoveListenerAttached = false;
attachMouseMoveListener();
export type PositionOptions = {
@@ -177,7 +178,6 @@ export function getElementPosition(
return position;
}
-let mouseMoveListenerAttached = false;
function attachMouseMoveListener() {
if (mouseMoveListenerAttached || !("window" in globalThis)) return;
window.addEventListener("mousemove", (e) => {