Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on presenting pan modal over pan modal #176

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions PanModal/Controller/PanModalPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,14 @@ private extension PanModalPresentationController {
Halts the scroll of a given scroll view & anchors it at the `scrollViewYOffset`
*/
func haltScrolling(_ scrollView: UIScrollView) {
scrollView.setContentOffset(CGPoint(x: 0, y: scrollViewYOffset), animated: false)
scrollView.showsVerticalScrollIndicator = false
if scrollView.frame.isEmpty == false {
let maxY = max(scrollView.contentSize.height - scrollView.bounds.height, 0)
let point = CGPoint(x: 0, y: min(scrollViewYOffset.rounded(), maxY))
if presentedViewController.isPanModalPresented && point != scrollView.contentOffset {
scrollView.setContentOffset(point, animated: false)
scrollView.showsVerticalScrollIndicator = false
}
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion PanModal/Presenter/UIViewController+PanModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ extension UIViewController: PanModalPresenter {
the presentationController is referenced here and called too early resulting in
a strong reference to this view controller and in turn, creating a memory leak.
*/
public var isPanModalPresented: Bool {
@objc
open var isPanModalPresented: Bool {
return (transitioningDelegate as? PanModalPresentationDelegate) != nil
}

Expand Down