I want replace default Fancybox1.3.4 image preloader (fancy_loading.png) with another preloader.
The Fancybox preloader coded not only in css, but also in javascript itself.
Seems, there are two places in javascript, at least:
_animate_loading = function() {
if (!loading.is(':visible')){
clearInterval(loadingTimer);
return;
}
$('div', loading).css('top', (loadingFrame * -40) + 'px');
loadingFrame = (loadingFrame + 1) % 12;
};
and
$.fancybox.showActivity = function() {
clearInterval(loadingTimer);
loading.show();
loadingTimer = setInterval(_animate_loading, 66);
};
$.fancybox.hideActivity = function() {
loading.hide();
};
So customizing the preloader will require modifying javascript too.
How can I change fancybox-1.3.4 javascript to set custom preloader image?
The CSS declaration is here:
They are using a sprite for the background image and changing the background-position to animate it. If you’re going to use a
loading.gifimage, then you won’t need to animate it.You need to change the
background-imagepath,height, andwidthto cater to your new image. You may want to comment out their JS code for the animation so that it doesn’t conflict.The
loading divis being declared here:You can either piggyback on the
loadingvariable or simply change the styling on#fancybox-loading. You’ll then need to remove any reference toloadingTimerandloadingFrame. Comment out this entire function:Modify the following function:
That should do it. You don’t want
loadingto have anysetIntervalon it since you won’t be animating it, but you do want it to hide/show conditionally.