From 837d5792bea89c30aa12c4a95db1fae31ab45271 Mon Sep 17 00:00:00 2001 From: Sinai Date: Thu, 22 Apr 2021 01:04:59 +1000 Subject: [PATCH] Update DataHeightManager.cs --- src/UI/Widgets/ScrollPool/DataHeightManager.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/UI/Widgets/ScrollPool/DataHeightManager.cs b/src/UI/Widgets/ScrollPool/DataHeightManager.cs index 3a5f405..4a15dc5 100644 --- a/src/UI/Widgets/ScrollPool/DataHeightManager.cs +++ b/src/UI/Widgets/ScrollPool/DataHeightManager.cs @@ -161,11 +161,10 @@ namespace UnityExplorer.UI.Widgets break; } - // we guessed wrong. if diff is > 1 than add it and try again. - // the new min start index will be at least the diff from our index. - int jmp = Math.Max(0, dataIndex - rangeToDataIndexCache[i]); - if (jmp > 1) - i += jmp - 1; + // our index is further down. add the min difference and try again. + // the iterator will add 1 on the next loop so account for that. + int jmp = dataIndex - rangeToDataIndexCache[i] - 1; + i += jmp < 1 ? 0 : jmp; } if (rangeStart == -1)