mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Interpolate the visibility
property correctly
This commit is contained in:
parent
f52df06a2a
commit
882ad4726e
Notes:
github-actions[bot]
2025-05-13 10:25:14 +00:00
Author: https://github.com/tcl3
Commit: 882ad4726e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4705
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 230 additions and 0 deletions
|
@ -169,6 +169,26 @@ ValueComparingRefPtr<CSSStyleValue const> interpolate_property(DOM::Element& ele
|
|||
return interpolate_value(element, calculation_context, from_value, to_value, delta);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/web-animations-1/#animating-visibility
|
||||
if (property_id == PropertyID::Visibility) {
|
||||
// For the visibility property, visible is interpolated as a discrete step where values of p between 0 and 1 map to visible and other values of p map to the closer endpoint.
|
||||
// If neither value is visible, then discrete animation is used.
|
||||
if (from->equals(to))
|
||||
return from;
|
||||
|
||||
auto from_is_visible = from->to_keyword() == Keyword::Visible;
|
||||
auto to_is_visible = to->to_keyword() == Keyword::Visible;
|
||||
|
||||
if (from_is_visible || to_is_visible) {
|
||||
if (delta <= 0)
|
||||
return from;
|
||||
if (delta >= 1)
|
||||
return to;
|
||||
return CSSKeywordValue::create(Keyword::Visible);
|
||||
}
|
||||
return delta >= 0.5f ? to : from;
|
||||
}
|
||||
|
||||
if (property_id == PropertyID::Scale)
|
||||
return interpolate_scale(element, calculation_context, from, to, delta);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue