Jump to content
Search Community

How to stop a current running element based on a condition in a stagger?

wolfgangGrimmer 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

I'm playing around with this amazing library. What I'm currently doing is to stagger animate a list of words.

How do i stop the animation of a particular elem in the list while they're being animated one by one by TweenMax stagger method

Requirement:

  • If a condition  is met, i want to stop a particular element in the stagger.

See the Pen MWgjYJY?editors=1100 by chan-dev (@chan-dev) on CodePen

Link to comment
Share on other sites

46 minutes ago, wolfgangGrimmer said:

If a condition  is met, i want to stop a particular element in the stagger.

 

What's the condition, and how often is it being checked?

 

How would you stop an animation outside of a stagger? Same process. This returns an array of the animations in the stagger.

 

var tweens = TweenMax.staggerTo(wordsElem, 10, {
    top: '100%'
    // yPercent: 100 
}, 2);

// this will kill the second animation
tweens[1].kill();

 

 

  • Like 3
Link to comment
Share on other sites

Based on the codepen, what i'm planning to do is sort of a typing game where the user types and any word that matches the input will be removed from DOM or when any word has reached the end of the container, then stop the stagger animation altogether.

So the checking of condition would probably be invoked on every keypress.

 

Link to comment
Share on other sites

17 minutes ago, wolfgangGrimmer said:

Based on the codepen, what i'm planning to do is sort of a typing game where the user types and any word that matches the input will be removed from DOM or when any word has reached the end of the container, then stop the stagger animation altogether.

 

I see. I actually made a game like that many years ago, although I didn't use GSAP.

 

I would recommend checking out the docs for TweenMax.

https://greensock.com/docs/TweenMax

 

Here are some methods that you might find useful for this:

TweenMax.getTweensOf()

TweenMax.isTweening()

TweenMax.killTweensOf()

 

 

 

  • 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.
×
×
  • Create New...