So, the motion function that you go through in your example easeOutCubic, which is defined as
function easeOutCubic(t) {
t--;
return t * t * t + 1;
}
-, t speed * step , scrollToX. , t 1 . t 1, -1, (0,1). , scrollToX, (t-1)^3 + 1 , . , t , (t-1) , (t-1) 0, (t-1)^3 0 , (t-1)^3 + 1 1 . - , d^2((t-1)^3)/dt^2 < 0 t < 1, .
motion(t) 0 1, (xFrom-xTo), , .
( , ):
t - , scrollToX , scrollToX ( ), , . linearTween , .
t 0 0,02 0,04, motion(t) . motion(t), 0 1 ( , , 1) , (xFrom-xTo), t. , , , , xFrom, t.
:
xTo = 100
|
|
||
||
||
xFrom = 200
, 100. , (t) = 0,6 ( ). , (t) = 0,6, 200- (100) * 0,6 xFrom - (xFrom - xTo)*motion(t).