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

Swipe down to close? #379

Open
jrz-afs opened this issue Mar 25, 2020 · 6 comments
Open

Swipe down to close? #379

jrz-afs opened this issue Mar 25, 2020 · 6 comments

Comments

@jrz-afs
Copy link

jrz-afs commented Mar 25, 2020

By default, you cannot swipe down from a "collapsed" state to a "closed" state. Is this supported out of the box via some property? If not, what is the best way to achieve this?

Thanks.

@amyleecodes
Copy link
Contributor

It's not supported. You could try adding a gesture recognizer or looking at the drawer position changes.

@ARGAMX
Copy link

ARGAMX commented May 26, 2020

I am search that functionality too. I thought that it works that way out of the box. But not.
Looking at the drawer position don't work (in 'PulleyViewController .drawerChangedDistanceFromBottom'), because it wont move or bounce below "closed" state. So change position delegate method did not called.
Thanks, will add gesture recognizer manually. Hope it will help.

@ARGAMX
Copy link

ARGAMX commented May 26, 2020

Sadly, but "UISwipeGestureRecognizer.direction = .down" don't work too.
I have tried 'PulleyViewController.addDrawerGestureRecognizer'method, and also tried to add it on inner view.
Gesture Handle function not called.
Tap, Swipe Left, Swipe Right - works perfect.
Swipe Up, Swipe Down - not.

So, seems "Swipe down to close" is not possible. It should be handled from Pulley, not externally.

@ARGAMX
Copy link

ARGAMX commented Jun 9, 2020

Found solution to close from bottom position without gesture:

extension OfficeDetailsVC: PulleyDrawerViewControllerDelegate {

    func drawerChangedDistanceFromBottom(drawer: PulleyViewController, distance: CGFloat, bottomSafeArea: CGFloat) {
        previousPosition = nil
    }
    
    func partialRevealDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
        return bottomSafeArea + (UIScreen.main.bounds.height - bottomSafeArea) / 2
    }

    func collapsedDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
        let collapsedSize: CGFloat = 55.0
        return bottomSafeArea + collapsedSize
    }

    func drawerPositionDidChange(drawer: Pulley.PulleyViewController, bottomSafeArea: CGFloat) {
        if (drawer.drawerPosition.rawValue == PulleyPosition.collapsed.rawValue) && (previousPosition == drawer.drawerPosition.rawValue) {
            drawer.setDrawerPosition(position: .closed, animated: true)
        }
        previousPosition = drawer.drawerPosition.rawValue
    }
}

@iori57
Copy link

iori57 commented Dec 2, 2020

+1 for this, I'm not sure why this is not supported because sounds like a common feature to allow user to swipe down to dismiss the drawer
For my case I'm using supportedDrawerPositions of [.partiallyRevealed, .closed] for a lot of the dialogs to replace popups and user can pull down to dismiss the drawer

@iGeX
Copy link

iGeX commented Feb 25, 2021

Maybe somebody will find it useful. With ARGAMX workaround when drawer in .collapsed state it no longer moves down with finger. You can achieve closing with swipe even in this position, but it looks and feels unnatural. As workaround for this problem I've decided to sacrifice one of possible drawer positions and redefine heights, so .collapsed state is now 0 pixels height, and .partiallyRevealed is equal to previous .collapsed. Now I don't have .partiallyRevealed state at all, but have smooth transitions between any states and swipe to close imitation looking natural. If you don't want to sacrifice positions, you can add one more, but it can be pretty complicated task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants