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 gesture return null direction value on IOS #40

Open
ManishKumarPandia opened this issue Jul 23, 2019 · 3 comments
Open

Swipe gesture return null direction value on IOS #40

ManishKumarPandia opened this issue Jul 23, 2019 · 3 comments

Comments

@ManishKumarPandia
Copy link

ManishKumarPandia commented Jul 23, 2019

Here is the detail

<GestureRecognizer
                onSwipe={(direction, state) => this.onSwipe(direction, state, item)}
For Onswipe 
    onSwipe(gestureName, gestureState, item) {
        console.log("direction is="+gestureName);
        let { outletInfo, assetFilter, tags, imageOlderThanHrs, locationClassification, market, imageStatus } = this.state;
        const { SWIPE_LEFT, SWIPE_RIGHT } = swipeDirections;
        let paramsObj = {
            AssetPurityId: item.AssetPurityId ? item.AssetPurityId : 0,
            AssetId: item.AssetId
        };
        switch (gestureName) {
            case SWIPE_LEFT:
                Object.assign(paramsObj, { PrevNext: 1 });
                break;
            case SWIPE_RIGHT:
                Object.assign(paramsObj, { PrevNext: -1 });
                break;
        }

Gatting null direction in starting 3-4 attempt

@ReallyLiri
Copy link

ReallyLiri commented Nov 30, 2019

I found the following workaround:

onSwipe={(gestureName, gestureState) => {
                    const {dy} = gestureState;
                    if (dy > 0) {
                        // swiped down
                    }
                    else if (dy < 0) {
                        // swiped up
                    }
                }}

you can do similar logic to swiping left/right, just note the troubles of determining wether it was a horizontal or vertical swipe (you can use threshold from config)

@nerycordova
Copy link

@ReallyLiri works for me. I have handlers for swipe left and right. In addition, if direcciont === null in onSwipe, then I make an attempt to derive user intention as per your suggestion.

onSwipe={ (direction, state) => {
                    const {dx} = state;
                    if (direction === null){
                        if (dx > 0) {
                            console.log('swipe right');
                        }
                        else if (dx < 0) {
                            console.log('swipe left');
                        }
                    }

                } }

I do feel that the UX is better this way.

@Diabl0269
Copy link

I wrote some code in this issue #52 which might help these problems :)

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

4 participants