Jump to content


window.onload + gsap animation won't play

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 have a landing page animation that i want to start after all the images and files have been downloaded.


So... my js file looks like this


  window.onload = function() {
  var main = new TimelineMax({paused:true});
  main.set($('.main__content'), {visibility: "visible"})
      .from($('.main__content img'), 0.3, {autoAlpha: 0, scale: 0, ease: Power4.easeOut})
      .staggerFrom($('.main__content h1 span'), 0.3, {autoAlpha: 0, ease: Power4.easeIn}, 0.15, 0)
      .from($('.main__content p'), 0.3, {autoAlpha: 0, ease: Power4.easeOut})
      .from($('.main__content .call-to-action'), 0.3, {autoAlpha: 0, y: 50, ease: Power1.easeOut})
      .from($('.main__social'), 0.3, {autoAlpha: 0, ease: Power4.easeOut})

and the '.main__content' has visibility : hidden in the css file


when the page loads, the main__content remains hidden... and the animation is not seen...


Any ideas what could be wrong.


If i  remove the gsap code from the window.onload function, it works fine, but i prefer to have the images load first.


Many thanks!

Link to comment
Share on other sites

Make a demo. It's very hard to troubleshoot stuff from a snippet.


The problem is most likely your onload assignment. See this post about not doing that for events. 

// Bad
window.onload = handler;

// Good
window.addEventListener("load", handler);
$(window).on("load", handler);
  • 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.