Jump to content
Search Community

Stop looping animation and make it disappear

Chrigu test
Moderator Tag

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
I'm new to Greensock's amazing library and as such I'm struggling with some basic problems/concepts.

 

I have a rain animation that is in a infinite loop. When the user clicks a button I would like to stop the animation gracefully and play the next one.

 

By gracefully I mean the following:

  1. Animation repeats one more time
  2. Rains disappears
  3. Rains stays hidden

 

My current solution is the following: When the user clicks on the button, I set repeat to 1 on all tweens.

  const tweens = TweenMax.getTweensOf('.raindrop')
  tweens.map(tween => tween.repeat(1))

 

This stops the animation, but the problem is, that the rain appears again after the animation has stopped. I guess it's because I use the clearProps property on the opacity.

 

  const opacitySettings = {
    opacity: 0,
    ease: Linear.easeNone,
    clearProps: 'opacity',
    repeat: -1
  };

 

How could I achieve the required behaviour?

 

Thanks in advance as I'm really stuck!

 

See the Pen qYabKy by chriguc (@chriguc) on CodePen

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