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

Customize pan gesture recognizer sensitivity #71

Closed
gpapotti opened this issue Aug 23, 2019 · 4 comments
Closed

Customize pan gesture recognizer sensitivity #71

gpapotti opened this issue Aug 23, 2019 · 4 comments

Comments

@gpapotti
Copy link

gpapotti commented Aug 23, 2019

Hi, Kukushi.
Beautiful control, Congrats!
Sometimes pan gesture recognizer is a little too "choosy" in detecting a valid gesture. After a few tests I discovered that it would be useful to add a property in SideMenuController class in order to parametrise the constant value (.25) you're using in isValidateHorizontalMovement. For example on a real iPhone XS you get much better user experience with a value of .45 to guess "horizontality" of the gesture. I'll investigate further because I think it depends on screen dimension/density.

open class SideMenuController: UIViewController {
...

    private var _horizontalPanSensitivity:CGFloat = 0.25 // .45 was much better on large screens
    
    open var horizontalPanSensitivity: CGFloat
    {
        set
        {
            _horizontalPanSensitivity = newValue
        }
        get
        {
            return _horizontalPanSensitivity
        }
    }
...
}


in extension SideMenuController:
    private func isValidateHorizontalMovement(for velocity: CGPoint) -> Bool {
        if isMenuRevealed {
            return true
        }

        let direction = preferences.basic.direction
        var factor: CGFloat = direction == .left ? 1 : -1
        factor *= shouldReverseDirection ? -1 : 1
        guard velocity.x * factor > 0 else {
            return false
        }
        // Changed: using new sensitivity parameter
        return abs(velocity.y / velocity.x) < horizontalPanSensitivity
    }
@kukushi
Copy link
Owner

kukushi commented Sep 1, 2019

@gpapotti I have not yet tested it, but fell free to open a PR.

@ghost
Copy link

ghost commented Dec 30, 2020

@kukushi can you please just add this property yourself. We need this desperately for larger phones.

@ghost
Copy link

ghost commented Dec 30, 2020

It's been 2 years. He isn't going to make a PR.

@kukushi
Copy link
Owner

kukushi commented Jan 3, 2021

It's been 2 years. He isn't going to make a PR.

Shipped in 2.0.7

@kukushi kukushi closed this as completed Jan 3, 2021
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

2 participants