From 34cd4a1f10c01c030396454fffb331cc54ecc107 Mon Sep 17 00:00:00 2001 From: bmiit145 <21bmiit145@gmail.com> Date: Fri, 1 Mar 2024 13:55:03 +0530 Subject: [PATCH] correction loader timeout --- js/main.js | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/js/main.js b/js/main.js index bdf080f..b631c92 100644 --- a/js/main.js +++ b/js/main.js @@ -30,28 +30,40 @@ // loader //for testing - - // var loader = function() { - // setTimeout(function() { - // if($('#ftco-loader').length > 0) { - // $('#ftco-loader').removeClass('show'); - // } - // }, 100000); - // }; - // loader(); - - window.addEventListener("load", function() { - var loader = document.querySelector("#ftco-loader"); - var timeoutId = setTimeout(function() { - loader.style.display = "none"; - }, 5000); - // Clear the timeout if the page finishes loading before 5 seconds - window.addEventListener("load", function() { - clearTimeout(timeoutId); - loader.style.display = "none"; + $(document).ready(function() { + var loader = $('#ftco-loader'); + + // Function to hide the loader + var hideLoader = function() { + loader.fadeOut(); + }; + + // Hide the loader if content or window is already loaded + $(window).on('load', function() { + hideLoader(); }); + + // Set a timeout to hide the loader after 5 seconds + setTimeout(function() { + hideLoader(); + }, 5000); }); + + // loader + + // window.addEventListener("load", function() { + // var loader = document.querySelector("#ftco-loader"); + // var timeoutId = setTimeout(function() { + // loader.style.display = "none"; + // }, 5000); + // + // // Clear the timeout if the page finishes loading before 5 seconds + // window.addEventListener("load", function() { + // clearTimeout(timeoutId); + // loader.style.display = "none"; + // }); + // }); // Scrollax