mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibWeb: Implement AnimationEffect's transformed_progress helper
This commit is contained in:
parent
611faf3645
commit
0d3c8a1cd9
Notes:
sideshowbarker
2024-07-17 09:49:33 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/0d3c8a1cd9 Pull-request: https://github.com/SerenityOS/serenity/pull/21871 Reviewed-by: https://github.com/alimpfard
@ -462,6 +462,31 @@ Optional<double> AnimationEffect::current_iteration() const
|
||||
return floor(overall_progress().value());
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#transformed-progress
|
||||
Optional<double> AnimationEffect::transformed_progress() const
|
||||
{
|
||||
// 1. If the directed progress is unresolved, return unresolved.
|
||||
auto directed_progress = this->directed_progress();
|
||||
if (!directed_progress.has_value())
|
||||
return {};
|
||||
|
||||
// 2. Calculate the value of the before flag as follows:
|
||||
|
||||
// 1. Determine the current direction using the procedure defined in §4.9.1 Calculating the directed progress.
|
||||
auto current_direction = this->current_direction();
|
||||
|
||||
// 2. If the current direction is forwards, let going forwards be true, otherwise it is false.
|
||||
auto going_forwards = current_direction == AnimationDirection::Forwards;
|
||||
|
||||
// 3. The before flag is set if the animation effect is in the before phase and going forwards is true; or if the animation effect
|
||||
// is in the after phase and going forwards is false.
|
||||
auto before_flag = (is_in_the_before_phase() && going_forwards) || (is_in_the_after_phase() && !going_forwards);
|
||||
|
||||
// 3. Return the result of evaluating the animation effect’s timing function passing directed progress as the input progress value and
|
||||
// before flag as the before flag.
|
||||
return m_timing_function(directed_progress.value(), before_flag);
|
||||
}
|
||||
|
||||
AnimationEffect::AnimationEffect(JS::Realm& realm)
|
||||
: Bindings::PlatformObject(realm)
|
||||
{
|
||||
|
@ -125,6 +125,7 @@ public:
|
||||
AnimationDirection current_direction() const;
|
||||
Optional<double> simple_iteration_progress() const;
|
||||
Optional<double> current_iteration() const;
|
||||
Optional<double> transformed_progress() const;
|
||||
|
||||
protected:
|
||||
AnimationEffect(JS::Realm&);
|
||||
|
Loading…
Reference in New Issue
Block a user