Skip to content

Instantly share code, notes, and snippets.

@andrew8088
Created June 3, 2010 21:29
Show Gist options
  • Save andrew8088/424522 to your computer and use it in GitHub Desktop.
Save andrew8088/424522 to your computer and use it in GitHub Desktop.
(function ($) {
$.fn.chromeFade = function (opts) {
var defs = { msTilFade : 2000, fadeSpeed : 500, fadeTo : 0.01 },
sets = $.extend({}, defs, opts),
elems = this,
fadeFunc = function () {
elems.fadeTo(sets.fadeSpeed, sets.fadeTo);
},
fadeTimer = setTimeout(fadeFunc, sets.msTilFade);
$(document).mousemove(function () {
elems.fadeTo(100, 1.0);
clearTimeout(fadeTimer);
fadeTimer = setTimeout(fadeFunc, sets.msTilFade);
});
}
}(jQuery));
// example : http://jsbin.com/avedu3/5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment