File tree Expand file tree Collapse file tree 2 files changed +26
-17
lines changed
src/Controls/src/Core/Handlers/Items2 Expand file tree Collapse file tree 2 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -161,23 +161,7 @@ NSIndexPath DetermineIndex(ScrollToRequestEventArgs args)
161
161
162
162
protected bool IsIndexPathValid ( NSIndexPath indexPath )
163
163
{
164
- if ( indexPath . Item < 0 || indexPath . Section < 0 )
165
- {
166
- return false ;
167
- }
168
-
169
- var collectionView = Controller . CollectionView ;
170
- if ( indexPath . Section >= collectionView . NumberOfSections ( ) )
171
- {
172
- return false ;
173
- }
174
-
175
- if ( indexPath . Item >= collectionView . NumberOfItemsInSection ( indexPath . Section ) )
176
- {
177
- return false ;
178
- }
179
-
180
- return true ;
164
+ return LayoutFactory2 . IsIndexPathValid ( indexPath , Controller . CollectionView ) ;
181
165
}
182
166
183
167
public override Size GetDesiredSize ( double widthConstraint , double heightConstraint )
Original file line number Diff line number Diff line change @@ -376,6 +376,11 @@ public static UICollectionViewLayout CreateCarouselLayout(
376
376
377
377
var goToIndexPath = cv2Controller . GetScrollToIndexPath ( carouselPosition ) ;
378
378
379
+ if ( ! IsIndexPathValid ( goToIndexPath , cv2Controller . CollectionView ) )
380
+ {
381
+ return ;
382
+ }
383
+
379
384
//This will move the carousel to fake the loop
380
385
cv2Controller . CollectionView . ScrollToItem (
381
386
NSIndexPath . FromItemSection ( pageIndex , 0 ) ,
@@ -394,6 +399,26 @@ public static UICollectionViewLayout CreateCarouselLayout(
394
399
return layout ;
395
400
}
396
401
#nullable enable
402
+
403
+ public static bool IsIndexPathValid ( NSIndexPath indexPath , UICollectionView collectionView )
404
+ {
405
+ if ( indexPath . Item < 0 || indexPath . Section < 0 )
406
+ {
407
+ return false ;
408
+ }
409
+
410
+ if ( indexPath . Section >= collectionView . NumberOfSections ( ) )
411
+ {
412
+ return false ;
413
+ }
414
+
415
+ if ( indexPath . Item >= collectionView . NumberOfItemsInSection ( indexPath . Section ) )
416
+ {
417
+ return false ;
418
+ }
419
+
420
+ return true ;
421
+ }
397
422
class CustomUICollectionViewCompositionalLayout : UICollectionViewCompositionalLayout
398
423
{
399
424
LayoutSnapInfo _snapInfo ;
You can’t perform that action at this time.
0 commit comments