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

Swiping video causes video to play on ipad iOS 8.1 #1817

Closed
smohadjer opened this issue Jan 21, 2015 · 12 comments
Closed

Swiping video causes video to play on ipad iOS 8.1 #1817

smohadjer opened this issue Jan 21, 2015 · 12 comments

Comments

@smohadjer
Copy link

If I go to videojs.com and swipe video in an attempt to scroll the page the video starts playing! If I pause video and swipe again, video does not start playing. Why video plays on first swipe? How can I avoid video play during page swiping?

@mmcc
Copy link
Member

mmcc commented Jan 21, 2015

I can quasi-confirm this one. On both an iPad and iPhone it works fine if I scroll how I normally do, but if I shorten it to more of a quick, swiping motion then it will trigger a click event most of the time. We should probably decrease the length that's considered a swipe vs click?

@smohadjer
Copy link
Author

I can accept that a slow swipe be mistaken for a click, but a fast swipe being counted as click is certainly wrong. Either way why doesn't it happen after video is paused?

@mmcc
Copy link
Member

mmcc commented Jan 21, 2015

Why would you expect an actual dragging motion to be mistaken for a click? I'm having to actively change how I scroll to reproduce this, but it seems like a reasonable movement so I agree that it's probably worth experimenting with a lower tap movement threshold. Want to find a lower number that works for this movement and submit a PR?

Didn't notice the second question (or late edit that I missed). Looks like the video element isn't tappable on the iPad when using custom controls, so after the video is paused you actually have to hit the play button to continue playback. Initially the entire poster is a clickable element, which is what's registering that initial tap event.

@mmcc mmcc removed the browser bug label Jan 21, 2015
@smohadjer
Copy link
Author

No, I can play video after it's stopped by tapping anywhere on the video on iPad, but I can't play it by swiping. This makes me wonder if the problem lies indeed in swipe logic because then swiping should continue to trigger a click after video is stopped and hence play it, same as a click does.

@mmcc
Copy link
Member

mmcc commented Jan 21, 2015

Well that's strange, I'll hold off opening an issue for that, then...For whatever reason click events on the player itself aren't working for me. Our iPad for testing just died, so I'll play with that more later today.

FWIW, I don't think that's related to the click / swipe confusion. A quick look around for the tap threshold in other projects shows anything from 2 (hammer.js) to 11, which even on the larger end is still half what our current tap movement threshold is.

I'll test the element-click issue more later today and open a separate issue if need be.

@smohadjer
Copy link
Author

I don't think reducing the tap threshold is the right way to better differentiate taps from swipes. Perhaps it would be better if we take velocity also into account. This article explains the problem well:

http://minuum.com/taps-and-swipes/

For example in touchend handler you can trigger tap only if velocity is less than 1 px/ms.

@mmcc
Copy link
Member

mmcc commented Jan 21, 2015

I think lowering the tap threshold would improve things, but a PR taking velocity into account would certainly be welcome.

@Jackipy
Copy link

Jackipy commented Jan 27, 2015

I am hitting the same issue on iPhone iOS 8.1.2 as well.

I am building a webpage with a list of videos, and scrolling through the page would inevitably open a video by accident. Unfortunately, iOS launches the video in full screen and interrupts the user's scrolling. The user has to close the full screen video and "be careful" not to scroll too fast. This makes the page very hard to use.

@steverandy
Copy link

There are two things that cause this issue:

  1. touchDistance is always 0 on iOS devices (I tested on iOS 8).
  2. tapMovementThreshold and touchTime values are set to high (currently 22 and 250)

I have already sent a pull request to fix point 1, #1809.
For point 2, I propose we use 10 for tapMovementThreshold and 200 for touchTime like what fastclick lib is using.

@Jackipy
Copy link

Jackipy commented Jan 27, 2015

Steve - thanks for submitting the fix for 1 and looking into 2! I am really looking forward to seeing this fixed in the next release.

@mmcc
Copy link
Member

mmcc commented Jan 27, 2015

Thanks for the ping on this one, I'd been meaning to put out a PR for tapMovementThreshold, but I think it makes sense to also reduce the touchTime threshold to what @steverandy suggests. Patch PR: #1830

@mmcc
Copy link
Member

mmcc commented Jul 25, 2015

That PR was merged in, so closing.

@mmcc mmcc closed this as completed Jul 25, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants