« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/static/client3.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/static/client3.js b/src/static/client3.js
index 485ae3c3..764bdaa8 100644
--- a/src/static/client3.js
+++ b/src/static/client3.js
@@ -689,6 +689,29 @@ function mutateCSSCompatibilityContent() {
 clientSteps.getPageReferences.push(getCSSCompatibilityAssistantInfoReferences);
 clientSteps.mutatePageContent.push(mutateCSSCompatibilityContent);
 
+// Ever-updating mouse position helper --------------------
+
+const liveMousePositionInfo = initInfo('liveMousePositionInfo', {
+  state: {
+    clientX: null,
+    clientY: null,
+  },
+});
+
+function addLiveMousePositionPageListeners() {
+  const info = liveMousePositionInfo;
+  const {state} = info;
+
+  document.body.addEventListener('mousemove', domEvent => {
+    Object.assign(state, {
+      clientX: domEvent.clientX,
+      clientY: domEvent.clientY,
+    });
+  });
+}
+
+clientSteps.addPageListeners.push(addLiveMousePositionPageListeners);
+
 // JS-based links -----------------------------------------
 
 const scriptedLinkInfo = initInfo('scriptedLinkInfo', {