1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:13:00 +08:00

Prefer ScrollTo in SectionsContainer.

This commit is contained in:
Huo Yaoyuan 2017-07-14 22:56:27 +08:00
parent 6cf36da389
commit 26b36c08a3
2 changed files with 2 additions and 11 deletions

View File

@ -139,16 +139,7 @@ namespace osu.Game.Graphics.Containers
originalSectionsMargin = scrollContentContainer.Margin;
}
public void ScrollToTop(T section)
{
float pos = scrollContainer.GetChildPosInContent(section);
float current = scrollContainer.Current;
float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0;
if (section == Children.First() && current < pos - scrollOffset) return;
scrollContainer.ScrollTo(pos - scrollOffset);
}
public void ScrollTo(Drawable section) => ScrollContainer.ScrollTo(ScrollContainer.GetChildPosInContent(section) - FixedHeader.BoundingBox.Height);
public void ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0));
private float lastKnownScroll;
protected override void UpdateAfterChildren()

View File

@ -137,7 +137,7 @@ namespace osu.Game.Overlays
if (lastSection != s)
{
lastSection = s;
sectionsContainer.ScrollToTop(lastSection);
sectionsContainer.ScrollTo(lastSection);
}
};