virtual_list: Avoid scroll when list contents not overflow. (#1125)
- Fix scrollbar position in popup menu.
This commit is contained in:
parent
b1f4a4f642
commit
7f64f8798e
3 changed files with 40 additions and 20 deletions
|
|
@ -217,24 +217,43 @@ impl Render for MenuStory {
|
|||
}),
|
||||
)
|
||||
.child(
|
||||
section("Menu with scrollbar").child(
|
||||
Button::new("popup-menu-11112")
|
||||
.outline()
|
||||
.label("Scrollable Menu")
|
||||
.popup_menu_with_anchor(Corner::TopRight, move |this, _, _| {
|
||||
let mut this = this
|
||||
.scrollable()
|
||||
.max_h(px(300.))
|
||||
.label(format!("Total {} items", 100));
|
||||
for i in 0..100 {
|
||||
this = this.menu(
|
||||
SharedString::from(format!("Item {}", i)),
|
||||
Box::new(Info(i)),
|
||||
)
|
||||
}
|
||||
this.min_w(px(100.))
|
||||
}),
|
||||
),
|
||||
section("Menu with scrollbar")
|
||||
.child(
|
||||
Button::new("popup-menu-scrollable-1")
|
||||
.outline()
|
||||
.label("Scrollable Menu (100 items)")
|
||||
.popup_menu_with_anchor(Corner::TopRight, move |this, _, _| {
|
||||
let mut this = this
|
||||
.scrollable()
|
||||
.max_h(px(300.))
|
||||
.label(format!("Total {} items", 100));
|
||||
for i in 0..100 {
|
||||
this = this.menu(
|
||||
SharedString::from(format!("Item {}", i)),
|
||||
Box::new(Info(i)),
|
||||
)
|
||||
}
|
||||
this.min_w(px(100.))
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
Button::new("popup-menu-scrollable-2")
|
||||
.outline()
|
||||
.label("Scrollable Menu (5 items)")
|
||||
.popup_menu_with_anchor(Corner::TopRight, move |this, _, _| {
|
||||
let mut this = this
|
||||
.scrollable()
|
||||
.max_h(px(300.))
|
||||
.label(format!("Total {} items", 100));
|
||||
for i in 0..5 {
|
||||
this = this.menu(
|
||||
SharedString::from(format!("Item {}", i)),
|
||||
Box::new(Info(i)),
|
||||
)
|
||||
}
|
||||
this.min_w(px(100.))
|
||||
}),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -942,8 +942,8 @@ impl Render for PopupMenu {
|
|||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.right_0p5()
|
||||
.bottom_0p5()
|
||||
.right_0()
|
||||
.bottom_0()
|
||||
.child(Scrollbar::vertical(&self.scroll_state, &self.scroll_handle)),
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -548,6 +548,7 @@ impl Element for VirtualList {
|
|||
scroll_to_item,
|
||||
);
|
||||
}
|
||||
scroll_offset = scroll_offset.min(&point(px(0.), px(0.)));
|
||||
|
||||
self.base.interactivity().prepaint(
|
||||
global_id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue