Round halfway values toward positive infinity for integer type of animation.

From the spec[1];

 `with values halfway between a pair of integers rounded towards positive infinity.`

[1] https://drafts.csswg.org/css-transitions/#animtype-integer
This commit is contained in:
Hiroyuki Ikezoe 2017-08-15 13:04:21 +09:00
parent bff67d8272
commit 08ebc524cf

View file

@ -863,7 +863,7 @@ impl Animatable for f64 {
impl Animatable for i32 {
#[inline]
fn add_weighted(&self, other: &i32, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
Ok((*self as f64 * self_portion + *other as f64 * other_portion).round() as i32)
Ok((*self as f64 * self_portion + *other as f64 * other_portion + 0.5).floor() as i32)
}
}