JSFiddle - React, Tailwind, and code Playground
by trkli
HTML
<span id="currentPos"></span><br/>
<span id="logPos"></span>
JavaScript
var oldMath = 0;
$(document).mousemove(function(event) {
var startingTop = 10,
startingLeft = 22,
math = Math.round(Math.sqrt(Math.pow(startingTop - event.clientY, 2) +Math.pow(startingLeft - event.clientX, 2))) + 'px';
$('#currentPos').text('you are at :' + math);
if(Math.abs(parseInt(math) - oldMath) >20){
//you have moved 5 pixles, put your stuff in here
$('#logPos').append('5');
oldMath = parseInt(math);
}
});