From e27c86fc49a315e34af4a1735c5d285a385df994 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Mon, 6 Mar 2017 17:52:58 +0800 Subject: [PATCH] Fix inaccurate input progress in the final animation frame. --- components/style/animation.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/style/animation.rs b/components/style/animation.rs index c69aca08bde..6eae69e8183 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -355,7 +355,15 @@ impl PropertyAnimation { TransitionTimingFunction::Frames(frames) => { // https://drafts.csswg.org/css-timing/#frames-timing-functions let mut out = (time * (frames as f64)).floor() / ((frames - 1) as f64); - if out > 1.0 && time <= 1.0 { + if out > 1.0 { + // FIXME: Basically, during the animation sampling process, the input progress + // should be in the range of [0, 1]. However, |time| is not accurate enough + // here, which means |time| could be larger than 1.0 in the last animation + // frame. (It should be equal to 1.0 exactly.) This makes the output of frames + // timing function jumps to the next frame/level. + // However, this solution is still not correct because |time| is possible + // outside the range of [0, 1] after introducing Web Animations. We should fix + // this problem when implementing web animations. out = 1.0; } out