Skip to content
This repository was archived by the owner on Nov 5, 2020. It is now read-only.
This repository was archived by the owner on Nov 5, 2020. It is now read-only.

Menu bounces to centre of frame when a gesture is received while the menu is opening #7

@meteochu

Description

@meteochu

Hello.

I'm trying to implement a radial menu where you could tap and hold the menu, which will open the menu and close it when the finger is lifted. The implementation works almost entirely, other than if you
lift your finger, while the menu is still opening, and immediately tap and hold the menu (and drag) it again. This results in the menu (or the mainItem of the menu) to bounce to the centre of the frame.

The following is my implementation. [self checkHitTarget] simply checks which item DLWMMenuItem is selected.

- (void)receivedPan:(UIPanGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu {

    switch (recognizer.state) {
        case UIGestureRecognizerStateBegan:
            if ([menu isClosedOrClosing]) {
                [self.menu open];
            }
            break;
        case UIGestureRecognizerStateChanged:
            [self checkHitTarget];
        case UIGestureRecognizerStateEnded:
        case UIGestureRecognizerStateCancelled:
        case UIGestureRecognizerStateFailed:
            if ([menu isOpenedOrOpening]){
                if (item == menu.mainItem){
                    [self.menu close];
                } else {
                    [menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc]init] forItem:item];
                }
            }
            break;
        default:
            break;
    }
}

I've tried going through most of the DLWMMenu implementation dropping break points everywhere, but I still can't pinpoint the exact place it'll break. I'm guessing it's something to do with the state of the menu while the menu is animating (closing or opening)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions