« get me outta code hell

live-mouse-position.js « client « js « static « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static/js/client/live-mouse-position.js
blob: 36a284299810cdfd89e5ef22f996036c1b86986a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* eslint-env browser */

export const info = {
  id: 'liveMousePositionInfo',

  state: {
    clientX: null,
    clientY: null,
  },
};

export function addPageListeners() {
  const {state} = info;

  document.body.addEventListener('mousemove', domEvent => {
    Object.assign(state, {
      clientX: domEvent.clientX,
      clientY: domEvent.clientY,
    });
  });
}