add list
This commit is contained in:
@@ -31,7 +31,6 @@ full = [
|
||||
"tooltip",
|
||||
"menu",
|
||||
"dialog",
|
||||
"sheet",
|
||||
"toast",
|
||||
]
|
||||
button = []
|
||||
@@ -49,5 +48,4 @@ scroll_area = []
|
||||
tooltip = []
|
||||
menu = ["scroll_area"]
|
||||
dialog = []
|
||||
sheet = []
|
||||
toast = []
|
||||
|
||||
@@ -122,6 +122,7 @@ impl RenderOnce for ScrollArea {
|
||||
pane.extend(self.children);
|
||||
|
||||
let mut wrapper = div().relative();
|
||||
wrapper.style().refine(&self.style);
|
||||
wrapper.extend(std::iter::once(pane.into_any_element()));
|
||||
|
||||
if let Some(handle) = self.handle {
|
||||
|
||||
@@ -94,3 +94,57 @@ fn the_thumb_paints_when_the_content_overflows() {
|
||||
// 30 rows × 20px in a 200px viewport: the thumb has something to report.
|
||||
assert!(handle.max_offset().y > px(0.));
|
||||
}
|
||||
|
||||
/// The gallery's exact shell: a window-filling root, a window-filling scroll
|
||||
/// area over padded flex-column content that towers past the viewport.
|
||||
struct GalleryShell {
|
||||
scroll: ScrollHandle,
|
||||
}
|
||||
|
||||
impl Render for GalleryShell {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div().size_full().child(
|
||||
ScrollArea::new("gallery-scroll")
|
||||
.handle(self.scroll.clone())
|
||||
.size_full()
|
||||
.child(
|
||||
div()
|
||||
.p_6()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_5()
|
||||
.children((0..12).map(|section| {
|
||||
div()
|
||||
.h(px(220.))
|
||||
.child(SharedString::from(format!("section {section}")))
|
||||
})),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_gallery_style_window_fill_scroll_area_scrolls_tall_flex_content() {
|
||||
let mut cx = TestAppContext::single();
|
||||
cx.update(Theme::init);
|
||||
let handle = ScrollHandle::new();
|
||||
let handle_for_view = handle.clone();
|
||||
let window = cx.add_window(move |_, _| GalleryShell {
|
||||
scroll: handle_for_view,
|
||||
});
|
||||
let mut visual = VisualTestContext::from_window(window.into(), &cx);
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
|
||||
// 12 sections × 220px + padding towers past the window; a wheel event
|
||||
// over the middle of the viewport must scroll the root area.
|
||||
visual.simulate_event(ScrollEvent {
|
||||
position: point(px(300.), px(300.)),
|
||||
delta: ScrollDelta::Pixels(point(px(0.), px(-60.))),
|
||||
modifiers: Modifiers::default(),
|
||||
..Default::default()
|
||||
});
|
||||
assert_eq!(handle.offset().y, px(-60.));
|
||||
assert!(handle.max_offset().y > px(1000.));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user