Fix inaccurate input progress in the final animation frame.

This commit is contained in:
Boris Chiou 2017-03-06 17:52:58 +08:00
parent f1feddf52c
commit e27c86fc49

View file

@ -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