@@ -113,7 +113,7 @@ open class PanModalPresentationController: UIPresentationController {
113113 }
114114 view. didTap = { [ weak self] _ in
115115 if self ? . presentable? . allowsTapToDismiss == true {
116- self ? . dismissPresentedViewController ( )
116+ self ? . presentedViewController . dismiss ( animated : true )
117117 }
118118 }
119119 return view
@@ -192,7 +192,14 @@ open class PanModalPresentationController: UIPresentationController {
192192 } )
193193 }
194194
195+ override public func presentationTransitionDidEnd( _ completed: Bool ) {
196+ if completed { return }
197+
198+ backgroundView. removeFromSuperview ( )
199+ }
200+
195201 override public func dismissalTransitionWillBegin( ) {
202+ presentable? . panModalWillDismiss ( )
196203
197204 guard let coordinator = presentedViewController. transitionCoordinator else {
198205 backgroundView. dimState = . off
@@ -210,10 +217,10 @@ open class PanModalPresentationController: UIPresentationController {
210217 } )
211218 }
212219
213- override public func presentationTransitionDidEnd ( _ completed: Bool ) {
214- if completed { return }
215-
216- backgroundView . removeFromSuperview ( )
220+ override public func dismissalTransitionDidEnd ( _ completed: Bool ) {
221+ if ! completed { return }
222+
223+ presentable ? . panModalDidDismiss ( )
217224 }
218225
219226 /**
@@ -516,7 +523,7 @@ private extension PanModalPresentationController {
516523 transition ( to: . shortForm)
517524
518525 } else {
519- dismissPresentedViewController ( )
526+ presentedViewController . dismiss ( animated : true )
520527 }
521528
522529 } else {
@@ -534,7 +541,7 @@ private extension PanModalPresentationController {
534541 transition ( to: . shortForm)
535542
536543 } else {
537- dismissPresentedViewController ( )
544+ presentedViewController . dismiss ( animated : true )
538545 }
539546 }
540547 }
@@ -673,16 +680,6 @@ private extension PanModalPresentationController {
673680 else { return number }
674681 return nearestVal
675682 }
676-
677- /**
678- Dismiss presented view
679- */
680- func dismissPresentedViewController( ) {
681- presentable? . panModalWillDismiss ( )
682- presentedViewController. dismiss ( animated: true ) { [ weak self] in
683- self ? . presentable? . panModalDidDismiss ( )
684- }
685- }
686683}
687684
688685// MARK: - UIScrollView Observer
0 commit comments