|
1 | 1 | // This injects a box into the page that moves with the mouse; |
2 | 2 | // Useful for debugging |
3 | | -(function(){ |
| 3 | +(function () { |
4 | 4 | const box = document.createElement('div'); |
5 | 5 | box.classList.add('mouse-helper'); |
6 | 6 | const styleElement = document.createElement('style'); |
|
42 | 42 | `; |
43 | 43 | document.head.appendChild(styleElement); |
44 | 44 | document.body.appendChild(box); |
45 | | - document.addEventListener('mousemove', event => { |
46 | | - box.style.left = event.pageX + 'px'; |
47 | | - box.style.top = event.pageY + 'px'; |
48 | | - updateButtons(event.buttons); |
49 | | - }, true); |
50 | | - document.addEventListener('mousedown', event => { |
51 | | - updateButtons(event.buttons); |
52 | | - box.classList.add('button-' + event.which); |
53 | | - }, true); |
54 | | - document.addEventListener('mouseup', event => { |
55 | | - updateButtons(event.buttons); |
56 | | - box.classList.remove('button-' + event.which); |
57 | | - }, true); |
| 45 | + document.addEventListener( |
| 46 | + 'mousemove', |
| 47 | + (event) => { |
| 48 | + box.style.left = event.pageX + 'px'; |
| 49 | + box.style.top = event.pageY + 'px'; |
| 50 | + updateButtons(event.buttons); |
| 51 | + }, |
| 52 | + true |
| 53 | + ); |
| 54 | + document.addEventListener( |
| 55 | + 'mousedown', |
| 56 | + (event) => { |
| 57 | + updateButtons(event.buttons); |
| 58 | + box.classList.add('button-' + event.which); |
| 59 | + }, |
| 60 | + true |
| 61 | + ); |
| 62 | + document.addEventListener( |
| 63 | + 'mouseup', |
| 64 | + (event) => { |
| 65 | + updateButtons(event.buttons); |
| 66 | + box.classList.remove('button-' + event.which); |
| 67 | + }, |
| 68 | + true |
| 69 | + ); |
58 | 70 | function updateButtons(buttons) { |
59 | 71 | for (let i = 0; i < 5; i++) |
60 | 72 | box.classList.toggle('button-' + i, buttons & (1 << i)); |
|
0 commit comments