Use new engine APIs for setting the scroll target of views (#35401)
This commit is contained in:
committed by
GitHub
parent
3192914fc5
commit
cbecc4cc4b
@@ -372,14 +372,11 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
||||
if (!_tryToScrollToListFocus)
|
||||
return;
|
||||
|
||||
if (!TryGetVerticalScrollbar(SensorScroller, out var vScrollbar))
|
||||
return;
|
||||
|
||||
if (TryGetNextScrollPosition(out float? nextScrollPosition))
|
||||
{
|
||||
vScrollbar.ValueTarget = nextScrollPosition.Value;
|
||||
SensorScroller.VScrollTarget = nextScrollPosition.Value;
|
||||
|
||||
if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
|
||||
if (MathHelper.CloseToPercent(SensorScroller.VScroll, SensorScroller.VScrollTarget))
|
||||
{
|
||||
_tryToScrollToListFocus = false;
|
||||
return;
|
||||
@@ -387,22 +384,6 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
|
||||
{
|
||||
vScrollBar = null;
|
||||
|
||||
foreach (var child in scroll.Children)
|
||||
{
|
||||
if (child is not VScrollBar)
|
||||
continue;
|
||||
|
||||
vScrollBar = (VScrollBar) child;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
||||
{
|
||||
nextScrollPosition = 0;
|
||||
|
||||
Reference in New Issue
Block a user