Dim ct As CTItem = Items.Get(i)
ct.CurrentValue = CalcNewValue(ct.CurrentValue, ct.TargetValue, MaxDelta / FromValueToPixels)
ct.CurrentHeight = CalcNewValue(ct.CurrentHeight, height, MaxDelta)
ct.CurrentTop = CalcNewValue(ct.CurrentTop, i * height, MaxDelta)
Private Sub CalcNewValue (CurrentValue As Float, TargetValue As Float, MaxDelta As Float) As Float
If CurrentValue <= TargetValue Then
Return Min(TargetValue, CurrentValue + MaxDelta)
Else
Return Max(TargetValue, CurrentValue - MaxDelta)
End If
End Sub