diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef5d356..65f9476b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. `Pageboy` adheres to [Semantic Versioning](http://semver.org/). #### 2.x Releases -- `2.5.x` Releases - [2.5.0](#250) +- `2.5.x` Releases - [2.5.0](#250) | [2.5.1](#251) - `2.4.x` Releases - [2.4.0](#240) - `2.3.x` Releases - [2.3.0](#230) | [2.3.1](#231) | [2.3.2](#232) | [2.3.3](#233) | [2.3.4](#234) - `2.2.x` Releases - [2.2.0](#220) @@ -22,6 +22,13 @@ All notable changes to this project will be documented in this file. --- +## [2.5.1](https://github.com/uias/Pageboy/releases/tag/2.5.1) +Released on 2018-04-23 + +#### Fixed +- [#159](https://github.com/uias/Pageboy/issues/159) Current Index is negative when infinite scroll is enabled and scrolling between ranges. + - by [msaps](https://github.com/msaps). + ## [2.5.0](https://github.com/uias/Pageboy/releases/tag/2.5.0) Released on 2018-04-05 diff --git a/Pageboy.podspec b/Pageboy.podspec index b38922ab..db80d52f 100644 --- a/Pageboy.podspec +++ b/Pageboy.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.requires_arc = true - s.version = "2.5.0" + s.version = "2.5.1" s.summary = "A simple, highly informative page view controller." s.description = <<-DESC A page view controller that provides simplified data source management, enhanced delegation and other useful features. diff --git a/Sources/Pageboy/Extensions/PageboyViewController+ScrollDetection.swift b/Sources/Pageboy/Extensions/PageboyViewController+ScrollDetection.swift index cbc9470b..f9497b5a 100644 --- a/Sources/Pageboy/Extensions/PageboyViewController+ScrollDetection.swift +++ b/Sources/Pageboy/Extensions/PageboyViewController+ScrollDetection.swift @@ -290,10 +290,7 @@ private extension PageboyViewController { currentIndex = Int(pagePosition) } - guard currentIndex != self.currentIndex else { - return false - } - self.currentIndex = currentIndex + return updateCurrentPageIndexIfNeeded(currentIndex) } return false @@ -302,12 +299,15 @@ private extension PageboyViewController { /// Safely update the current page index. /// /// - Parameter index: the proposed index. - private func updateCurrentPageIndexIfNeeded(_ index: Int) { + /// - Returns: Whether the page index was updated. + @discardableResult + private func updateCurrentPageIndexIfNeeded(_ index: Int) -> Bool { guard self.currentIndex != index, index >= 0 && index < self.viewControllerCount ?? 0 else { - return + return false } self.currentIndex = index + return true } /// Calculate the expected index diff for a page scroll. diff --git a/Sources/Pageboy/Info.plist b/Sources/Pageboy/Info.plist index 7e9e1f4a..60be2533 100644 --- a/Sources/Pageboy/Info.plist +++ b/Sources/Pageboy/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.5.0 + 2.5.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass