mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
animations: Finish support for fractional iteration counts
This change also improves support for creating animations with negative delays, as that is necessary to test support for fractional iteration lengths. This change also adjusts existing Servo animation tests which assumed that advancing to the exact moment of the end of the animation would be considered "before the end." With this change, this moment is "after the end." Fixes: #14858
This commit is contained in:
parent
99d409f15d
commit
954b5177f0
19 changed files with 163 additions and 101 deletions
|
@ -365,7 +365,7 @@ impl Animations {
|
|||
now: f64,
|
||||
pipeline_id: PipelineId,
|
||||
) {
|
||||
let num_iterations = match animation.iteration_state {
|
||||
let iteration_index = match animation.iteration_state {
|
||||
KeyframesIterationState::Finite(current, _) |
|
||||
KeyframesIterationState::Infinite(current) => current,
|
||||
};
|
||||
|
@ -381,10 +381,14 @@ impl Animations {
|
|||
TransitionOrAnimationEventType::AnimationStart => {
|
||||
(-animation.delay).max(0.).min(active_duration)
|
||||
},
|
||||
TransitionOrAnimationEventType::AnimationIteration |
|
||||
TransitionOrAnimationEventType::AnimationEnd => num_iterations * animation.duration,
|
||||
TransitionOrAnimationEventType::AnimationIteration => {
|
||||
iteration_index * animation.duration
|
||||
},
|
||||
TransitionOrAnimationEventType::AnimationEnd => {
|
||||
(iteration_index * animation.duration) + animation.current_iteration_duration()
|
||||
},
|
||||
TransitionOrAnimationEventType::AnimationCancel => {
|
||||
(num_iterations * animation.duration) + (now - animation.started_at).max(0.)
|
||||
(iteration_index * animation.duration) + (now - animation.started_at).max(0.)
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue