Mausposition wenn maus stehen bleibt

Erst wenn die Maus stehen bleibt, wird die Position der Maus angezeigt

Der hier verwendete Code

<style> body{ height:100vh; width:100vw; } </style> <body> <div id="out"></div> </body> <script> (function (mouseStopDelay) { var timeout; document.addEventListener('mousemove', function (e) { clearTimeout(timeout); timeout = setTimeout(function () { var event = new CustomEvent("mouse_bleibt_stehen", { detail: { clientX: e.clientX, clientY: e.clientY }, bubbles: true, cancelable: true }); e.target.dispatchEvent(event); }, mouseStopDelay); }); }(100)); document.getElementsByTagName('body')[0].addEventListener('mouse_bleibt_stehen', function(e) { console.log(e) document.getElementById('out').innerHTML='You stopped your mouse <br>' +'Mouse coordinates are: <br>X = '+ e.detail.clientX+'<br>Y = '+ e.detail.clientY; }); </script>

Add Comment

* Required information
1000
Drag & drop images (max 3)
Powered by Commentics

Comments

No comments yet. Be the first!