I want to move an element based on the velocity of a user's swipe. I have the easing function to make it start fast and get slower over time, but the one variable I need to calculate based on their swipe is totalTime
(or totalSteps
).
How would I calculate this?
What I know:
- The time they started the swipe
- The time and distance of each
touchmove
- The time the swipe ended (
touchend
)
From that I need to calculate how far to move them (the easing function will handle the distance of each individual step). How do i calculate this?
Easing function:
function easeOutCubic(currTime, beginningValue, change, duration)
{
return change * ( ( currTime = currTime / duration - 1 ) * currTime * currTime + 1 ) + beginningValue;
}
The change
is what i need to calculate.