Skip to content

Commit 44e025b

Browse files
committed
Added sticky bottom scroll helper for expanding content in lists.
1 parent 724de2e commit 44e025b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

ui/widgets/scroll_area.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,18 @@ class ScrollArea : public RpWidgetBase<QScrollArea> {
253253

254254
};
255255

256+
template <typename Scroll>
257+
void SetStickyBottomScroll(
258+
not_null<Scroll*> scroll,
259+
not_null<RpWidget*> inner) {
260+
inner->heightValue(
261+
) | rpl::combine_previous(
262+
) | rpl::on_next([=](int previous, int height) {
263+
if (scroll->scrollTop() + scroll->scrollHeight() >= previous) {
264+
const auto visible = scroll->scrollHeight();
265+
scroll->scrollToY(height - visible, height);
266+
}
267+
}, inner->lifetime());
268+
}
269+
256270
} // namespace Ui

0 commit comments

Comments
 (0)