2

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.

3
  • 1
    What's the incrementation for? What does it mean to "skip elements"? What is the animation doing? What are currentPanelIndex and target? Commented Oct 7, 2011 at 23:43
  • Base number? Skipped elements? I don't understand what you're asking -- can you show some pseudo-code of what you'd like to happen? How are animationDuration, currentPanelIndex and target related? (That's probably the core of your question, but they're too unobvious for me to understand so far.) Commented Oct 7, 2011 at 23:43
  • A bit more detail on your question would be useful, it's not quite clear what you're trying to achieve here. Commented Oct 8, 2011 at 0:45

2 Answers 2

2
  animationDuration = difference * increment ??
Sign up to request clarification or add additional context in comments.

Comments

0

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;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.