Jump to content


TimelineLite and loading

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

Simple question: Is it the case all images referenced in a TimelineLite sequence are loaded before the animation initiates?

Link to comment
Share on other sites

hello.. if I understand your question.. its always best whether your referencing an image for TweenLite or TimelineLite.. that the images be loaded first.

In this case its best to use the window load event to make sure the images are fully loaded before trying to animate them.

// native javascript way
window.load = function(){     
        // tween code goes here

// jQuery way
	// tween code goes here

this guarantees that your images are loaded before you try to do anything with them...

is that what you mean?

  • Like 2
Link to comment
Share on other sites



Jonathan is completely right. GSAP works on DOM elements, which in this case is the <img> tag, and a totally different thing is the image data which is ultimately what the user sees in the screen.


What you could do is use the window.load method or preload the images using a third party code. For the latter I recommend you David DeSandro's Images Loaded, works great, has no library dependencies and you can use it with JQuery's deferred object.




  • Like 2
Link to comment
Share on other sites

Thanks, guys! This is what I was after. Much appreciated. 

Link to comment
Share on other sites

One more question: the preloader animated gifs often accompanying loading image sequences, are these things generally handled with canvas manipulations? Any good tutorials you can recommend on this?

Link to comment
Share on other sites

you could create your own with canvas or use css and use GSAP to animate the element instead of css transitions..


or if you just want fast and simple you can use a regular animated gif from preloaders.net


using GSAP you could make a simple bar preloader like this:

var $box = $('div');
    tl = new TimelineMax({paused:true});
tl.add ( TweenMax.to($box, 3, { 
                ease: Linear.easeNone,
		onUpdateParams: ["{self}",$box],
		onUpdate: function(t,{
                        // gets the current timeline progress on each update
			var tlp = t.progress(); 
}), "mylabel" );


Link to comment
Share on other sites

Thanks so much, Jonathon. This is very helpful. 

Link to comment
Share on other sites

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.