Animate NonNegativeLength as its inner type

This commit is contained in:
Anthony Ramine 2018-02-15 10:54:03 +01:00
parent 52f0fcabad
commit d8c43ac855
3 changed files with 19 additions and 20 deletions

View file

@ -815,6 +815,20 @@ pub type LengthOrNormal = Either<Length, Normal>;
/// A wrapper of Length, whose value must be >= 0.
pub type NonNegativeLength = NonNegative<Length>;
impl ToAnimatedValue for NonNegativeLength {
type AnimatedValue = Length;
#[inline]
fn to_animated_value(self) -> Self::AnimatedValue {
self.0
}
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
NonNegativeLength::new(animated.px().max(0.))
}
}
impl NonNegativeLength {
/// Create a NonNegativeLength.
#[inline]