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

Can't trigger long taps on Surface Pro #166

Open
mhmxd opened this issue May 1, 2020 · 8 comments
Open

Can't trigger long taps on Surface Pro #166

mhmxd opened this issue May 1, 2020 · 8 comments
Assignees
Labels
awaiting-feedback The issue requires more feedback from the original poster. investigating The developer is currently investigating the cause or solution to this issue.

Comments

@mhmxd
Copy link

mhmxd commented May 1, 2020

Firstly, thanks for the plugins!

But I encountered this issue of tapend or taphold not getting called when touching on my Surface Pro, on neither Chrome nor Firefox.
When I click with mouse or hold the click, the events are called with no problem. but when touching, only quick tapping fires tapstart/tapend/taphold and holding the touch triggers none of them.

What do you think is causing this?

@benmajor
Copy link
Owner

benmajor commented May 1, 2020

Can you please send me the user agent that you're using? I suspect it could be an issue with the touch detection.

Do the other events function as expected? In particular, I'd be interested if tapstart, tapend work.

@mhmxd
Copy link
Author

mhmxd commented May 1, 2020

The user agent for Firefox:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0

Chrome:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36

Yes, the tapstart/tapend work when I click or click and hold, also when I tap with finger.
But when I touch and hold with finger, none of them works. Nothing is shown in the console.

@mhmxd
Copy link
Author

mhmxd commented May 1, 2020

I just checked, jQuery Mobile has the same exact issue.

@benmajor
Copy link
Owner

benmajor commented May 1, 2020

Interesting, I can't seem to replicate it by changing the UA alone, so I think it must be something in the Surface Pro sandbox. Can you do me a favour and try using the unminified code in this commit:

f09999d

It basically reduces the threshold for taphold down to 500ms, instead of 750. If that improves the behaviour, there's obviously some native event going on that needs to be cancelled first.

@benmajor benmajor self-assigned this May 1, 2020
@benmajor benmajor added awaiting-feedback The issue requires more feedback from the original poster. investigating The developer is currently investigating the cause or solution to this issue. labels May 1, 2020
@mhmxd
Copy link
Author

mhmxd commented May 2, 2020

I tried that code and no difference. The same behavior.

@mhmxd
Copy link
Author

mhmxd commented May 2, 2020

Correction to my previous comment: I got it working with jquery mobile (v. 1.4.5) and jquery v.1.11.3 (lower version due to compatibility with jquery mobile).

It doesn't have tapstart or tapend, but tap and taphold both work with finger, as well as mouse click.

@benmajor
Copy link
Owner

benmajor commented May 3, 2020

It appears that holding a touch on the Surface Pro actually selects the element. As such, I don't think it's actually a fault with the library, you just need to prevent the default action. Can you see if the following works:

$(element).on('touchstart', (e => { e.preventDefault(); }));
$(element).on('taphold', function(e) { });

@mhmxd
Copy link
Author

mhmxd commented May 4, 2020

Unfortunately, that didn't work. It seems though the preventDefault() takes effect, as the button I have on the screen loses the "pressing" state.
But the functions still don't work.

I did some testing with Touch Events in JS and interestingly, they all work perfectly. Even without the preventDefault(). The touchstart, touchend, touchmove all get triggered, and only by the touch (not the mouse click).

I also tried to combine the two with something like this: (though not sure it is even permissible)

function handleStart(e){
    e.preventDefault();
    console.log("touchStart");
}

$("#clickButton").on("taphold", function(e) {
    console.log('taphold');
});

but this also doesn't work. Only "touchStart" is shown in console.

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. investigating The developer is currently investigating the cause or solution to this issue.
Projects
None yet
Development

No branches or pull requests

2 participants