Skip to content

Instantly share code, notes, and snippets.

@EtherDream
Last active August 24, 2017 07:39
Show Gist options
  • Save EtherDream/9b426b9946cadcfec959e3e8bddd936f to your computer and use it in GitHub Desktop.
Save EtherDream/9b426b9946cadcfec959e3e8bddd936f to your computer and use it in GitHub Desktop.
e.timeStamp vs Date.now()
var t1, t2;
function sleep(ms) {
var s = Date.now();
while (Date.now() - s < ms);
}
document.addEventListener('mousemove', function(e) {
if (!t1) {
t1 = Date.now();
t2 = e.timeStamp;
return;
}
console.log(
'time:', Date.now() - t1,
'ts:', e.timeStamp - t2,
'x:', e.clientX, 'y:', e.clientY
);
sleep(1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment