Jump to content
Search Community

TimelineLite and loading

isaballoon test
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

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
$(window).on('load',function(){
	// 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

Yep

 

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.

 

Best

Rodrigo

  • Like 2
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(); 
			TweenMax.set(b,{scale:tlp});
		}							
}), "mylabel" );
tl.play(0);

:)

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.
×
×
  • Create New...