Skip to content

Commit

Permalink
Round halfway values toward positive infinity for integer type of ani…
Browse files Browse the repository at this point in the history
…mation.

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
  • Loading branch information
Hiroyuki Ikezoe committed Aug 15, 2017
1 parent bff67d8 commit 08ebc52
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 08ebc52

Please sign in to comment.