RFR: 8236753: Animations do not play backwards after being stopped
nlisker at openjdk.java.net
Thu Jan 9 00:06:34 UTC 2020
The private field `lastPlayFinished` is responsible for 2 cases where an animation in `STOPPED` status does not play after `play()` is called if the rate is negative:
1. When the animation is created, it is `STOPPED` and `lastPlayFinished` is `false`. Setting a negative rate and calling `play()` will not jump to the end of the animation (in order to play it backwards) because the `if (lastPlayedFinished)` check is `false`. Creating the animation with `lastPlayFinished = true` fixes this.
2. When the animation is stopped (if it was not `STOPPED` already), `jumpTo(Duration.ZERO)` sets `lastPlayFinished` to `false`, which causes the same issue above with `play()`. Setting `lastPlayFinished = true` at the end `stop()` fixes this issue.
A test was added for case 2 to check that the playing head indeed jumps to the end of the animation. Without this fix, it stays at the start. Testing case 1 will require a new animation instance since the one in the test is used prior, but I'm not sure it's very helpful.
I'm still somewhat confused as to what constitutes a "last play finished". Any `jumpTo` resets `lastPlayFinished` to `false`, even if the jump is to the start/end of the animation. In this case, stopping an animation, jumping to its start/end, setting the rate to negative/positive, and playing, will do nothing as the end condition is reached immediately. This is what the behavior that was fixed for cases 1 and 2, but maybe this is also incorrect behavior for jumping to start/end.
A test app is included in the "parent" [bug](https://bugs.openjdk.java.net/browse/JDK-8210238), which also mentions a bug relating to **pausing** and playing backwards, so be mindful of it when testing.
- 3332a97f: Initial push of 8236753
Stats: 12 lines in 2 files changed: 10 ins; 0 del; 2 mod
Fetch: git fetch https://git.openjdk.java.net/jfx pull/82/head:pull/82
More information about the openjfx-dev