mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 03:56:16 +00:00
LibWeb: Handle persisting an animation after it has been removed
This commit is contained in:
parent
a80af938eb
commit
6859826e3d
Notes:
sideshowbarker
2024-07-17 03:59:29 +09:00
Author: https://github.com/mattco98
Commit: 6859826e3d
Pull-request: https://github.com/SerenityOS/serenity/pull/24514
3 changed files with 16 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
||||||
persist() sets animation's replaceState to persist
|
persist() sets animation's replaceState to persist
|
||||||
|
persist() undoes the Document removal effects: true
|
||||||
Animations are properly replaced when covered by another animation
|
Animations are properly replaced when covered by another animation
|
||||||
persist() keeps an animation from being replaced
|
persist() keeps an animation from being replaced
|
||||||
|
|
|
@ -10,6 +10,14 @@
|
||||||
anim.persist();
|
anim.persist();
|
||||||
if (prevReplaceState === "active" && anim.replaceState === "persisted")
|
if (prevReplaceState === "active" && anim.replaceState === "persisted")
|
||||||
println("persist() sets animation's replaceState to persist");
|
println("persist() sets animation's replaceState to persist");
|
||||||
|
anim.cancel();
|
||||||
|
|
||||||
|
// "Undo" the removal of an animation by the Document
|
||||||
|
anim1 = foo.animate({ opacity: 0 }, { duration: 1, fill: 'forwards' });
|
||||||
|
anim2 = foo.animate({ opacity: 0 }, { duration: 1, fill: 'forwards' });
|
||||||
|
await anim1.finished;
|
||||||
|
anim1.persist();
|
||||||
|
println(`persist() undoes the Document removal effects: ${foo.getAnimations().length === 2}`);
|
||||||
|
|
||||||
const timeline = internals.createInternalAnimationTimeline();
|
const timeline = internals.createInternalAnimationTimeline();
|
||||||
let anim1 = foo.animate({ opacity: 0 }, { duration: 1000, fill: "forwards", timeline });
|
let anim1 = foo.animate({ opacity: 0 }, { duration: 1000, fill: "forwards", timeline });
|
||||||
|
|
|
@ -358,8 +358,6 @@ bool Animation::is_replaceable() const
|
||||||
|
|
||||||
void Animation::set_replace_state(Bindings::AnimationReplaceState value)
|
void Animation::set_replace_state(Bindings::AnimationReplaceState value)
|
||||||
{
|
{
|
||||||
m_replace_state = value;
|
|
||||||
|
|
||||||
if (value == Bindings::AnimationReplaceState::Removed) {
|
if (value == Bindings::AnimationReplaceState::Removed) {
|
||||||
// Remove the associated effect from its target, if applicable
|
// Remove the associated effect from its target, if applicable
|
||||||
if (m_effect && m_effect->target())
|
if (m_effect && m_effect->target())
|
||||||
|
@ -367,7 +365,14 @@ void Animation::set_replace_state(Bindings::AnimationReplaceState value)
|
||||||
|
|
||||||
// Remove this animation from its timeline
|
// Remove this animation from its timeline
|
||||||
m_timeline->disassociate_with_animation(*this);
|
m_timeline->disassociate_with_animation(*this);
|
||||||
|
} else if (value == Bindings::AnimationReplaceState::Persisted && m_replace_state == Bindings::AnimationReplaceState::Removed) {
|
||||||
|
// This animation was removed, but is now being "unremoved"; undo the effects from the if-statement above
|
||||||
|
if (m_effect && m_effect->target())
|
||||||
|
m_effect->target()->associate_with_animation(*this);
|
||||||
|
m_timeline->associate_with_animation(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_replace_state = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#dom-animation-onfinish
|
// https://www.w3.org/TR/web-animations-1/#dom-animation-onfinish
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue