Jump to content
Search Community

Relative position mismatch

Tweenrookie test
Moderator Tag

Recommended Posts

b1.onPress = function () {
    TweenLite.to (cds, 3, {_y:"-500", ease:Power2.easeInOut} );
}

 

I am designing a presentation with a column of cds covers i want the user to skim through each time he/she clicks on button "b1".As you can see each image is 500 pxs away from the next. the problem is that if the user press button "b1" BEFORE the transition has completed, the tween is called again, and therefore a mismatch occurs. 

 

How can this be solved?

 

 

 

Link to comment
Share on other sites

The simplest change would probably be to use absolute tweens instead. You can achieve a relative effect doing something like:

currentY = cds._y; // starting position of cds
yDif = -500;       // amount to 'relatively' adjust _y
b1.onPress = function() {
  TweenLite.to(cds, 3, {_y:(currentY += yDif), ease:Power2.easeInOut});
}

This should keep all _y values as a factor of 500 regardless of someone clicking through quickly. Also, if you need to go in reverse you can just use _y:(currentY -= yDif)
 
Alternatively, you could manage a currentItem index for which cover you are currently looking at, and use _y:(currentItem * yDif)

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