Skip to content

Commit

Permalink
Merge branch 'release/1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
msaps committed Jun 25, 2017
2 parents 435c1e2 + 899e458 commit cd24254
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 40 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
`Pageboy` adheres to [Semantic Versioning](http://semver.org/).

#### 1.x Releases
- `1.3.X` Releases - [1.3.0](#130) | [1.3.1](#131)
- `1.3.X` Releases - [1.3.0](#130) | [1.3.1](#131) | [1.3.2](#132)
- `1.2.X` Releases - [1.2.0](#120) | [1.2.1](#121)
- `1.1.X` Releases - [1.1.0](#110) | [1.1.1](#111) | [1.1.2](#112)
- `1.0.X` Releases - [1.0.0](#100) | [1.0.1](#101) | [1.0.2](#102) | [1.0.3](#103) | [1.0.4](#104) | [1.0.5](#105) | [1.0.6](#106) | [1.0.7](#107) | [1.0.8](#108) | [1.0.9](#109)
Expand All @@ -13,6 +13,18 @@ All notable changes to this project will be documented in this file.

---

## [1.3.2](https://github.com/uias/Pageboy/releases/tag/1.3.2)
Released on 2017-06-25

#### Updated
- Renamed utility extensions.

#### Fixed
- [#83](https://github.com/uias/Pageboy/issues/83) Fixed memory issue with custom transitioning support.
- Fixed by [farshadmb](https://github.com/farshadmb).
- [#85](https://github.com/uias/Pageboy/pull/85) Fixed issue with animated transition positional updates.
- Transitions with index ranges greater than 1 will now provide positions through the entire range.

## [1.3.1](https://github.com/uias/Pageboy/releases/tag/1.3.1)
Released on 2017-06-24.

Expand Down
3 changes: 3 additions & 0 deletions Example/Pageboy-Example/TransparentNavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class TransparentNavigationBar: UINavigationBar {
var titleTextAttributes: [String : Any] = [NSForegroundColorAttributeName : UIColor.white]
if #available(iOS 8.2, *) {
titleTextAttributes[NSFontAttributeName] = UIFont.systemFont(ofSize: 18.0, weight: UIFontWeightRegular)
}else{
titleTextAttributes[NSFontAttributeName] = UIFont.systemFont(ofSize: 18.0)
}

self.titleTextAttributes = titleTextAttributes
self.tintColor = UIColor.white.withAlphaComponent(0.7)

Expand Down
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, "8.0"
s.requires_arc = true

s.version = "1.3.1"
s.version = "1.3.2"
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.
Expand Down
24 changes: 12 additions & 12 deletions Sources/Pageboy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
D623B1C81E1D0C6B00527F3D /* Pageboy.h in Headers */ = {isa = PBXBuildFile; fileRef = D623B1BA1E1D0C6A00527F3D /* Pageboy.h */; settings = {ATTRIBUTES = (Public, ); }; };
D623B1D21E1D2DF200527F3D /* PageboyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D623B1D11E1D2DF200527F3D /* PageboyViewController.swift */; };
D62436EB1E703D30006FF1A5 /* PageboyAutoScrollTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62436EA1E703D30006FF1A5 /* PageboyAutoScrollTests.swift */; };
D681E3381E546FA2007C08F5 /* PageboyAutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E3371E546FA2007C08F5 /* PageboyAutoLayout.swift */; };
D681E3381E546FA2007C08F5 /* UIView+AutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E3371E546FA2007C08F5 /* UIView+AutoLayout.swift */; };
D681E33F1E5477D3007C08F5 /* TestPageboyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E33E1E5477D3007C08F5 /* TestPageboyViewController.swift */; };
D681E3411E5478E6007C08F5 /* TestPageChildViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E3401E5478E6007C08F5 /* TestPageChildViewController.swift */; };
D681E3431E547901007C08F5 /* TestPageboyDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E3421E547901007C08F5 /* TestPageboyDataSource.swift */; };
Expand All @@ -25,11 +25,11 @@
D6CC557E1ECCC55F00A7FBB4 /* PageboyViewController+Management.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6CC557C1ECCC55F00A7FBB4 /* PageboyViewController+Management.swift */; };
D6CC557F1ECCC55F00A7FBB4 /* PageboyViewController+ScrollDetection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6CC557D1ECCC55F00A7FBB4 /* PageboyViewController+ScrollDetection.swift */; };
D6CC55811ECCC5BE00A7FBB4 /* PageboyViewController+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6CC55801ECCC5BE00A7FBB4 /* PageboyViewController+Extras.swift */; };
D6ECCEC21E51AFE500E9D5B3 /* PageViewControllerUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6ECCEC11E51AFE500E9D5B3 /* PageViewControllerUtils.swift */; };
D6ECCEC21E51AFE500E9D5B3 /* UIPageViewController+ScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6ECCEC11E51AFE500E9D5B3 /* UIPageViewController+ScrollView.swift */; };
D6F42C9E1EDE01DD006F0208 /* TransitionOperation+Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F42C9D1EDE01DD006F0208 /* TransitionOperation+Action.swift */; };
D6F561361EDCAD6D0033C654 /* PageboyViewController+Transitioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F561351EDCAD6D0033C654 /* PageboyViewController+Transitioning.swift */; };
D6F561391EDCC3320033C654 /* TransitionOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F561381EDCC3320033C654 /* TransitionOperation.swift */; };
D6F6F8F91EF6D672006397D0 /* LocalizationUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6F8F81EF6D672006397D0 /* LocalizationUtils.swift */; };
D6F6F8F91EF6D672006397D0 /* UIView+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6F8F81EF6D672006397D0 /* UIView+Localization.swift */; };
D6F6F8FC1EF6DC49006397D0 /* UIViewController+PageboyExtras.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6F8FB1EF6DC49006397D0 /* UIViewController+PageboyExtras.swift */; };
/* End PBXBuildFile section */

