diff --git a/Runtime/LoopHorizontalScrollRect.cs b/Runtime/LoopHorizontalScrollRect.cs index 6e85194..968f4fb 100644 --- a/Runtime/LoopHorizontalScrollRect.cs +++ b/Runtime/LoopHorizontalScrollRect.cs @@ -139,7 +139,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.max.x > contentBounds.max.x - m_ContentRightPadding) + if (viewBounds.max.x > contentBounds.max.x - threshold - m_ContentRightPadding) { float size = NewItemAtEnd(), totalSize = size; while (size > 0 && viewBounds.max.x > contentBounds.max.x - m_ContentRightPadding + totalSize) @@ -151,7 +151,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.min.x < contentBounds.min.x + m_ContentLeftPadding) + if (viewBounds.min.x < contentBounds.min.x + threshold + m_ContentLeftPadding) { float size = NewItemAtStart(), totalSize = size; while (size > 0 && viewBounds.min.x < contentBounds.min.x + m_ContentLeftPadding - totalSize) diff --git a/Runtime/LoopHorizontalScrollRectMulti.cs b/Runtime/LoopHorizontalScrollRectMulti.cs index 130664e..13ba0a3 100644 --- a/Runtime/LoopHorizontalScrollRectMulti.cs +++ b/Runtime/LoopHorizontalScrollRectMulti.cs @@ -139,7 +139,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.max.x > contentBounds.max.x - m_ContentRightPadding) + if (viewBounds.max.x > contentBounds.max.x - threshold - m_ContentRightPadding) { float size = NewItemAtEnd(), totalSize = size; while (size > 0 && viewBounds.max.x > contentBounds.max.x - m_ContentRightPadding + totalSize) @@ -151,7 +151,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.min.x < contentBounds.min.x + m_ContentLeftPadding) + if (viewBounds.min.x < contentBounds.min.x + threshold + m_ContentLeftPadding) { float size = NewItemAtStart(), totalSize = size; while (size > 0 && viewBounds.min.x < contentBounds.min.x + m_ContentLeftPadding - totalSize) diff --git a/Runtime/LoopScrollRectBase.cs b/Runtime/LoopScrollRectBase.cs index 3cd735e..3ae2a2e 100644 --- a/Runtime/LoopScrollRectBase.cs +++ b/Runtime/LoopScrollRectBase.cs @@ -875,7 +875,7 @@ IEnumerator ScrollToCellCoroutine(int index, float speed) protected abstract void ProvideData(Transform transform, int index); /// - /// Refresh item data + /// Refresh item data (if totalCount increases, please call `RefillCells` instead) /// public void RefreshCells() { diff --git a/Runtime/LoopVerticalScrollRect.cs b/Runtime/LoopVerticalScrollRect.cs index cecc183..66cc9f0 100644 --- a/Runtime/LoopVerticalScrollRect.cs +++ b/Runtime/LoopVerticalScrollRect.cs @@ -138,7 +138,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.min.y < contentBounds.min.y + m_ContentBottomPadding) + if (viewBounds.min.y < contentBounds.min.y + threshold + m_ContentBottomPadding) { float size = NewItemAtEnd(), totalSize = size; while (size > 0 && viewBounds.min.y < contentBounds.min.y + m_ContentBottomPadding - totalSize) @@ -150,7 +150,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.max.y > contentBounds.max.y - m_ContentTopPadding) + if (viewBounds.max.y > contentBounds.max.y - threshold - m_ContentTopPadding) { float size = NewItemAtStart(), totalSize = size; while (size > 0 && viewBounds.max.y > contentBounds.max.y - m_ContentTopPadding + totalSize) diff --git a/Runtime/LoopVerticalScrollRectMulti.cs b/Runtime/LoopVerticalScrollRectMulti.cs index eacf0e9..58d6f40 100644 --- a/Runtime/LoopVerticalScrollRectMulti.cs +++ b/Runtime/LoopVerticalScrollRectMulti.cs @@ -138,7 +138,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.min.y < contentBounds.min.y + m_ContentBottomPadding) + if (viewBounds.min.y < contentBounds.min.y + threshold + m_ContentBottomPadding) { float size = NewItemAtEnd(), totalSize = size; while (size > 0 && viewBounds.min.y < contentBounds.min.y + m_ContentBottomPadding - totalSize) @@ -150,7 +150,7 @@ protected override bool UpdateItems(ref Bounds viewBounds, ref Bounds contentBou changed = true; } - if (viewBounds.max.y > contentBounds.max.y - m_ContentTopPadding) + if (viewBounds.max.y > contentBounds.max.y - threshold - m_ContentTopPadding) { float size = NewItemAtStart(), totalSize = size; while (size > 0 && viewBounds.max.y > contentBounds.max.y - m_ContentTopPadding + totalSize) diff --git a/Samples~/Demo/Scripts/UI_ControlData.cs b/Samples~/Demo/Scripts/UI_ControlData.cs index f5467fb..b615f60 100644 --- a/Samples~/Demo/Scripts/UI_ControlData.cs +++ b/Samples~/Demo/Scripts/UI_ControlData.cs @@ -61,9 +61,10 @@ private void OnButtonAddDataClick() { int RandomResult = Random.Range(0, 10); m_ListBank.AddContent(RandomResult); - m_InitOnStart.m_LoopScrollRect.totalCount = m_InitOnStart.m_LoopListBank.GetListLength(); - m_InitOnStart.m_LoopScrollRect.RefreshCells(); } + + m_InitOnStart.m_LoopScrollRect.totalCount = m_InitOnStart.m_LoopListBank.GetListLength(); + m_InitOnStart.m_LoopScrollRect.RefreshCells(); } private void OnButtonSetDataClick()