Jump to content
Search Community

TweenMax error after animations run

danboyle8637 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 do run a function to revert the SplitText after the animation is complete. Here's my code... 

 

useEffect(() => {
    const splitMobile = new SplitText(wordRef.current, { type: "chars" })
    const tl = new TimelineMax({ delay: 0.4 })
    const revertSplitMobile = () => splitMobile.revert()

    tl.add(
      TweenMax.staggerFrom(
        splitMobile.chars,
        0.4,
        {
          opacity: 0,
          scale: 0.6,
          y: 20,
          ease: Power2.easeOut,
        },
        0.05
      )
    )
    tl.add(
      TweenMax.staggerTo(
        splitMobile.chars,
        0.2,
        {
          color: "#6471BF",
          scale: 1.08,
          ease: Power2.easeIn,
        },
        0.05
      ),
      "-=0.5"
    )
    tl.add(
      TweenMax.staggerTo(
        splitMobile.chars,
        0.2,
        {
          color: "#383838",
          scale: 1,
          ease: Power2.easeOut,
        },
        0.05,
        "-=0.1"
      )
    )
    tl.add(revertSplitMobile)

    tl.play()
}, []}

 

Link to comment
Share on other sites

The one circled is not like the others. 

TweenMax.stagger To() does not use a position parameter. 

 

Id suggest using the timeline stagger methods instead of using add() with a TweenMax.staggerTo(). Much easier to to read and type. 

 

 

 

 

DD3DEB07-17D1-423D-A373-53BBEC08CFFE.jpeg

  • Like 4
Link to comment
Share on other sites

Carl beat me to it, but yeah, the position parameter is out of position in your code. It's sitting in the onCompleteAll spot.  This will work for you.

 

    tl.add(
      TweenMax.staggerTo(
        chars,
        0.2,
        {
          color: "#383838",
          scale: 1,
          ease: Power2.easeOut,
        },
        0.05
      ),
        "-=0.1"
    )

 

But I'd definitely echo @Carl's advice about not using the add() method. Happy tweening.

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