Gubbels

Delay for fade in and separate delay for fade out

Recommended Posts

Hi.

This is my first time using Greensock, also I'm a  beginner in javascript.

I don't know if my code is beautiful or not, and I ask you to not pay too much attention to that aspect :P (or maybe you should, that'd help me)

 

Basically, everything is working as I want it to, there's just one minor change I want: 

Before the text fades out again, I want there to be a delay again. I don't know how or where to put that delay in.         

All suggestions are welcome : )

 

  • Like 2

Share this post


Link to post
Share on other sites

That's really well written actually.

 

To set delay before text fades out again, you can set repeatDelay property. You are setting delay in both from and to values but it will ignore delay in 'from' values.

 

 

On codepen you don't have to write entire HTML, you can add your scripts from settings and just write HTML body in codepen, rest is not needed.

  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi @Gubbels,


Welcome to the GreenSock Forum.

 

Here are a few tips in addition to the good advice from @Sahil.

 

You can build both animations in a TimelineMax and position both with a gap, starting same time or with an overlap (more info here).


You can use autoAlpha in the aspect opacity .

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


Instead of fromTo simply from (= defining the starting values), if the final properties are defined in css - for example css: font-size: 32px; and scale: 0.4.

 

 

Happy tweening ...

Mikel

 

 

  • Like 4
  • Thanks 1

Share this post


Link to post
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.