Skip to content

Commit

Permalink
Delegate shouldRecognizeSimultaneously
Browse files Browse the repository at this point in the history
To enable scrolling of a scrollView which contain the collectionView/tableView
  • Loading branch information
NSErfan committed Sep 26, 2019
1 parent f737273 commit 3848bcd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/SwipeCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ open class SwipeCollectionViewCell: UICollectionViewCell {
}

extension SwipeCollectionViewCell: SwipeControllerDelegate {

func swipeController(_ controller: SwipeController, canBeginEditingSwipeableFor orientation: SwipeActionsOrientation) -> Bool {
return true
}
Expand Down Expand Up @@ -252,5 +253,10 @@ extension SwipeCollectionViewCell: SwipeControllerDelegate {
func swipeController(_ controller: SwipeController, didDeleteSwipeableAt indexPath: IndexPath) {
collectionView?.deleteItems(at: [indexPath])
}

func swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(_ otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return delegate?.swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(otherGestureRecognizer) ?? false
}

}

10 changes: 10 additions & 0 deletions Source/SwipeCollectionViewCellDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public protocol SwipeCollectionViewCellDelegate: class {
- note: The returned rectange should be in the collection view's own coordinate system. Returning `nil` will result in no vertical offset to be be calculated.
*/
func visibleRect(for collectionView: UICollectionView) -> CGRect?

/**
We need this to make scrolling of a scrollView that contains the collection view, possible
*/
func swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(_ otherGestureRecognizer: UIGestureRecognizer) -> Bool

}

/**
Expand All @@ -88,4 +94,8 @@ public extension SwipeCollectionViewCellDelegate {
func visibleRect(for collectionView: UICollectionView) -> CGRect? {
return nil
}

func swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(_ otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
6 changes: 6 additions & 0 deletions Source/SwipeController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ protocol SwipeControllerDelegate: class {
func swipeController(_ controller: SwipeController, didDeleteSwipeableAt indexPath: IndexPath)

func swipeController(_ controller: SwipeController, visibleRectFor scrollView: UIScrollView) -> CGRect?

func swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(_ otherGestureRecognizer: UIGestureRecognizer) -> Bool

}

Expand Down Expand Up @@ -367,6 +369,10 @@ extension SwipeController: UIGestureRecognizerDelegate {

return true
}

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return delegate?.swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(otherGestureRecognizer) ?? false
}
}

extension SwipeController: SwipeActionsViewDelegate {
Expand Down
4 changes: 4 additions & 0 deletions Source/SwipeTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,8 @@ extension SwipeTableViewCell: SwipeControllerDelegate {
func swipeController(_ controller: SwipeController, didDeleteSwipeableAt indexPath: IndexPath) {
tableView?.deleteRows(at: [indexPath], with: .none)
}

func swipeCellShouldAllowOtherGestureRecoginzerToWorkSimultaneously(_ otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return delegate?.shouldRecognizeOtherGestureRecoginzerSimultaneously(otherGestureRecognizer) ?? false
}
}
5 changes: 5 additions & 0 deletions Source/SwipeTableViewCellDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public protocol SwipeTableViewCellDelegate: class {
- note: The returned rectange should be in the table view's own coordinate system. Returning `nil` will result in no vertical offset to be be calculated.
*/
func visibleRect(for tableView: UITableView) -> CGRect?

/**
We need this to make scrolling of a scrollView that contains the table view, possible
*/
func shouldRecognizeOtherGestureRecoginzerSimultaneously(_ otherGestureRecognizer: UIGestureRecognizer) -> Bool
}

/**
Expand Down

0 comments on commit 3848bcd

Please sign in to comment.