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

SwipeUp call's SwipeLeft #18

Closed
Nalyvaiko opened this issue Jun 5, 2017 · 3 comments
Closed

SwipeUp call's SwipeLeft #18

Nalyvaiko opened this issue Jun 5, 2017 · 3 comments

Comments

@Nalyvaiko
Copy link

Why SwipeUp call's SwipeLeft and SwipeDown calls SwipeRight ??? How to fix that???

@leandrowd
Copy link
Owner

leandrowd commented Jun 24, 2017

Hi @Nalyvaiko, when swiping, if you have any vertical movement, onSwipeDown or onSwipeUp will be called. Likewise, any horizontal movement will call onSwipeRight or onSwipeLeft. A vertical and horizontal movement at the same time would call onSwipeDown and onSwipeLeft together, for instance.

It's up to you to disable one or another if you need. You can do that by cancelling the handler through some calculations on your onSwipeMove handler.

Something like the code below would solve your problem:

    onSwipeMove = (delta) => {
        this.isHorizontal = delta.x > delta.y;
    }

    onSwipeLeft = () => {
        if (!this.isHorizontal) {
            return;
        }

        // your handler to swipe left
    }

    onSwipeDown = () => {
        if (this.isHorizontal) {
            return;
        }

        // your handler to swipe down
    }

@leandrowd
Copy link
Owner

leandrowd commented Jul 3, 2017

Closing due to inactivity. Feel free to reopen if you need.

@danielkorte
Copy link

I ran across this issue while using this package (thanks!) and I wanted to share that I think the above code should modified to handle both left and right horizontal movements:

    onSwipeMove = (delta) => {
        this.isHorizontal = Math.abs(delta.x) > Math.abs(delta.y);
    }

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

3 participants