Skip to content

Commit 5c98640

Browse files
committed
wip scroll: Show start of latest message if long, instead of end; TODO test
TODO test, inter alia: clamp min, clamp max This makes our first payoff in actual UX from having the message list split into two back-to-back slivers! With this change, if you open a message list and the latest message is very tall, the list starts out scrolled so that you can see the top of that latest message -- plus a bit of context above it (25% of the viewport's height). Previously the list would always start out scrolled to the end, so you'd have to scroll up in order to read even the one latest message from the beginning. In addition to a small UX improvement now, this makes a preview of behavior we'll want to have when the bottom sliver starts at the first unread message, and may have many messages after that. This new behavior is nice already with one message, if the message happens to be very tall; but it'll become critical when the bottom sliver is routinely many screenfuls tall.
1 parent c072738 commit 5c98640

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/widgets/scrolling.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,13 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
326326

327327
if (initial) {
328328
// The list is being laid out for the first time.
329-
// Start out scrolled to the end.
329+
// Start out scrolled down so the bottom sliver (the new messages)
330+
// occupies 75% of the viewport,
331+
// or at the in-range scroll position closest to that.
330332
// TODO what if the next _attemptLayout iteration finds more items below
331333
// and makes maxScrollExtent bigger?
332-
correctPixels(maxScrollExtent);
334+
correctPixels(clampDouble(0.75 * viewportDimension,
335+
minScrollExtent, maxScrollExtent));
333336
changed = true;
334337
}
335338

0 commit comments

Comments
 (0)