mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Adjust scroll behaviour to feel better
This commit is contained in:
@ -112,7 +112,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The percentage of the container to consider the centre-point for deciding the active section (and scrolling to a requested section).
|
/// The percentage of the container to consider the centre-point for deciding the active section (and scrolling to a requested section).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const float scroll_y_centre = 0.2f;
|
private const float scroll_y_centre = 0.1f;
|
||||||
|
|
||||||
public SectionsContainer()
|
public SectionsContainer()
|
||||||
{
|
{
|
||||||
@ -147,10 +147,22 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
public void ScrollTo(Drawable target)
|
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)
|
if (target is T section)
|
||||||
lastClickedSection = section;
|
lastClickedSection = section;
|
||||||
|
|
||||||
scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre - (FixedHeader?.BoundingBox.Height ?? 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollToTop() => scrollContainer.ScrollTo(0);
|
public void ScrollToTop() => scrollContainer.ScrollTo(0);
|
||||||
|
Reference in New Issue
Block a user