Jump to content
Search Community

Start animation once all images are loaded

Myows
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Posted

Hi

 

Sorry if this more a general js question, but your answer would be appreciated

 

I'm working on an animation and loving the gs TweenMax capacities

(work in progress here: http://max-guedy.com/animation-cofely/complet.html ) and I would like it to start only once all images have loaded, akin to adding a Flash preloader.

 

Could anyone please point me in the right direction?

 

Thanks in advance

Posted

Use the load event instead of `ready` to initialize your code.

 

$(window).on('load', function(){
 // code here
});

  • Like 1
Posted

Brilliant!

 

Thank you Dave (i've implemented on the link above)

 

Next question is what would the cleanest way be to hide the elements that are appearing... - would a display:none be my solution, the start the timeline with a display:visible ?

Posted

in your stylesheet add

 

#container {
 visibility: hidden;
}

 

In your script

 

$(window).on('load', function(){
 $('#container').css('visibility', 'visible');
 // code here
});

Posted

Hey Thanks Dave

 

I took a slightly different approach thanks to your 1st reply - visible on link above - gives it a preloader effect that fades out when the page is ready

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...