PreLoader wont run on Page Refresh
Hi all,
I have implemented a preloader for my site, it uses GSAP and a timeout function to ensure that the animation runs, even if the page has loaded (quickly).
However, upon uploading to the server (www.ainsleyclark.com), I have encountered that the preloader doesn't run on page refresh, I can only assume that this has something to do with the set timeout function but cant figure it out.
Many thanks in advance.
- /*
- PreLoader
- */
- $("#preloader svg").removeClass("hidden");
- $("#preloader h1").removeClass("hidden");
- $(window).on('load', function() {
- //Header Animation
- TweenLite.from("#preloader h1", 0.6, {
- y: -40,
- opacity: 0,
- ease: Sine.easeIn
- })
- //PreLoader Logo Animation
- var preLoaderTL = new TimelineMax({
- repeat: 2,
- yoyo: true,
- repeatDelay: 1
- });
- preLoaderTL
- .to("#left_logo", 0.6, {
- strokeDashoffset: 0,
- ease: Sine.easeIn
- })
- .to("#slash", 0.6, {
- strokeDashoffset: 0,
- ease: Sine.easeIn
- }, "-=0.4")
- .to("#right_logo", 0.6, {
- strokeDashoffset: 0,
- ease: Sine.easeIn
- }, "-=0.4")
- //Sets a timeout for the preloader so it doesnt load too early.
- setTimeout(function() {
- $('#about, #skills, #contact').show();
- TweenLite.to("#preloader h1", 0.6, {
- y: 40,
- opacity: 0,
- ease: Sine.easeIn
- });
- $("#preloader").fadeOut('slow', function() {
- drawLogoTL.play();
- homeBannerTL.play();
- });
- }, 3000);
- });