Scroll chat line to channel center

We may eventually want that encapsulated within `ScrollIntoView`, as it
would also come in handy for `GameplayLeaderboard`.
This commit is contained in:
Salman Ahmed
2022-03-10 02:49:23 +03:00
parent 93cf93943f
commit 80c0df6af5
3 changed files with 18 additions and 8 deletions

View File

@ -100,7 +100,8 @@ namespace osu.Game.Overlays.Chat
if (chatLine != null)
{
scroll.ScrollIntoView(chatLine);
float center = scroll.GetChildPosInContent(chatLine, chatLine.DrawSize / 2) - scroll.DisplayableContent / 2;
scroll.ScrollTo(Math.Clamp(center, 0, scroll.ScrollableExtent));
chatLine.ScheduleHighlight();
}