scroll-fade
Builds ScrollArea ScrollFade


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn scroll_fade(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
crate::layout::scroll_to("scene.fade.output", gpui::point(px(0.0), px(120.0)), cx);
stack(&theme)
.w(px(480.0))
.child(caption(&theme, "Scrolled: content runs past both ends"))
.child(
div()
.hairline(&theme)
.radius(&theme, Radius::Card)
.overflow_hidden()
.child(
ScrollFade::new("scene.fade.scrolled")
.edges(FadeEdges::vertical())
.fit_height()
.child(
ScrollArea::new("scene.fade.output")
.label("Run output")
.vertical()
.height(200.0)
.child(filler(&theme, "Output", 20)),
),
),
)
// Nothing is hidden here, so no edge fades and the caller says so.
.child(caption(&theme, "Nothing hidden: no edge fades"))
.child(
div()
.hairline(&theme)
.radius(&theme, Radius::Card)
.overflow_hidden()
.child(
ScrollFade::new("scene.fade.settled").fit_height().child(
ScrollArea::new("scene.fade.summary")
.label("Summary")
.vertical()
.height(120.0)
.child(filler(&theme, "Summary", 2)),
),
),
)
.into_any_element()
}