From a46acba2654022d846d212a2bc09666fe88a3895 Mon Sep 17 00:00:00 2001 From: Sinai Date: Thu, 27 May 2021 19:44:17 +1000 Subject: [PATCH] Better JumpToIndex height calculation --- src/UI/Widgets/ScrollPool/ScrollPool.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/UI/Widgets/ScrollPool/ScrollPool.cs b/src/UI/Widgets/ScrollPool/ScrollPool.cs index c46612f0..e9db77cc 100644 --- a/src/UI/Widgets/ScrollPool/ScrollPool.cs +++ b/src/UI/Widgets/ScrollPool/ScrollPool.cs @@ -142,7 +142,9 @@ public void JumpToIndex(int index, Action onJumped) RefreshCells(true, true); // Slide to the normalized position of the index - float normalized = HeightCache[index].startPosition / HeightCache.TotalHeight; + var cache = HeightCache[index]; + float normalized = (cache.startPosition + (cache.height * 0.5f)) / HeightCache.TotalHeight; + RuntimeProvider.Instance.StartCoroutine(ForceDelayedJump(index, normalized, onJumped)); }