From f4f1c80ed54738ef06007df30b2c45d922870b90 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Mar 2024 19:53:34 -0300 Subject: client: always watch mouse position This will definitely not have any consequences. --- src/static/client3.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/static') 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', { -- cgit 1.3.0-6-gf8a5