Javascript animatio...
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

[Closed] Javascript animation equation

3 Posts
3 Users
0 Reactions
125 Views
Posts: 0
Free Member
Topic starter
 

I need to animate a DIV sliding left to right, but I want it to overshoot.

I have a variable, for the sake of argument X, that increments between 0 and 1 to represent the percentage complete. This is then used to multiply a second variable that holds the total distance that needs to be moved to create the animation.

I'd like to be able to pass X to a function that returns 0 when passed 0, 1 when passed 1, but at some point (around 0.85) over shoots 1. I hope that makes sense.

Can any point me in the direction of a suitable equation.

Thanks.


 
Posted : 30/06/2011 3:23 pm
Posts: 0
Free Member
 

something like

function incX(x)
{
if(x == 1){
return 1
}
if (x==0){
return 0
}
return (1.29 * x)

}

That syntax is probably wrong but its been a while since I've done javascript.


 
Posted : 30/06/2011 3:30 pm
 Bez
Posts: 7371
Full Member
 

Don't reinvent the wheel. Use JQuery.


 
Posted : 30/06/2011 4:36 pm
Posts: 0
Free Member
Topic starter
 

I've worked it out now. Can't use JQuery.


 
Posted : 30/06/2011 7:19 pm

6 DAYS LEFT
We are currently at 95% of our target!