Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Nickbee

How to tell when tweenlite and css plugin is loaded and ready to use?

Recommended Posts

I'm working on a double click banner ad.  After an inital 40k polite load I'm going to be loading TweenLite.min.js and CSSPlugin.min.js, by adding it to the head. 

 

Is there an easy way to test when these two files are loaded and ready to go so I can start my animation? 

 

THANKS!!!

Link to comment
Share on other sites

Hi,

 

Is fairly simple and straight forward, just check the global namespace in order to see if the TweenLite and CSSPlugin methods exists (remember we're talking about objects so you should check them as properties of the window object), like this:

if(window.TweenLite && window.CSSPlugin){
  //start your banner animation
}
else{
  //perhaps start a setInterval to check for the assets to be loaded
}

Also you could try using an asset loader that has a callback to start the animations. There are several options that weight less than 3KB minified and using GZIP in the .HTACCESS file, I'm pretty sure your client won't have much objection with that.

 

Rodrigo.

  • Like 3
Link to comment
Share on other sites

Hi,

 

In addition (actually I should've remembered this when I wrote the first post), you can check if GSAP is already added in the page and, if it is, also check the version in order to load the version you need or not. Please check this thread:

 

http://greensock.com/forums/topic/9881-avoid-multiple-loaded-tweenmax-and-tweenlite/

  • Like 1
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.
×