RFR: 8241582: Infinite animation does not start from the end when started with a negative rate
Kevin Rushforth
kcr at openjdk.java.net
Wed Apr 22 00:19:07 UTC 2020
On Fri, 10 Apr 2020 06:31:39 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
> ### Cause
>
> `Animation#jumpTo(Duration)` does not handle `Duration.INDEFINITE` properly. This causes
> `InfiniteClipEnvelope#jumpTo(long)` to receive an erroneous value and start the animation not from the end, depending
> on the modulo calculation. ### Fix
>
> For infinite cycles, use the `cycleDuration` as the destination since that is the effective end point.
>
> ### Tests
>
> * Added an `testJumpTo_IndefiniteCycles` test that fails without the patch and passes after it.
> * Added a `testJumpTo_IndefiniteCycleDuration` that passes both before and after, just to make sure that this type of
> infinite duration is correct.
> * Removed a test in `SequentialTransition` that fails with this patch, but it passed before it only because the modulo
> value happened to land in the right place. Changing the duration of one of the child animation can cause it to fail, so
> the test is faulty anyway at this stage.
>
> ### Future work
>
> Playing backwards will still not work correctly, but at least now it start from the correct value. This is the first of
> a series of fixes under the umbrella issue [JDK-8210238](https://bugs.openjdk.java.net/browse/JDK-8210238).
Looks good. I left a question about one of the tests (for my own curiosity), but I'm approving it anyway.
modules/javafx.graphics/src/test/java/test/javafx/animation/AnimationTest.java line 271:
> 270: animation.jumpTo("end");
> 271: assertEquals(Duration.millis(Long.MAX_VALUE / 6), animation.getCurrentTime());
> 272: }
Why `/ 6` ?
-------------
Marked as reviewed by kcr (Lead).
PR: https://git.openjdk.java.net/jfx/pull/169
More information about the openjfx-dev
mailing list