blockui
blockui copied to clipboard
Add a fade in delay
For an application, that communicate with a server, i use blockUI when a request start and unblockUI when the request finish.
Many times the response arrive quick (less then 200 ms), in that case the blockUI flash a short time, that looks not so good (increasing fadeIn time is not the solution).
A delay for displaying could defuse the problem, e. g. i modify the code a little bit: (line 418)
if ((msie || opts.forceIframe) && opts.showOverlay)
lyr1.show(); // opacity is zero
if (opts.fadeIn) {
var cb = opts.onBlock ? opts.onBlock : noOp;
var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
var cb2 = msg ? cb : noOp;
// MOD: start
this.timer = setTimeout(function() {
if (opts.showOverlay)
lyr2._fadeIn(opts.fadeIn, cb1);
if (msg)
lyr3._fadeIn(opts.fadeIn, cb2);
}, opts.fadeInDelay);
// MOD: end
}
and on unblockUI clear the timer.
Or support specifying jQuery's easing functions.
if anyone needs this functionality, I added it to my copy of BlockUI in one of my projects. The source is here.