Skip to content

Commit

Permalink
cancel transition delegate method added
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetkgunay committed May 24, 2017
1 parent d913c71 commit 6c0ad5f
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 54 deletions.
5 changes: 3 additions & 2 deletions AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import UIKit
@objc public protocol AKGPushAnimatorDelegate {

@objc optional func beganTransition()
@objc optional func cancelledTransition()
@objc optional func finishedTransition()
}


public class AKGPushAnimator: NSObject {

public var isReverseTransition = false
Expand Down Expand Up @@ -86,12 +86,13 @@ public class AKGPushAnimator: NSObject {

if (transitionContext.transitionWasCancelled) {
toView.removeFromSuperview()
self.delegate?.cancelledTransition?()
} else {
fromView.removeFromSuperview()
self.delegate?.finishedTransition?()
}
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)

self.delegate?.finishedTransition?()
}
}

Expand Down
4 changes: 4 additions & 0 deletions AKGPushAnimator/FirstViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ extension FirstViewController: AKGPushAnimatorDelegate {
print("began transition")
}

func cancelledTransition() {
print("cancelled transition")
}

func finishedTransition() {
print("finished transition")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import UIKit
@objc public protocol AKGPushAnimatorDelegate {

@objc optional func beganTransition()
@objc optional func cancelledTransition()
@objc optional func finishedTransition()
}


public class AKGPushAnimator: NSObject {

public var isReverseTransition = false
Expand Down Expand Up @@ -86,12 +86,13 @@ public class AKGPushAnimator: NSObject {

if (transitionContext.transitionWasCancelled) {
toView.removeFromSuperview()
self.delegate?.cancelledTransition?()
} else {
fromView.removeFromSuperview()
self.delegate?.finishedTransition?()
}
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)

self.delegate?.finishedTransition?()
}
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/AKGPushAnimatorTableviewDemo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ platform :ios, '8.0'
target 'AKGPushAnimatorTableviewDemo' do
use_frameworks!

pod 'AKGPushAnimator', '~> 1.0.3'
pod 'AKGPushAnimator', '~> 1.0.4'

target 'AKGPushAnimatorTableviewDemoTests' do
inherit! :search_paths
Expand Down
8 changes: 4 additions & 4 deletions Examples/AKGPushAnimatorTableviewDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PODS:
- AKGPushAnimator (1.0.3)
- AKGPushAnimator (1.0.4)

DEPENDENCIES:
- AKGPushAnimator (~> 1.0.3)
- AKGPushAnimator (~> 1.0.4)

SPEC CHECKSUMS:
AKGPushAnimator: 7c6c0c348aa20b015c559bd41c0f8d39a39002fe
AKGPushAnimator: d8bb4b710a798603f4c8b5c71be3578f1f1ed708

PODFILE CHECKSUM: 47efaf878697cff3a4efeb7577867c4069d71ef8
PODFILE CHECKSUM: 1a9ca41fd159f3d33bb6dfef8b6d066d7528e902

COCOAPODS: 1.2.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Examples/AKGPushAnimatorTableviewDemo/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Source/AKGPushAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import UIKit
@objc public protocol AKGPushAnimatorDelegate {

@objc optional func beganTransition()
@objc optional func cancelledTransition()
@objc optional func finishedTransition()
}


public class AKGPushAnimator: NSObject {

public var isReverseTransition = false
Expand Down Expand Up @@ -86,12 +86,13 @@ public class AKGPushAnimator: NSObject {

if (transitionContext.transitionWasCancelled) {
toView.removeFromSuperview()
self.delegate?.cancelledTransition?()
} else {
fromView.removeFromSuperview()
self.delegate?.finishedTransition?()
}
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)

self.delegate?.finishedTransition?()
}
}

Expand Down

0 comments on commit 6c0ad5f

Please sign in to comment.