mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:17:26 +08:00
last section gets selected when scrolling to bottom of list
This commit is contained in:
parent
097fcfd9ad
commit
c55eb83351
@ -189,24 +189,19 @@ namespace osu.Game.Graphics.Containers
|
||||
headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0);
|
||||
headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0;
|
||||
|
||||
T bestMatch = Children.FirstOrDefault();
|
||||
float minDiff = float.MinValue;
|
||||
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;
|
||||
|
||||
if (minDiff < diff && diff < 0)
|
||||
SelectedSection.Value = Children.LastOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
minDiff = diff;
|
||||
bestMatch = section;
|
||||
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault()
|
||||
?? Children.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (bestMatch != null)
|
||||
SelectedSection.Value = bestMatch;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSectionsMargin()
|
||||
|
Loading…
Reference in New Issue
Block a user