Last active
August 24, 2017 07:39
-
-
Save EtherDream/9b426b9946cadcfec959e3e8bddd936f to your computer and use it in GitHub Desktop.
e.timeStamp vs Date.now()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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