Expand All @@ -52,7 +52,7 @@
D623B1C71E1D0C6B00527F3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D623B1D11E1D2DF200527F3D /* PageboyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageboyViewController.swift; sourceTree = "<group>"; };
D62436EA1E703D30006FF1A5 /* PageboyAutoScrollTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageboyAutoScrollTests.swift; sourceTree = "<group>"; };
D681E3371E546FA2007C08F5 /* PageboyAutoLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageboyAutoLayout.swift; sourceTree = "<group>"; };
D681E3371E546FA2007C08F5 /* UIView+AutoLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+AutoLayout.swift"; sourceTree = "<group>"; };
D681E33E1E5477D3007C08F5 /* TestPageboyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestPageboyViewController.swift; sourceTree = "<group>"; };
D681E3401E5478E6007C08F5 /* TestPageChildViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestPageChildViewController.swift; sourceTree = "<group>"; };
D681E3421E547901007C08F5 /* TestPageboyDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestPageboyDataSource.swift; sourceTree = "<group>"; };
Expand All @@ -65,11 +65,11 @@
D6CC557C1ECCC55F00A7FBB4 /* PageboyViewController+Management.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PageboyViewController+Management.swift"; sourceTree = "<group>"; };
D6CC557D1ECCC55F00A7FBB4 /* PageboyViewController+ScrollDetection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PageboyViewController+ScrollDetection.swift"; sourceTree = "<group>"; };
D6CC55801ECCC5BE00A7FBB4 /* PageboyViewController+Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PageboyViewController+Extras.swift"; sourceTree = "<group>"; };
D6ECCEC11E51AFE500E9D5B3 /* PageViewControllerUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageViewControllerUtils.swift; sourceTree = "<group>"; };
D6ECCEC11E51AFE500E9D5B3 /* UIPageViewController+ScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIPageViewController+ScrollView.swift"; sourceTree = "<group>"; };
D6F42C9D1EDE01DD006F0208 /* TransitionOperation+Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TransitionOperation+Action.swift"; sourceTree = "<group>"; };
D6F561351EDCAD6D0033C654 /* PageboyViewController+Transitioning.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PageboyViewController+Transitioning.swift"; sourceTree = "<group>"; };
D6F561381EDCC3320033C654 /* TransitionOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransitionOperation.swift; sourceTree = "<group>"; };
D6F6F8F81EF6D672006397D0 /* LocalizationUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalizationUtils.swift; sourceTree = "<group>"; };
D6F6F8F81EF6D672006397D0 /* UIView+Localization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Localization.swift"; sourceTree = "<group>"; };
D6F6F8FB1EF6DC49006397D0 /* UIViewController+PageboyExtras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+PageboyExtras.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -180,11 +180,11 @@
D6ECCEC01E51AFDB00E9D5B3 /* Utilities */ = {
isa = PBXGroup;
children = (
D6ECCEC11E51AFE500E9D5B3 /* PageViewControllerUtils.swift */,
D681E3371E546FA2007C08F5 /* PageboyAutoLayout.swift */,
D6ECCEC11E51AFE500E9D5B3 /* UIPageViewController+ScrollView.swift */,
D681E3371E546FA2007C08F5 /* UIView+AutoLayout.swift */,
D6F6F8F81EF6D672006397D0 /* UIView+Localization.swift */,
D6F561381EDCC3320033C654 /* TransitionOperation.swift */,
D6F42C9D1EDE01DD006F0208 /* TransitionOperation+Action.swift */,
D6F6F8F81EF6D672006397D0 /* LocalizationUtils.swift */,
);
path = Utilities;
sourceTree = "<group>";
Expand Down Expand Up @@ -323,13 +323,13 @@
D6CC557B1ECCC55300A7FBB4 /* PageboyAutoScroller.swift in Sources */,
D6CC557E1ECCC55F00A7FBB4 /* PageboyViewController+Management.swift in Sources */,
D623B1D21E1D2DF200527F3D /* PageboyViewController.swift in Sources */,
D681E3381E546FA2007C08F5 /* PageboyAutoLayout.swift in Sources */,
D681E3381E546FA2007C08F5 /* UIView+AutoLayout.swift in Sources */,
D6CC557F1ECCC55F00A7FBB4 /* PageboyViewController+ScrollDetection.swift in Sources */,
D6F561391EDCC3320033C654 /* TransitionOperation.swift in Sources */,
D6ECCEC21E51AFE500E9D5B3 /* PageViewControllerUtils.swift in Sources */,
D6ECCEC21E51AFE500E9D5B3 /* UIPageViewController+ScrollView.swift in Sources */,
D6F561361EDCAD6D0033C654 /* PageboyViewController+Transitioning.swift in Sources */,
D6CC55811ECCC5BE00A7FBB4 /* PageboyViewController+Extras.swift in Sources */,
D6F6F8F91EF6D672006397D0 /* LocalizationUtils.swift in Sources */,
D6F6F8F91EF6D672006397D0 /* UIView+Localization.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal extension PageboyViewController {

// MARK: Set Up

internal func setUpTransitioning() {
fileprivate func prepareForTransition() {
guard self.transitionDisplayLink == nil else { return }

let transitionDisplayLink = CADisplayLink(target: self, selector: #selector(displayLinkDidTick))
Expand All @@ -65,6 +65,11 @@ internal extension PageboyViewController {
self.transitionDisplayLink = transitionDisplayLink
}

fileprivate func clearUpAfterTransition() {
self.transitionDisplayLink?.invalidate()
self.transitionDisplayLink = nil
}

// MARK: Animation

func displayLinkDidTick() {
Expand All @@ -88,6 +93,8 @@ internal extension PageboyViewController {
guard self.activeTransition == nil else { return }
guard let pageViewController = self.pageViewController else { return }

prepareForTransition()

/// Calculate semantic direction for RtL languages
var semanticDirection = direction
if view.layoutIsRightToLeft && navigationOrientation == .horizontal {
Expand Down Expand Up @@ -117,6 +124,8 @@ extension PageboyViewController: TransitionOperationDelegate {
didFinish finished: Bool) {
self.transitionDisplayLink?.isPaused = true
self.activeTransition = nil

clearUpAfterTransition()
}

func transitionOperation(_ operation: TransitionOperation,
Expand All @@ -125,8 +134,12 @@ extension PageboyViewController: TransitionOperationDelegate {
let isReverse = operation.action.direction == .reverse
let isVertical = operation.action.orientation == .vertical

/// Take into account the diff between startIndex and endIndex
let indexDiff = abs(operation.action.endIndex - operation.action.startIndex)
let diff = percentComplete * CGFloat(indexDiff)

let currentIndex = CGFloat(self.currentIndex ?? 0)
let currentPosition = isReverse ? currentIndex - percentComplete : currentIndex + percentComplete
let currentPosition = isReverse ? currentIndex - diff : currentIndex + diff
let point = CGPoint(x: isVertical ? 0.0 : currentPosition,
y: isVertical ? currentPosition : 0.0)

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>1.3.1</string>
<string>1.3.2</string>
<key>CFBundleVersion</key>
<string>AUTO_GENERATED</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 7 additions & 2 deletions Sources/Pageboy/PageboyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,21 @@ open class PageboyViewController: UIViewController {
/// Auto Scroller for automatic time-based page transitions.
public let autoScroller = PageboyAutoScroller()

// MARK: Init

deinit{
self.viewControllers?.removeAll()
}

// MARK: Lifecycle

open override func viewDidLoad() {
super.viewDidLoad()

self.autoScroller.handler = self
self.setUpTransitioning()
self.setUpPageViewController()
}

open override func viewWillTransition(to size: CGSize,
with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
Expand Down
46 changes: 28 additions & 18 deletions Sources/Pageboy/Utilities/TransitionOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,33 @@ internal class TransitionOperation: NSObject, CAAnimationDelegate {
let action: Action

/// The raw animation for the operation.
private var animation: CATransition
private var animation: CATransition?
/// The time that the operation did start.
private(set) var startTime: CFTimeInterval?

/// Whether the operation is currently animating.
private var isAnimating: Bool = false

/// The object that acts as a delegate to the operation
private(set) weak var delegate: TransitionOperationDelegate?

/// The time that the operation did start.
private(set) var startTime: CFTimeInterval?

/// Action to execute when the operation is complete.
private var completion: Completion?

/// The total duration of the transition.
var duration: CFTimeInterval {
guard let animation = self.animation else {
return 0.0
}
return animation.duration
}
/// The percent that the transition is complete.
var percentComplete: CGFloat {
guard self.isAnimating else { return 0.0 }

let percent = CGFloat((CACurrentMediaTime() - (startTime ?? CACurrentMediaTime())) / duration)
return max(0.0, min(1.0, percent))
}

// MARK: Init

init(for transition: PageboyViewController.Transition,
Expand All @@ -78,15 +92,22 @@ internal class TransitionOperation: NSObject, CAAnimationDelegate {
animation.delegate = self
}

// MARK: Transitioning

/// Start the transition animation on a layer.
///
/// - Parameter layer: The layer to animate.
/// - Parameter completion: Completion of the transition.
func start(on layer: CALayer,
completion: @escaping Completion) {
guard let animation = self.animation else {
completion(false)
return
}

self.completion = completion
self.startTime = CACurrentMediaTime()
layer.add(self.animation,
layer.add(animation,
forKey: "transition")
}

Expand All @@ -96,18 +117,6 @@ internal class TransitionOperation: NSObject, CAAnimationDelegate {
delegate?.transitionOperation(self, didUpdateWith: percentComplete)
}

/// The total duration of the transition.
var duration: CFTimeInterval {
return animation.duration
}
/// The percent that the transition is complete.
var percentComplete: CGFloat {
guard self.isAnimating else { return 0.0 }

let percent = CGFloat((CACurrentMediaTime() - (startTime ?? CACurrentMediaTime())) / duration)
return max(0.0, min(1.0, percent))
}

// MARK: CAAnimationDelegate

public func animationDidStart(_ anim: CAAnimation) {
Expand All @@ -118,6 +127,7 @@ internal class TransitionOperation: NSObject, CAAnimationDelegate {
isAnimating = false
completion?(flag)
delegate?.transitionOperation(self, didFinish: flag)
self.animation = nil
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// PageViewControllerUtils.swift
// UIPageViewController+ScrollView.swift
// Pageboy
//
// Created by Merrick Sapsford on 13/02/2017.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// PageboyAutoLayout.swift
// UIView+AutoLayout.swift
// Pageboy
//
// Created by Merrick Sapsford on 15/02/2017.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// LocalizationUtils.swift
// UIView+Localization.swift
// Pageboy
//
// Created by Merrick Sapsford on 18/06/2017.
Expand Down

0 comments on commit cd24254

Please sign in to comment.