Jump to content

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

Using TweenMax.from (autoAlpha:0) shows a brief flash of the content

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

On my site, I am using a plugin inView, which calls a function when an element has come into view in the page.


There is a div in the middle of the page, and i'd like to use this to fade in it and come from the bottom 

TweenMax.from(element, 1.5, { autoAlpha: 0, y: 100, ease:Expo.easeOut })


The thing is it works, however if I quickly scroll down to this div, I'll see it for a millisecond, a quick flash....and then the effect starts.


I tried to use the .set function and set it to autoAlpha: 0...however now it doesn't even fade in at all.


Is there a solution to this problem? I'd like to use .from, however I do not want to see it flash quickly on the page before it starts the animation.

Link to comment
Share on other sites

Hi ejlee,


Welcome to GreenSock Forums.


It is difficult to guess from just looking at the code snippet you provided what the problem is.

Please provide a very basic CodePen demo as explained here: https://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/
In this pen I can´t see a problem - box #two with css 'visibility:hidden;':


See the Pen xrPvMw by mikeK (@mikeK) on CodePen


  • Like 2
Link to comment
Share on other sites

Hello @ejlee and welcome to the GreenSock forum!


Keep in mind that anytime you use autoAlpha is that you should add visibility: hidden to the element your tweening autoAlpha. This will prevent the brief flash your seeing of the element. And then autoAlpha will toggle the CSS property visibility: hidden to inherit and then animate opacity from 0 to 1.


Please see the CSSPlugin Docs: https://greensock.com/docs/Plugins/CSSPlugin

  • autoAlpha
    Identical to opacity except that when the value hits 0 the visibility property will be set to "hidden" in order to improve browser rendering performance and prevent clicks/interactivity on the target. When the value is anything other than 0, visibility will be set to "inherit". It is not set to "visible" in order to honor inheritance (imagine the parent element is hidden - setting the child to visible explicitly would cause it to appear when that's probably not what was intended). And for convenience, if the element's visibility is initially set to "hidden" and opacity is 1, it will assume opacity should also start at 0. This makes it simple to start things out on your page as invisible (set your css visibility:hidden) and then fade them in whenever you want.
//fade out and set visibility:hidden 
TweenLite.to(element, 2, {autoAlpha:0});  
//in 2 seconds, fade back in with visibility:visible 
TweenLite.to(element, 2, {autoAlpha:1, delay:2});


Here is an example of using autoAlpha

See the Pen iHdek by jonathan (@jonathan) on CodePen



  • Like 4
Link to comment
Share on other sites

Thanks guy! That was the problem.  I didn't have visibility :hidden on the css. 

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