mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Merge pull request #9023 from Fukashi13/sections-container-fix
Fix overlay section display highlighting wrong section
This commit is contained in:
commit
490b6dbd7a
@ -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 = null;
|
|
||||||
float minDiff = float.MaxValue;
|
|
||||||
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 = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset);
|
SelectedSection.Value = Children.LastOrDefault();
|
||||||
|
}
|
||||||
if (diff < minDiff)
|
else
|
||||||
{
|
{
|
||||||
minDiff = diff;
|
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault()
|
||||||
bestMatch = section;
|
?? Children.FirstOrDefault();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestMatch != null)
|
|
||||||
SelectedSection.Value = bestMatch;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user