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

Wrong swipe direction #165

Closed
ctwist opened this issue Apr 22, 2020 · 3 comments
Closed

Wrong swipe direction #165

ctwist opened this issue Apr 22, 2020 · 3 comments
Assignees
Labels
awaiting-feedback The issue requires more feedback from the original poster.

Comments

@ctwist
Copy link

ctwist commented Apr 22, 2020

I am getting some incorrect swipe directions. If I swipe right, this is sometimes interpreted as a swipe up. This happens if I deviate slightly from a flat sideways swipe.

I looked at the code. The problem is in these statements:

            if (originalCoord.y > finalCoord.y && (originalCoord.y - finalCoord.y > v_threshold)) {
                swipedir = 'swipeup';
            }
            if (originalCoord.x < finalCoord.x && (finalCoord.x - originalCoord.x > h_threshold)) {
                swipedir = 'swiperight';
            }

If a slight vertical swipe amount exceeds the threshhold, it is interpreted as swipeup, even though a much greater horizontal swipe occurred.

If there is more horizontal movement than vertical movement, this should be interpreted as swiperight.

Edit:
Actually it is the next 2 statements that "win":

            if (originalCoord.y < finalCoord.y && (finalCoord.y - originalCoord.y > v_threshold)) {
                swipedir = 'swipedown';
            }

So the swiperight is interpreted as swipedown.

@benmajor
Copy link
Owner

Thanks for the heads up. Are you able to share a basic working example which demonstrates this? I will be happy to look into it, but I fear that it could be difficult. The library doesn't know anything about other events that are bound to the element, only the one that it is currently occurring.

Is it not viable that you can increase the threshold for a vertical swipe?

@benmajor benmajor self-assigned this Apr 23, 2020
@benmajor benmajor added the awaiting-feedback The issue requires more feedback from the original poster. label Apr 23, 2020
@ctwist
Copy link
Author

ctwist commented Apr 23, 2020

I have attached a fixed version of jquery.mobile-events.js. I have tested it and it has fixed the problem.
(I have not attached a file before; I hope I have done it correctly)

jquery.mobile-events.txt

@ctwist ctwist closed this as completed Apr 23, 2020
@ctwist ctwist reopened this Apr 23, 2020
@benmajor
Copy link
Owner

Thanks for the fix. I have now released a new version which includes this fix:
5db124d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback The issue requires more feedback from the original poster.
Projects
None yet
Development

No branches or pull requests

2 participants