Handling Multiple Panning Gestures

I am developing a drawing app that supports multiple canvases for drawing. I manage these canvases using a collection view with paging enabled. Each collectionViewCell is a canvas and has the size of the collectionView. The setup is similar to a PDF viewer where you can annotate pages with my custom drawing engine.

I currently have a custom panning gesture for the CanvasView as well as the panning gesture of the collectionView. I use the UIGestureRecognizerDelegate methods to allow the transition from the canvas panning gesture to the collectionView panning gesture when reaching the end of the canvas. I achieve this by setting the canvas gesture state to .cancelled:

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        if otherGestureRecognizer == panGestureCellRecognizer {
            return true
        }
        return false
    }
@objc private func didPan(_ gesture: UIPanGestureRecognizer) {
        let canvas = canvasViews[collectionView.currentCanvas]
        switch gesture.state {
        case .began:
            canvas.touchBegan(gesture); canvas.redraw()
        case .changed:
            let canPan = canvas.touchMoved(gesture)
            if !canPan { gesture.state = .cancelled }
            canvas.redraw()
        default: return
        }
    }

My issue arises when the collectionView panning gesture is active, and I pan back to the same page; I am unable to activate the panning gesture of the CanvasView. In other words, I can only transition once from the canvas panning gesture to the collectionView panning gesture. Ideally, I want to be able to go back if, on the next canvas, I can pan again on the CanvasView itself. Note that my CanvasView is a custom Metal View, not a UIScrollView.

Does anyone have suggestions for correctly handling multiple panning gesture recognizers in this scenario? Thank you in advance!

Why not disable pan for CollectionView once gesture ended ?

Handling Multiple Panning Gestures
 
 
Q