Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- var IdleTime = 0;
- var timeout;
- // initially fade in upon page load
- $('#header-wrapper').delay(100).fadeIn(1600);
- // They may be idle from this point onwards
- // We do a check to find out
- timeout = setTimeout("checkIdle()", 5000); // 5 seconds
- $(document).bind('mousemove', function() {
- // check if #header-wrapper is not visible
- if (!$('#header-wrapper').is(':visible'))
- {
- // Header is invisible, so fade in
- $('#header-wrapper').fadeIn(1600);
- // They may be idle from this point onwards
- // We do a check to find out
- timeout = setTimeout("checkIdle()", 5000); // 5 seconds
- }
- });
- function checkIdle()
- {
- clearTimeout(timeout);
- IdleTime += 5; // 5 seconds
- if (IdleTime >= 180) // 180 seconds = 3 minutes
- {
- // Reset idle time
- IdleTime = 0;
- // if header is visible
- if ($('#header-wrapper').is(':visible'))
- {
- // Header is visible, so fade out
- $('#header-wrapper').fadeOut(1600);
- }
- }
- else
- {
- // If the user is idle, why bother doing checks?
- // User is not idle to this point, so we check again
- timeout = setTimeout("checkIdle()", 5000); // 5 seconds
- }
- }
- });
Add Comment
Please, Sign In to add comment