Jump to content
GreenSock

mthomson

Need to force Tween to complete

Go to solution Solved by Carl,

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've created some morphing icons that morph back and forth with different easing functions on .mouseenter() and .mouseleave() (using jQuery .hover method) 

 

I'd like to force the Tween in my hoverOver functions to complete before the hoverOff function is allowed to start.

 

 

I'm a little stumped on how to achieve this. Can anyone point me in the right direction of how to do this?

See the Pen qZoREQ by MandyMadeThis (@MandyMadeThis) on CodePen

Link to comment
Share on other sites

Hi mthomson :)

 

pls tween same property with hover over / out functions , currently you tween progress on over and time on out

  • Like 3
Link to comment
Share on other sites

  • Solution

Thanks for the demo. Nice effect you have there.

I had to cut a bunch of out to help see what was happening.

I also made the duration super long for testing purposes.

 

I think fromTo will help a lot here:

 

function hoverOver(){
        //put timeline into tween to add easing
        TweenMax.to(tl, 10, { progress: 1});
      }
      
      function hoverOff(){
        //send tl back to beginning with a differnt easing
        console.log("off");
       TweenMax.fromTo(tl, 0.25, {progress:1}, {progress:0, ease: Power2.easeIn});
      }
 
  • Like 4
Link to comment
Share on other sites

ah, I just saw Diaco's response. 

Yes, a problem was that while you were tweening time back to 0 the progress was still tweening to 1.

Link to comment
Share on other sites

Ah! Ok thank you so much for your fast and clear responses :)

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