Okay
  Public Ticket #771738
How to call the pre loader?
Closed

Comments

  • Heigler started the conversation

    Hello, is there a simple way to call the pre loader animation? I have some ajax calls, and I would like to call the same animation that happens between a common page loading.

  •  519
    Nikita replied

    Hi, Heigler.

    There is no api for it. Preloader animation removed after load. But you can add it manually. I think you can clone it on page and show/hide when needed. Try this code:

    jQuery(function ($) {
        // clone existing preloader
        var $preloader = $('.page-preloader').clone();
    
        setTimeout(function () {
            // insert to page (insert it only after main preloader is hidden, if you insert it before main preloader was hidden, this preloader content will be also removed after page load)
            $preloader.hide().appendTo('body');
    
            // show
            $preloader.fadeIn(300);
    
            // hide
            setTimeout(function () {
                $preloader.fadeOut(300);
            }, 5000);
        }, 10000);
    });
    

    Best regards, nK.

  • Heigler replied

    Worked! Thanks Nikita :)