Reputation: 5621
This should be easy, but for some reason I keep approaching it wrong.
I need to incrementally increase a base number, on a one to infinity scale.
I have a number representing in milliseconds the duration of an animation, starting at 750. I have another number, representing the number of elements we are skipping.
var animationDuration = 750;
var difference = Math.abs(currentPanelIndex - target); //somewhere from 1 - X
I need to increase animationDuration incrementally for each number in difference.
Upvotes: 2
Views: 290
Reputation: 5621
Solution:
Math.abs(currentPanelIndex - target) gives us our difference (animationDuration / 10) gives us an increment that is 1/10 of the standard duration
So: var currentDuration = Math.abs(currentPanelIndex - target) * (animationDuration / 10) + animationDuration;
Upvotes: 0