To show the loading animation programmatically, you need to do it in the active instance of FancyBox:
// Get the opened instance of fancybox
var instance = $.fancybox.getInstance();
or if you open ir programmatically:
// Get the initialized fancybox
var instance = $.fancybox.open({
// Your content and options
});
Then you could show or hide the loading animation for the instance like so:
instance.showLoading( slide );
instance.hideLoading( slide );
The loading animation must be shown/hidden on a specific slide.
To customize the loading animation, you can override the default loading template. Then the css is up to you:
// Changes the loading animation when opening a new instance
$.fancybox.open({
// Loading indicator template
spinnerTpl: '<div class="your-animation"></div>'
});
// Overrides the default template for all instances
$.fancybox.defaults.spinnerTpl: '<div class="your-animation"></div>';
You can find our more about FancyBox options and api methods here.
Hope it helps.