Skip to content

Instantly share code, notes, and snippets.

@STRd6
Created April 14, 2011 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save STRd6/918983 to your computer and use it in GitHub Desktop.
Save STRd6/918983 to your computer and use it in GitHub Desktop.
Detect when user is idle from mouse movement
#TODO: Fade out things under certain conditions
lastMoved = new Date().getTime()
inactiveThreshold = 2000
$(document).bind "mousemove", ->
lastMoved = new Date().getTime()
setInterval ->
currentTime = new Date().getTime()
inactiveTime = currentTime - lastMoved
if inactiveTime > inactiveThreshold
else
, 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment