Jump to content


Fading in page

Go to solution Solved by Ihatetomatoes,

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

Hi there,


On page load I am trying to fade in the body and then once this completes all my other animations start. I have this working, but on page load the page shows very quickly and then hides as per my TweenMax.set


An example URL is here



At the above URL I have resorted to placing inline CSS right at the start of the page to hide the body so that it doesnt flicker but I am just concerned that hiding it with CSS and then animating it in with JS may not be the best as it is relying on JS to solve the issue? Or is this OK to do?

See the Pen by marketing (@marketing) on CodePen

Link to comment
Share on other sites

  • Solution

Hi grantambrose,

this is a quite common issue when animating elements on page load.


Your approach with hiding body by default using inline CSS is the right one.


I would suggest adding a class to the body instead of the inline styles and then remove this class using the .set() method.

<body class="loading">
body {
    transition: all 0.3s linear;
.loading {
    opacity: 0;
    visibility: hidden;
TweenMax.set($('body'), {className: '-=loading'});

You can use the CSS3 transition inside of the body to define the right fading duration.


If you are concerned about the users without JS not being able to see anything, then you can use modernizr class .no-js and turn the visibility and opacity on like this:

.no-js .loading {
    opacity: 1;
    visibility: visible;

Just wanted to share my approach, that you might find useful.





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