This commit is contained in:
Christian Heilmann 2021-03-21 15:06:21 +01:00
Родитель 9769a880bd
Коммит a12a4ca450
1 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -3,10 +3,30 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Logging mouse movement</title>
<title>Mouse movement without logging</title>
<link rel="stylesheet" href="demostyles.css">
<link rel="shortcut icon" type="image/ico" href="favicon_io/favicon.ico"/>
</head>
<body>
<h1>Console demos: no logging</h1>
<p>There is nothing to see here, you need to open the Developer Tools and set up live expressions for x and y.</p>
<p>Select <code>Control</code>+<code>Shift</code>+<code>J</code> (Windows, Linux) or <code>Command</code>+<code>Option</code>+<code>J</code> (macOS).</p>
<p>Then move your mouse around the screen. Uncheck the following to stop logging.</p>
<p><label><input type="checkbox" checked>Log mouse movement</label></p>
<script>
let x = 0;
let y = 0;
document.addEventListener('mousemove', e => {
x = e.x;
y = e.y;
if(document.querySelector('input').checked) {
console.log({x}, {y});
}
});
</script>
</body>
</html>
<script>
let x = 0;
let y = 0;