1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 16:12:54 +08:00

Adjust scroll behaviour to feel better

This commit is contained in:
Dean Herbert 2021-08-20 17:40:56 +09:00
parent 2d19f37dc6
commit 03e6ca5ba9

View File

@ -112,7 +112,7 @@ namespace osu.Game.Graphics.Containers
/// <summary>
/// The percentage of the container to consider the centre-point for deciding the active section (and scrolling to a requested section).
/// </summary>
private const float scroll_y_centre = 0.2f;
private const float scroll_y_centre = 0.1f;
public SectionsContainer()
{
@ -147,10 +147,22 @@ namespace osu.Game.Graphics.Containers
public void ScrollTo(Drawable target)
{
lastKnownScroll = null;
float fixedHeaderSize = FixedHeader?.BoundingBox.Height ?? 0;
// implementation similar to ScrollIntoView but a bit more nuanced.
float top = scrollContainer.GetChildPosInContent(target);
var bottomScrollExtent = scrollContainer.ScrollableExtent - fixedHeaderSize;
if (top > bottomScrollExtent)
scrollContainer.ScrollToEnd();
else
scrollContainer.ScrollTo(top - fixedHeaderSize - scrollContainer.DisplayableContent * scroll_y_centre);
if (target is T section)
lastClickedSection = section;
scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre - (FixedHeader?.BoundingBox.Height ?? 0));
}
public void ScrollToTop() => scrollContainer.ScrollTo(0);