Skip to content

Commit 40a06f8

Browse files
committed
Merge branch 'release/0.4.4'
2 parents 20e80e2 + d84038e commit 40a06f8

7 files changed

Lines changed: 28 additions & 7 deletions

File tree

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
language: objective-c
22
osx_image: xcode8.2
3+
branches:
4+
only:
5+
- master
6+
- develop
7+
38
script:
49
- xcodebuild -workspace Pageboy.xcworkspace -scheme Pageboy -destination 'platform=iOS
510
Simulator,name=iPhone 7,OS=10.1' build test
611
- pod lib lint --quick
12+
713
after_success:
814
- bash <(curl -s https://codecov.io/bash)
15+
916
notifications:
1017
slack:
1118
on_success: change

Pageboy.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Pod::Spec.new do |s|
44
s.platform = :ios, "9.0"
55
s.requires_arc = true
66

7-
s.version = "0.4.3"
7+
s.version = "0.4.4"
88
s.summary = "A simple, highly informative page view controller."
99
s.description = <<-DESC
1010
Pageboy is a page view controller that provides simplified data source management, enhanced delegation and other useful features.

Sources/Pageboy/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.4.3</string>
18+
<string>0.4.4</string>
1919
<key>CFBundleVersion</key>
2020
<string>AUTO_GENERATED</string>
2121
<key>NSPrincipalClass</key>

Sources/Pageboy/PageboyScrollDetection.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ extension PageboyViewController: UIPageViewControllerDelegate, UIScrollViewDeleg
6161
contentOffset = scrollView.contentOffset.y
6262
}
6363

64+
let scrollIndexDiff = CGFloat(abs((self.expectedTransitionIndex ?? currentIndex + 1) - currentIndex))
6465
let scrollOffset = contentOffset - pageSize
65-
let pageOffset = (CGFloat(currentIndex) * pageSize) + scrollOffset
66+
let pageOffset = (CGFloat(currentIndex) * pageSize) + (scrollOffset * scrollIndexDiff)
6667
var pagePosition = pageOffset / pageSize
6768

6869
// do not continue if a page change is detected

Sources/Pageboy/PageboyViewController.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,8 @@ open class PageboyViewController: UIViewController {
260260
guard let viewController = self.viewControllers?[rawIndex] else { return }
261261

262262
let direction = NavigationDirection.forPage(rawIndex, previousPage: self.currentIndex ?? rawIndex)
263-
self.delegate?.pageboyViewController(self,
264-
willScrollToPageAtIndex: rawIndex,
265-
direction: direction,
266-
animated: animated)
263+
self.pageViewController(self.pageViewController,
264+
willTransitionTo: [viewController])
267265

268266
self.isScrollingAnimated = true
269267
self.pageViewController.setViewControllers([viewController],

Sources/PageboyTests/PageboyDataSourceTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,18 @@ class PageboyDataSourceTests: PageboyTests {
102102
"Default Page index is not using correct .last PageIndex when specified.")
103103
}
104104

105+
/// Test whether reloadPages fully reloads
106+
/// PageboyViewController.
107+
func testPageboyViewControllerReloadBehavior() {
108+
self.dataSource.numberOfPages = 5
109+
self.pageboyViewController.dataSource = self.dataSource
110+
let initialPageCount = self.pageboyViewController.viewControllers?.count
111+
112+
self.dataSource.numberOfPages = 3
113+
self.pageboyViewController.reloadPages()
114+
let reloadPageCount = self.pageboyViewController.viewControllers?.count
115+
116+
XCTAssert(initialPageCount == 5 && reloadPageCount == 3,
117+
"reloadPages is not correctly reloading view controllers.")
118+
}
105119
}

Sources/PageboyTests/TestComponents/TestPageboyDataSource.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TestPageboyDataSource: Any, PageboyViewControllerDataSource {
2020
return nil
2121
}
2222

23+
viewControllers.removeAll()
2324
for index in 0..<numberOfPages {
2425
let viewController = TestPageChildViewController()
2526
viewController.index = index

0 commit comments

Comments
 (0)