Jump to content
Search Community

Trying to combine 2 independent animations

Joey Leon test
Moderator Tag

Go to solution Solved by Carl,

Recommended Posts

I've been learning GSAP's basics for a while and created a simple timeline for animations on my hero section. Next, I created a cycling text animation from Snorkl.tv's video. They both work independently, but when I try combine the two it's not working the way I want it to. I know theres an intermediate step I have to do to seamlessly combine the 2 but I can't figure out where to start.

Aim: animateElements triggers -> timeline with animations -> animations finish -> start cyclingText.

Problem: I think it's a css issue but when my timeline with animations start, my cycling text spans orginally start 'stacked' on top of one another, when I want only one of the spans to show itself on default.

I'm guessing this is a css issue, but if I change the css then I'm guessing the animation logic would have to change? A step to the right direction would be gladly appreciated.

Problem in question:
image.png.54eb0e291354a7939b4a0da52a6c48fd.png

See the Pen NWeEyBK by Joseph-Leonardi (@Joseph-Leonardi) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for the demo. You did a good job.

The main issue is that you aren't setting up your cycle timeline until after the headings slide in.

This caused you to see all the words on top of each other in their "pre-animated" state.

 

I did a few things 

  • I set the cycleWords function to return the timeline
  • I called the cycleWords function before the main timeline was built
  • I paused the cycleWords timeline at a time of 1 (this makes only the first word show)
  • I changed your onComplete callback on the main timeline to tell the cycle timeline to play

See the Pen BavGPpo?editors=0010 by snorkltv (@snorkltv) on CodePen

 

 

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