From 26657cc29b6e91c7ac90fd689150a45a51b553bc Mon Sep 17 00:00:00 2001 From: Geetesh Vaingankar Date: Wed, 25 May 2022 17:52:57 +0530 Subject: [PATCH] Fix - Crash issue with numberOfItems --- Sources/FSPagerView.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sources/FSPagerView.swift b/Sources/FSPagerView.swift index 7fb17d9..2c0b90c 100644 --- a/Sources/FSPagerView.swift +++ b/Sources/FSPagerView.swift @@ -511,9 +511,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega /// - animated: Specify true to animate the scrolling behavior or false to adjust the pager view’s visible content immediately. @objc(scrollToItemAtIndex:animated:) open func scrollToItem(at index: Int, animated: Bool) { - guard index < self.numberOfItems else { - fatalError("index \(index) is out of range [0...\(self.numberOfItems-1)]") - } + guard index <= self.numberOfItems else { return } let indexPath = { () -> IndexPath in if let indexPath = self.possibleTargetingIndexPath, indexPath.item == index { defer {