Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
_Tron_

tween slowing down after multiple mouseenter/leave events

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 was just playing around and for some reason, even though I kill all tweens after the mouse leaves the element, it slows down the tween over time...

 

http://jsfiddle.net/Lightning_II/A6jRp/17/

 

I realize somehow its stacking or the tween is conflicting with itself but shouldn't the kill stop it from doing that?

$(".category").hover(
function(){
 TweenMax.to($(this), .2, {autoAlpha:1});
 TweenMax.to($(this).parent().children(".region-icon"), 2,  {rotation:"360_cc", ease:"Linear.easeNone",repeat:-1});
},


function(){
 TweenMax.to($(this), .2, {autoAlpha:.8});
 TweenMax.killTweensOf($(this).parent().children(".region-icon"));
});

 

Link to comment
Share on other sites

Hi Tron

 

The problem is you are always tweening to an absolute rotation of 360 with a tween that is always 2 seconds long.

 

Imagine the first time you rollover the object starts rotating from rotation 0 to rotation 360 BUT you rollout once the rotation reaches 270.

 

At this point all tweens are killed.

 

The next time you rollover a new tween is created that has a duration of 2 seconds and it rotates now from 270 to 360, much less distance to travel with the same 2 second duration; so yes it appears slower and the repeat is also going to look junky. 

 

The trick here would be to use a relative value so that the object always rotates 360 degrees more than the current rotation. The syntax is:

 

TweenMax.to($(this).parent().children(".region-icon"), 2,  {rotation:"+=360_cw", ease:"Linear.easeNone",repeat:-1});

 

updated fiddle: http://jsfiddle.net/m5bFm/1/

 

also, you were using 360_cc, _cc isn't a valid suffix. Sure it was just a typo but use _cw or _ccw.

  • Like 3
Link to comment
Share on other sites

Ah! Thank you so much! I should have realized that simple mistake. 

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