mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
LibWeb: Implement AnimationEffect::animation_direction()
This commit is contained in:
parent
2358f64d00
commit
d6fb1c24f6
2 changed files with 18 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibJS/Runtime/VM.h>
|
#include <LibJS/Runtime/VM.h>
|
||||||
|
#include <LibWeb/Animations/Animation.h>
|
||||||
#include <LibWeb/Animations/AnimationEffect.h>
|
#include <LibWeb/Animations/AnimationEffect.h>
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
@ -151,6 +152,16 @@ WebIDL::ExceptionOr<void> AnimationEffect::update_timing(OptionalEffectTiming ti
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/web-animations-1/#animation-direction
|
||||||
|
AnimationDirection AnimationEffect::animation_direction() const
|
||||||
|
{
|
||||||
|
// "backwards" if the effect is associated with an animation and the associated animation’s playback rate is less
|
||||||
|
// than zero; in all other cases, the animation direction is "forwards".
|
||||||
|
if (m_associated_animation && m_associated_animation->playback_rate() < 0.0)
|
||||||
|
return AnimationDirection::Backwards;
|
||||||
|
return AnimationDirection::Forwards;
|
||||||
|
}
|
||||||
|
|
||||||
AnimationEffect::AnimationEffect(JS::Realm& realm)
|
AnimationEffect::AnimationEffect(JS::Realm& realm)
|
||||||
: Bindings::PlatformObject(realm)
|
: Bindings::PlatformObject(realm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,11 @@ struct ComputedEffectTiming : public EffectTiming {
|
||||||
Optional<double> current_iteration;
|
Optional<double> current_iteration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class AnimationDirection {
|
||||||
|
Forwards,
|
||||||
|
Backwards,
|
||||||
|
};
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
|
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
|
||||||
class AnimationEffect : public Bindings::PlatformObject {
|
class AnimationEffect : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
|
||||||
|
@ -87,6 +92,8 @@ public:
|
||||||
JS::GCPtr<Animation> associated_animation() const { return m_associated_animation; }
|
JS::GCPtr<Animation> associated_animation() const { return m_associated_animation; }
|
||||||
void set_associated_animation(JS::GCPtr<Animation> value) { m_associated_animation = value; }
|
void set_associated_animation(JS::GCPtr<Animation> value) { m_associated_animation = value; }
|
||||||
|
|
||||||
|
AnimationDirection animation_direction() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AnimationEffect(JS::Realm&);
|
AnimationEffect(JS::Realm&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue