From 546d4c123447dfd48048148e598e8e3c9a0bf651 Mon Sep 17 00:00:00 2001 From: Kedar27 Date: Wed, 7 Oct 2020 02:26:18 +0530 Subject: [PATCH] Fix - Crash issue with numberOfItems When numberOfItems and index is zero --- Sources/FSPagerView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/FSPagerView.swift b/Sources/FSPagerView.swift index 7fb17d9..4cf9942 100644 --- a/Sources/FSPagerView.swift +++ b/Sources/FSPagerView.swift @@ -511,7 +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 { + guard index <= self.numberOfItems else { fatalError("index \(index) is out of range [0...\(self.numberOfItems-1)]") } let indexPath = { () -> IndexPath in