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

Fixed an issue of content taps being cancelled by the drawer tap recognisers. #57

Merged
merged 3 commits into from
Apr 6, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@ extension PresentationController {
}
}
}

extension PresentationController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
if let view = gestureRecognizer.view,
view.isDescendant(of: presentedViewController.view),
let subview = view.hitTest(touch.location(in: view), with: nil) {
return !(subview is UIControl)
} else {
return true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ extension PresentationController {
action: #selector(handleDrawerFullExpansionTap))
tapGesture.numberOfTouchesRequired = 1
tapGesture.numberOfTapsRequired = numTapsRequired
tapGesture.cancelsTouchesInView = false
tapGesture.delaysTouchesBegan = false
tapGesture.delaysTouchesEnded = false
tapGesture.delegate = self
presentedView?.addGestureRecognizer(tapGesture)
drawerFullExpansionTapGR = tapGesture
}
Expand All @@ -35,6 +39,10 @@ extension PresentationController {
action: #selector(handleDrawerDismissalTap))
tapGesture.numberOfTouchesRequired = 1
tapGesture.numberOfTapsRequired = numTapsRequired
tapGesture.cancelsTouchesInView = false
tapGesture.delaysTouchesBegan = false
tapGesture.delaysTouchesEnded = false
tapGesture.delegate = self
containerView?.addGestureRecognizer(tapGesture)
drawerDismissalTapGR = tapGesture
}
Expand Down
10 changes: 6 additions & 4 deletions DrawerKit/DrawerKit/Internal API/PresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ final class PresentationController: UIPresentationController {

/// The target state of the drawer. If no presentation animation is in
/// progress, the value should be equivalent to `currentDrawerState`.
var targetDrawerState: DrawerState
var targetDrawerState: DrawerState {
didSet {
drawerDismissalTapGR?.isEnabled = targetDrawerState == .partiallyExpanded
drawerFullExpansionTapGR?.isEnabled = targetDrawerState == .partiallyExpanded
}
}

var startingDrawerStateForDrag: DrawerState?

Expand All @@ -29,9 +34,6 @@ final class PresentationController: UIPresentationController {
self.handleView = (configuration.handleViewConfiguration != nil ? UIView() : nil)
self.presentingDrawerAnimationActions = presentingDrawerAnimationActions
self.presentedDrawerAnimationActions = presentedDrawerAnimationActions

// NOTE: Set the current drawer state to the target state of the initial
// presentation animation.
self.targetDrawerState = configuration.supportsPartialExpansion ? .partiallyExpanded : .fullyExpanded

super.init(presentedViewController: presentedVC, presenting: presentingVC)
Expand Down