Skip to content

Commit

Permalink
cleanup fillViewRect which has been implemented in another way
Browse files Browse the repository at this point in the history
  • Loading branch information
roointan authored Jul 17, 2023
1 parent e5e343e commit 81645a6
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions Runtime/LoopScrollRectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,8 @@ public void RefillCellsFromEnd(int endItem = 0, bool alignStart = false)
/// Refill cells with startItem at the beginning while clear existing ones
/// </summary>
/// <param name="startItem">The first item to fill</param>
/// <param name="fillViewRect">When [startItem, totalCount] is not enough for the whole viewBound, should we fill backwords with [0, startItem)? </param>
/// <param name="contentOffset">The first item's offset compared to viewBound</param>
public void RefillCells(int startItem = 0, bool fillViewRect = false, float contentOffset = 0)
public void RefillCells(int startItem = 0, float contentOffset = 0)
{
if (!Application.isPlaying)
return;
Expand Down Expand Up @@ -1013,19 +1012,6 @@ public void RefillCells(int startItem = 0, bool fillViewRect = false, float cont
sizeFilled += size;
}

if (fillViewRect && itemSize > 0 && sizeFilled < sizeToFill)
{
//calculate how many items can be added above the offset, so it still is visible in the view
int itemsToAddCount = (int)((sizeToFill - sizeFilled) / itemSize);
int newOffset = startItem - itemsToAddCount;
if (newOffset < 0) newOffset = 0;
if (newOffset != startItem)
{
//refill again, with the new offset value, and now with fillViewRect disabled.
RefillCells(newOffset);
}
}

Vector2 pos = m_Content.anchoredPosition;
if (direction == LoopScrollRectDirection.Vertical)
pos.y = -contentOffset;
Expand Down

0 comments on commit 81645a6

Please sign in to comment.