Skip to content

Commit

Permalink
Merge branch 'release/0.4.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
msaps committed Mar 13, 2017
2 parents e309919 + 34e7cd0 commit 490702c
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 11 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ script:
- pod lib lint --quick

deploy:
provider: script
script: ./scripts/push.sh
on:
tags: true

after_success:
- bash <(curl -s https://codecov.io/bash)
- provider: script
script: ./scripts/test.sh
on:
all_branches: true
- provider: script
script: ./scripts/push.sh
on:
tags: true

notifications:
slack:
Expand Down
Binary file modified Artwork/artwork.sketch
Binary file not shown.
Binary file modified Artwork/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Pageboy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pod::Spec.new do |s|
s.platform = :ios, "9.0"
s.requires_arc = true

s.version = "0.4.10"
s.version = "0.4.11"
s.summary = "A simple, highly informative page view controller."
s.description = <<-DESC
Pageboy is a page view controller that provides simplified data source management, enhanced delegation and other useful features.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Pageboy/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.4.10</string>
<string>0.4.11</string>
<key>CFBundleVersion</key>
<string>AUTO_GENERATED</string>
<key>NSPrincipalClass</key>
Expand Down
25 changes: 25 additions & 0 deletions Sources/Pageboy/PageboyScrollDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ extension PageboyViewController: UIPageViewControllerDelegate, UIScrollViewDeleg
//

public func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard self.updateContentOffsetForBounceIfNeeded(scrollView: scrollView) == false else {
return
}

guard let currentIndex = self.currentIndex else {
return
}
Expand Down Expand Up @@ -130,6 +134,10 @@ extension PageboyViewController: UIPageViewControllerDelegate, UIScrollViewDeleg
self.scrollView(didEndScrolling: scrollView)
}

public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
self.updateContentOffsetForBounceIfNeeded(scrollView: scrollView)
}

private func scrollView(didEndScrolling scrollView: UIScrollView) {
if self.autoScroller.restartsOnScrollEnd {
self.autoScroller.restart()
Expand Down Expand Up @@ -270,6 +278,23 @@ extension PageboyViewController: UIPageViewControllerDelegate, UIScrollViewDeleg
let pageOffset = (CGFloat(currentIndex) * pageSize) + (scrollOffset * indexDiff)
return pageOffset / pageSize
}

/// Update the scroll view contentOffset for bouncing preference if required.
///
/// - Parameter scrollView: The scroll view.
/// - Returns: Whether the contentOffset was manipulated to achieve bouncing preference.
@discardableResult private func updateContentOffsetForBounceIfNeeded(scrollView: UIScrollView) -> Bool {
guard self.bounces == false else { return false }

let previousContentOffset = scrollView.contentOffset
if self.currentIndex == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0.0)
}
if self.currentIndex == (self.viewControllers?.count ?? 1) - 1 && scrollView.contentOffset.x > scrollView.bounds.size.width {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0.0)
}
return previousContentOffset != scrollView.contentOffset
}
}


Expand Down
3 changes: 3 additions & 0 deletions Sources/Pageboy/PageboyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ open class PageboyViewController: UIViewController {
}
}

/// default YES. if YES, bounces past edge of content and back again.
public var bounces: Bool = true

/// Whether user interaction is enabled on the page view controller.
///
/// Default is TRUE
Expand Down
12 changes: 12 additions & 0 deletions Sources/PageboyTests/PageboyTransitionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ class PageboyTransitionTests: PageboyTests {
}
}

/// Test bounces flag is correctly adhered to when set to false.
func testBouncingDisabledTransition() {
self.dataSource.numberOfPages = 2
self.pageboyViewController.dataSource = self.dataSource
self.pageboyViewController.bounces = false

self.simulateScroll(toPosition: -0.1)

XCTAssert(self.pageboyViewController.currentPosition!.x == 0.0,
"Bounces flag is not adhered to when setting contentOffset when false.")
}

// MARK: Utils

func simulateScroll(toPosition position: CGFloat) {
Expand Down
Empty file modified scripts/push.sh
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

if [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "develop" ]; then
sh <(curl -s https://codecov.io/bash)
fi

0 comments on commit 490702c

Please sign in to comment.