Jump to content
Search Community

jquery hover - gsap animation not working

knalle 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 have a looping animation on hover:

 

 

TweenMax.defaultOverwrite = "all";

 

$('#box a').hover(

function(){

$(this).addClass('hover'); // works

TweenMax.to( $("#box .arrowbar"), 0.5, {css:{left:7}, repeat:-1, ease:Linear.easeNone});

},

function(){

$(this).removeClass('hover'); // works

TweenMax.to( $("#box .arrowbar"), 0.5, {css:{left:7}});

}

);

 

 

It works on first mouseenter and mouseleave. What's wrong (using it in a html5boilerplate setup). Using Chrome atm.

Link to comment
Share on other sites

Both your Tweens tween box arrow's left to 7.

It's very possible that when you roll over a second time that box arrow already has a left of 7 so thus there is nothing for your new repeating tween to do.

 

If possible. Please upload a simple set of files with just enough CSS/HTML/js to replicate the issue.

 

Very likely something else may be causing it but tough to say without testing.

Link to comment
Share on other sites

Killing the tweens isn't the issue - it's just a logic flaw in your code. Your rollout tween is animating "left" to 7, but then when your rollover tween occurs again, it says "okay, I'll tween from....7 (current value)....to.....7 (destination value)" (no change). It is starting at exactly the same place you're asking it to end at. See what I mean?

 

Maybe you intended to have your rollout tween go to zero instead of 7, like:

TweenMax.to( $("#box .arrowbar"), 0.5, {css:{left:0}})

?

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