Jump to content
Search Community

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

Nickbee test
Moderator Tag

Go to solution Solved by Rodrigo,

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

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

  • Solution

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

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...