I've got a side scrolling web site under jQuery control, with several pages that are thousands of pixels apart, horizontally. I'm using the easeOutElastic function, but the animation happens way to fast and the elastic bounce needs to be dampened. If I increase the duration parameter, the animation slows, but so does the bounce. It seems the duration controls the entire animation.
What I need to do is control the speed of the move and the tightness of the elasticity separately. I've been fiddling with my own copy of that easeOutElastic function in a plugin, but I cannot seem to get it right, not knowing what all the parameters are:
easeOutElastic: function (x, t, b, c, d) {
var s=1.70158;
var p=0;
var a=c;
if (t==0) return b;
if ((t/=d)==1) return b+c;
if (!p) p=d*.3;
if (a < Math.abs(c)) {
a=c;
var s=p/4;
}else{
var s = p/(2*Math.PI) * Math.asin (c/a);
}
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
}
Can any one tell me what the parameters: x, t, b, c, d represent?
I assume (tracing the function):
t = time // passed from the duration
d = distance // calculated from the current and move to positions passed from the css
It looks like when t == 0 the easing function is finished, but what I really need is for the function to return when the velocity of the motion is below some threshold, rather than waiting for time to expire. But where is velocity calculated? ( s ? )
Any help you can give deciphering this would be great!
Might I suggest a work-around? Use two animation calls, one for moving the element most of the distance and one for the final "bounce" effect. That way you can change the duration for the "bounce" effect to look as you want and also have the horizontal scroll motion as fast as you want.