JSFiddle - React, Tailwind, and code Playground
by Trisox
HTML
<div class="first"></div>
<div class="second"></div>
CSS
div { position: absolute; width: 60px; height: 60px; float: left; }
.first { background-color: #3f3; left: 0;}
.second { background-color: #33f; left: 80px;}
JavaScript
(function($){
$.fn.delayed = function(options) {
var timer;
var delayImpl = function(eventObj) {
if (timer != null) {
clearTimeout(timer);
}
var newFn = function() {
options.fn(eventObj);
};
timer = setTimeout(newFn, options.delay);
}
return this.each(function() {
var obj = $(this);
obj.bind(options.event, function(eventObj) {
delayImpl(eventObj);
});
});
};
})(jQuery);
$('html').delayed({delay: 5000,event: 'mousemove',fn: function(){
$("div.first").slideUp(300).delay(800).fadeIn(400);
$("div.second").slideUp(300).fadeIn(400);
}
});