What the Duration of negative Infinity mean?

Thu Jan 31 09:42:38 PST 2013

```The other option is not to throw the exception and keep the Duration
values above zero. If a > b, then b.subtract(a) will result in 0.

So let's say currentTime of the animation is 1s. We'd have a button that
jumps 2 seconds backwards in the animation.

So something like
animation.jumpTo(animation.getCurrentTime().subtract(Duration.seconds(2)));
would result in calling animation.jumpTo with Duration of zero, which
makes sense.

However, with the negative values and going backwards, it actually gets
quite complicated. Negative rates goes backwards, but goes from positive
Duration to 0. So in order to start the animation backwards you havo to
then start the animation with negative rate (animation.setRate(-1.0);
animation.play(); ). But what if we set duration to negative? Will the
total duration be also negative and will go from 0 to negative number?
This might break some code as so far it was reasonable to expect that
with positive rate, the next position in the animation will be greater
than the previous. And what about set animations with mixed
positive/negative durations in an sequential/parallel animation? What
would be the duration of the parent animation?

Or will setting a negative duration set the duration to  positive value
and automatically set the rate to negative?
I don't think we need negative durations then, as the durations that
animations will work with will be only positive.

What do you think?

-Martin

On 01/31/2013 05:23 PM, Richard Bair wrote:
>>> How does the animation code handle negative duration values?
>> It doesn't handle negative values at all. All code in animations expects the duration to be positive.
> It seems like we have to allow for negative durations for the sake of:
>
> Duration d1 = Duration.seconds(3);
> Duration d2 = Duration.seconds(-1);