@@ -155,11 +155,12 @@ public InfiniteListView AddItem(int num = 1, float extLength = 0.0f)
155
155
156
156
nextPosition += startPosition ;
157
157
158
- Debug . Log ( $ "id: { id } position: { nextPosition } ") ;
159
158
}
159
+ //Debug.Log($"id: {id} position: {nextPosition}");
160
160
//new Vector2(startPos.x + arrayIndex * (_itemSize.x + _spacing), startPos.y)
161
-
161
+
162
162
item . Position = nextPosition ;
163
+
163
164
_items . Add ( item ) ;
164
165
}
165
166
}
@@ -180,14 +181,17 @@ public InfiniteListView AddItem(int num = 1, float extLength = 0.0f)
180
181
_dragMax = Vector2 . zero ;
181
182
if ( _items . Count > 0 )
182
183
{
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
+
183
187
for ( int i = _items . Count - 1 ; i >= _items . Count - _splitCount ; i -- )
184
188
{
185
189
if ( i >= 0 )
186
190
{
187
191
var lastItem = _items [ i ] ;
188
192
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 ) ;
191
195
if ( maxLength > _maxLength )
192
196
{
193
197
_maxLength = maxLength ;
@@ -197,11 +201,11 @@ public InfiniteListView AddItem(int num = 1, float extLength = 0.0f)
197
201
198
202
if ( _renderLayout == Layout . Vertical )
199
203
{
200
- _dragMax . y = _maxLength - _maskSize . y * 0.5f ;
204
+ _dragMax . y = _maxLength - _maskSize . y ;
201
205
}
202
206
else
203
207
{
204
- _dragMin . x = - ( _maxLength - _maskSize . x * 0.5f ) ;
208
+ _dragMin . x = - ( _maxLength - _maskSize . x ) ;
205
209
}
206
210
}
207
211
@@ -431,7 +435,9 @@ public void Rebuild()
431
435
432
436
private void ClampDragPosition ( float floatDrag = 0.0f )
433
437
{
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 )
435
441
{
436
442
_dragPosition . x = Mathf . Clamp ( _dragPosition . x , _dragMin . x - floatDrag , _dragMax . x + floatDrag ) ;
437
443
_dragPosition . y = Mathf . Clamp ( _dragPosition . y , _dragMin . y - floatDrag , _dragMax . y + floatDrag ) ;
0 commit comments