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

Conflict with side menu #358

Open
igorkulman opened this issue Oct 9, 2019 · 10 comments · May be fixed by #378
Open

Conflict with side menu #358

igorkulman opened this issue Oct 9, 2019 · 10 comments · May be fixed by #378

Comments

@igorkulman
Copy link

I am using SwipeCellKit in a UITableViewController together with a side menu that is activated by a swipe from left to right. My SwipeTableViewCell only defines right items so I would expect swiping from right to left to show the SwipeCellKit actions and swipe from left to right to open the side menu.

The problem is that SwipeCellKit takes precedents over the side menu and handles the swipe gesture for both left to right and right to left without checking if swipe actions are defined for that direction.

I found this in SwipeController (https://github.com/SwipeCellKit/SwipeCellKit/blob/develop/Source/SwipeController.swift#L365):

if gestureRecognizer == panGestureRecognizer,
    let view = gestureRecognizer.view,
    let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
    let translation = gestureRecognizer.translation(in: view)
    return abs(translation.y) <= abs(translation.x)
}

I think the return abs(translation.y) <= abs(translation.x) should also check if there are actions defined for the currently handled direction.

Maybe something like this

if gestureRecognizer == panGestureRecognizer,
    let view = gestureRecognizer.view,
    let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
    let translation = gestureRecognizer.translation(in: view)

    let canSwipeLeft = (delegate?.swipeController(self, editActionsForSwipeableFor: .right)?.count ?? 0) > 0
    let canSwipeRight = (delegate?.swipeController(self, editActionsForSwipeableFor: .left)?.count ?? 0) > 0

    switch (canSwipeLeft, canSwipeRight) {
    case (true, true):
        return abs(translation.y) <= abs(translation.x)
    case (false, false):
        return false
    case (true, false):
        // only if swipe is horizontal and either to the left or to the right but menu is already open (so it gets dismissed)
        return abs(translation.y) <= abs(translation.x) && (translation.x < 0 || swipeable?.state == .right)
    case (false, true):
        // only if swipe is horizontal and either to the right or to the left but menu is already open (so it gets dismissed)
        return abs(translation.y) <= abs(translation.x) && (translation.x > 0 || swipeable?.state == .left)
    }
}
@ivancantarino
Copy link

ivancantarino commented Oct 14, 2019

Hey.
I am encountering exactly the same problem.
I have a notes app that opens a side menu when the user swipes left-to-right; currently with this framework, even though I am only using the regular right swipe, it fires my other gesture recognizer that handles the menu swipe.
Did you solve the issue with the code you provided above?

@igorkulman
Copy link
Author

Hey.
I am encountering exactly the same problem.
I have a notes app that opens a side menu when the user swipes left-to-right; currently with this framework, even though I am only using the regular right swipe, it fires my other gesture recognizer that handles the menu swipe.
Did you solve the issue with the code you provided above?

Yes I am using exactly this snippet I posted here. Working fine so far.

@ivancantarino
Copy link

Thanks! I’ll try it out 🙃

Sent with GitHawk

@ivancantarino
Copy link

@igorkulman I don’t know if this happens to you: when I am right-to-left swipping the options appear, though if I slowly left to right slide to close the cell options the menu on the left hand side starts to open.
I’ll probably have to add a controller in my main gesture recognizer

Sent with GitHawk

@igorkulman
Copy link
Author

@igorkulman I don’t know if this happens to you: when I am right-to-left swipping the options appear, though if I slowly left to right slide to close the cell options the menu on the left hand side starts to open.
I’ll probably have to add a controller in my main gesture recognizer

Sent with GitHawk

I would guess this is related to the gesture implementation in your side menu. I do not have a problem like this with https://github.com/evnaz/ENSwiftSideMenu

@ivancantarino
Copy link

@igorkulman I don’t know if this happens to you: when I am right-to-left swipping the options appear, though if I slowly left to right slide to close the cell options the menu on the left hand side starts to open. ...

@igorkulman yeah, it’s probably some “bug” on my implementation!
I’ll have a look in that lib
Thanks 🙏

Sent with GitHawk

@ivankholod
Copy link

Thanks, for this reason I removed SwipeCellKit and use native swipe.

@ivancantarino
Copy link

Thanks, for this reason I removed SwipeCellKit and use native swipe.

I have done the same! I have managed to customize the native swipe as I wanted, though SwipeCellKit is pretty great

@igorkulman
Copy link
Author

Thanks, for this reason I removed SwipeCellKit and use native swipe.

That would be ideal, but sadly the native swipe only show both icon and text when the cell has a certain height, not always as SwipeCellKit.

@ivankholod
Copy link

Thanks, for this reason I removed SwipeCellKit and use native swipe.

That would be ideal, but sadly the native swipe only show both icon and text when the cell has a certain height, not always as SwipeCellKit.

I'll use SwipeCellKit again

thomasdao added a commit to thomasdao/SwipeCellKit that referenced this issue Dec 4, 2019
Prevent conflict with side menu, using the solution described in the comment thread
@igorkulman igorkulman linked a pull request Feb 12, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants