1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00

Base bounds checks on +1 (to avoid worrying about current item heights)

This commit is contained in:
Dean Herbert 2020-10-12 19:12:00 +09:00
parent bb03c5d77c
commit 15325f5f51

View File

@ -574,11 +574,16 @@ namespace osu.Game.Screens.Select
//scrollableContent.RemoveAll(p => p.Y < visibleUpperBound - p.DrawHeight || p.Y > visibleBottomBound || !p.IsPresent);
// Find index range of all items that should be on-screen
int firstIndex = yPositions.BinarySearch(visibleUpperBound - DrawableCarouselItem.MAX_HEIGHT);
int firstIndex = yPositions.BinarySearch(visibleUpperBound);
if (firstIndex < 0) firstIndex = ~firstIndex;
int lastIndex = yPositions.BinarySearch(visibleBottomBound);
if (lastIndex < 0) lastIndex = ~lastIndex;
// as we can't be 100% sure on the size of individual carousel drawables,
// always play it safe and extend bounds by one.
firstIndex = Math.Max(0, firstIndex - 1);
lastIndex = Math.Min(yPositions.Count - 1, lastIndex + 1);
if (revalidateItems || firstIndex != displayedRange.first || lastIndex != displayedRange.last)
{
displayedRange = (firstIndex, lastIndex);