Lightbox Preloader shows after page is loaded

Hello,

Please can anyone help me with a better code that will make my lightbox preloader show properly while the page is still loading. The one i have now will only Show after the main page has finished loading thereby not achieving the purpose i need it for.

Below is the sample of the code i am using, is there anything wrong with it?

import wixWindow from ‘wix-window’;
$w.onReady(() => {
waitForLoading();
});
export function button6_onClick() {
wixWindow.openLightbox(“preloaderLightbox”);
}
function waitForLoading() {
setTimeout(() => {
wixWindow.lightbox.close();
}, 1500);
}

Some one please help with a better code.
Thanks.

Hey,

There’s an official example article explaining how you can achieve this with WixCode:

It’s similar to what you’re doing but basically you cover your screen with Box element and add your loader element to this Box. And hide this box element with animation once site is done loading.

Best regards,
Max

Hello Makaim,

I know that example and i have looked at it.
But i was also made to understand that the same process can be achieved with a Lightbox which makes the process look more professional and better.

With this method (Lightbox) i only need to create one Ligthbox and set that lightbox to show on some of pages.

The only problem i am having with this is that IT WILL NOT LOAD UNTIL THE PAGE ITSELF IS FULLY LOADED thereby defeating the purpose of a Preloader in the first place.

I am thinking that a faulty action in the code is responsible for this behavior. I need help in making sure that the preloader appears before the page(s) where it is suppose to appear Loads at all.

Can you or any one else help me correct the code to achieve that???

I will be very grateful.

Regards,
William

The link is now broken. Could you fix?

@marius-pop This example is no longer available. Please create a new post with the details of what you are trying to build and your code so the community can assist.