1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-29 03:08:45 +08:00

Fix scroll logic running before children may be alive in flow

This commit is contained in:
Dean Herbert 2020-10-29 18:51:54 +09:00
parent d69d78ab5d
commit 3491dea9e2

View File

@ -118,9 +118,10 @@ namespace osu.Game.Screens.Ranking
d.Origin = Anchor.Centre;
}));
if (IsLoaded)
{
if (SelectedScore.Value == score)
{
if (IsLoaded)
SelectedScore.TriggerChange();
}
else
@ -136,6 +137,7 @@ namespace osu.Game.Screens.Ranking
scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
}
}
}
return panel;
}
@ -170,12 +172,15 @@ namespace osu.Game.Screens.Ranking
expandedTrackingComponent.Margin = new MarginPadding { Horizontal = expanded_panel_spacing };
expandedPanel.State = PanelState.Expanded;
SchedulerAfterChildren.Add(() =>
{
// Scroll to the new panel. This is done manually since we need:
// 1) To scroll after the scroll container's visible range is updated.
// 2) To account for the centre anchor/origins of panels.
// In the end, it's easier to compute the scroll position manually.
float scrollOffset = flow.GetPanelIndex(expandedPanel.Score) * (ScorePanel.CONTRACTED_WIDTH + panel_spacing);
scroll.ScrollTo(scrollOffset);
});
}
protected override void Update()