@@ -155,11 +155,12 @@ public InfiniteListView AddItem(int num = 1, float extLength = 0.0f)
155155
156156 nextPosition += startPosition ;
157157
158- Debug . Log ( $ "id: { id } position: { nextPosition } ") ;
159158 }
159+ //Debug.Log($"id: {id} position: {nextPosition}");
160160 //new Vector2(startPos.x + arrayIndex * (_itemSize.x + _spacing), startPos.y)
161-
161+ 162162 item . Position = nextPosition ;
163+ 163164 _items . Add ( item ) ;
164165 }
165166 }
@@ -180,14 +181,17 @@ public InfiniteListView AddItem(int num = 1, float extLength = 0.0f)
180181 _dragMax = Vector2 . zero ;
181182 if ( _items . Count > 0 )
182183 {
184+ float startPos = _renderLayout == Layout . Vertical ? _items [ 0 ] . Position . y : _items [ 0 ] . Position . x ;
185+ float startSize = _renderLayout == Layout . Vertical ? _items [ 0 ] . Size . y * 0.5f + _spacing : _items [ 0 ] . Size . x * 0.5f + _spacing ;
186+ 183187 for ( int i = _items . Count - 1 ; i >= _items . Count - _splitCount ; i -- )
184188 {
185189 if ( i >= 0 )
186190 {
187191 var lastItem = _items [ i ] ;
188192 float maxLength = _renderLayout == Layout . Vertical ?
189- ( - lastItem . Position . y + lastItem . Size . y * 0.5f + _spacing ) :
190- ( lastItem . Position . x + lastItem . Size . x * 0.5f + _spacing ) ;
193+ ( - ( lastItem . Position . y - startPos ) + lastItem . Size . y * 0.5f + _spacing + startSize ) :
194+ ( ( lastItem . Position . x - startPos ) + lastItem . Size . x * 0.5f + _spacing + startSize ) ;
191195 if ( maxLength > _maxLength )
192196 {
193197 _maxLength = maxLength ;
@@ -197,11 +201,11 @@ public InfiniteListView AddItem(int num = 1, float extLength = 0.0f)
197201
198202 if ( _renderLayout == Layout . Vertical )
199203 {
200- _dragMax . y = _maxLength - _maskSize . y * 0.5f ;
204+ _dragMax . y = _maxLength - _maskSize . y ;
201205 }
202206 else
203207 {
204- _dragMin . x = - ( _maxLength - _maskSize . x * 0.5f ) ;
208+ _dragMin . x = - ( _maxLength - _maskSize . x ) ;
205209 }
206210 }
207211
@@ -431,7 +435,9 @@ public void Rebuild()
431435
432436 private void ClampDragPosition ( float floatDrag = 0.0f )
433437 {
434- if ( _maxLength > _maskSize . y )
438+ //Debug.Log($"_maxLength: {_maxLength} _maskSize.y:{_maskSize.y} _maskSize.x:{_maskSize.x}");
439+ bool canDrag = _renderLayout == Layout . Vertical ? _maxLength > _maskSize . y : _maxLength > _maskSize . x ;
440+ if ( canDrag )
435441 {
436442 _dragPosition . x = Mathf . Clamp ( _dragPosition . x , _dragMin . x - floatDrag , _dragMax . x + floatDrag ) ;
437443 _dragPosition . y = Mathf . Clamp ( _dragPosition . y , _dragMin . y - floatDrag , _dragMax . y + floatDrag ) ;
0 commit comments