Commit a535e62 1 parent 50dd96a commit a535e62 Copy full SHA for a535e62
File tree 2 files changed +20
-7
lines changed
2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ open class Transition: NSObject {
48
48
private var canAddBlocks : Bool = false
49
49
private var dismissBlocks : [ ( ) -> Void ] = [ ]
50
50
private var presentBlocks : [ ( ) -> Void ] = [ ]
51
+ private var startBlocks : [ ( ) -> Void ] = [ ]
51
52
private var completeBlocks : [ ( Bool ) -> Void ] = [ ]
52
53
private var prepareBlocks : [ ( ) -> Void ] = [ ]
53
54
private var pausedAnimations : [ UIView : [ String : CAAnimation ] ] = [ : ]
@@ -122,6 +123,10 @@ open class Transition: NSObject {
122
123
prepareBlocks. append ( block)
123
124
}
124
125
126
+ public func addStartBlock( _ block: @escaping ( ) -> Void ) {
127
+ startBlocks. append ( block)
128
+ }
129
+
125
130
// MARK: - Subclass Overrides
126
131
open func animate( ) { }
127
132
}
@@ -277,6 +282,12 @@ extension Transition: UIViewControllerAnimatedTransitioning {
277
282
}
278
283
279
284
animator. startAnimation ( )
285
+
286
+ for block in startBlocks {
287
+ block ( )
288
+ }
289
+ startBlocks = [ ]
290
+
280
291
if isInteractive {
281
292
animator. pauseAnimation ( )
282
293
}
Original file line number Diff line number Diff line change @@ -110,15 +110,17 @@ open class MatchModalTransition: Transition {
110
110
sourceViewPlaceholder. removeFromSuperview ( )
111
111
foregroundContainerView. removeFromSuperview ( )
112
112
}
113
+ addStartBlock {
114
+ if self . isInteractive, self . isMatched {
115
+ self . pauseForegroundView ( )
116
+ }
117
+ }
113
118
}
114
119
115
- open override func animateTransition( using context: UIViewControllerContextTransitioning ) {
116
- super. animateTransition ( using: context)
117
- if isInteractive, isMatched {
118
- let position = foregroundContainerView. layer. presentation ( ) ? . position ?? foregroundContainerView. layer. position
119
- pause ( view: foregroundContainerView, animationForKey: " position " )
120
- foregroundContainerView. layer. position = position
121
- }
120
+ func pauseForegroundView( ) {
121
+ let position = foregroundContainerView. layer. presentation ( ) ? . position ?? foregroundContainerView. layer. position
122
+ self . pause ( view: foregroundContainerView, animationForKey: " position " )
123
+ foregroundContainerView. layer. position = position
122
124
}
123
125
124
126
open override func animationEnded( _ transitionCompleted: Bool ) {
You can’t perform that action at this time.
0 commit comments