1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

last section gets selected when scrolling to bottom of list

This commit is contained in:
Fukashi13 2020-05-15 14:03:45 +02:00
parent 097fcfd9ad
commit c55eb83351

View File

@ -189,23 +189,18 @@ namespace osu.Game.Graphics.Containers
headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0); headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0);
headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0; headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0;
T bestMatch = Children.FirstOrDefault();
float minDiff = float.MinValue;
float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0; float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0;
Func<T, float> diff = section => scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset;
foreach (var section in Children) if (scrollContainer.IsScrolledToEnd())
{ {
float diff = scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset; SelectedSection.Value = Children.LastOrDefault();
}
if (minDiff < diff && diff < 0) else
{ {
minDiff = diff; SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault()
bestMatch = section; ?? Children.FirstOrDefault();
}
} }
if (bestMatch != null)
SelectedSection.Value = bestMatch;
} }
} }