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 @@ -375,6 +375,11 @@ public static UICollectionViewLayout CreateCarouselLayout(
375
375
376
376
var goToIndexPath = cv2Controller . GetScrollToIndexPath ( carouselPosition ) ;
377
377
378
+ if ( ! IsIndexPathValid ( goToIndexPath , cv2Controller . CollectionView ) )
379
+ {
380
+ return ;
381
+ }
382
+
378
383
//This will move the carousel to fake the loop
379
384
cv2Controller . CollectionView . ScrollToItem (
380
385
NSIndexPath . FromItemSection ( pageIndex , 0 ) ,
@@ -393,6 +398,26 @@ public static UICollectionViewLayout CreateCarouselLayout(
393
398
return layout ;
394
399
}
395
400
#nullable enable
401
+
402
+ public static bool IsIndexPathValid ( NSIndexPath indexPath , UICollectionView collectionView )
403
+ {
404
+ if ( indexPath . Item < 0 || indexPath . Section < 0 )
405
+ {
406
+ return false ;
407
+ }
408
+
409
+ if ( indexPath . Section >= collectionView . NumberOfSections ( ) )
410
+ {
411
+ return false ;
412
+ }
413
+
414
+ if ( indexPath . Item >= collectionView . NumberOfItemsInSection ( indexPath . Section ) )
415
+ {
416
+ return false ;
417
+ }
418
+
419
+ return true ;
420
+ }
396
421
class CustomUICollectionViewCompositionalLayout : UICollectionViewCompositionalLayout
397
422
{
398
423
LayoutSnapInfo _snapInfo ;
You can’t perform that action at this time.
0 commit comments