DanisFabric / RainbowNavigation

An easy way to change backgroundColor of UINavigationBar when Push & Pop
MIT License
786 stars 85 forks source link

Limit PanGesture #6

Open suikadev opened 7 years ago

suikadev commented 7 years ago

Hi, It would be nice to have a variable to restrict the zone of the PanGesture, because the user could close accidentally the Controller. I patch the code in RainbowDragPop.swift to restrict the PanGesture for the first 30px:

func handlePan(_ panGesture:UIPanGestureRecognizer) {
        let offset = panGesture.translation(in: panGesture.view)
        let velocity = panGesture.velocity(in: panGesture.view)
        let position = panGesture.location(in: panGesture.view) //EDIT

        switch panGesture.state {
        case .began:
            if(position.x > 30){ return; } //EDIT

            if !self.popAnimator.animating {

Regards

anneWe commented 7 years ago

I limited the position of the PanGesture by using ScreenEdgePanGesture instead: https://github.com/DanisFabric/RainbowNavigation/pull/7