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

Use passive event listeners for touchstart/touchmove #4440

Merged
merged 3 commits into from
Jun 28, 2017

Conversation

mister-ben
Copy link
Contributor

@mister-ben mister-ben commented Jun 23, 2017

Description

Not using passive event listeners now causes Chrome to log warnings to the console, and possibly has a performance impact
Fixes #4432

Specific Changes proposed

Where supported, use passive event listeners for touchmove and touchstart

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
  • Reviewed by Two Core Contributors

Copy link
Member

@misteroneill misteroneill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment/thought, but LGTM.

let options = false;

if (_supportsPassive &&
['touchstart', 'touchmove'].indexOf(type) > -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this array ought to be defined once in the parent scope rather than inline. Something like:

const passiveEvents = [
  'touchstart',
  'touchmove'
];

*/
let _supportsPassive = false;

try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should wrap this try/catch in an iife.

@misteroneill
Copy link
Member

Looks like this will fix #4432 (we should not that in the merge commit).

@gkatsev
Copy link
Member

gkatsev commented Jun 27, 2017

We probably should make this against 5.x as well.

@gkatsev gkatsev merged commit b4dc4f8 into videojs:master Jun 28, 2017
gkatsev pushed a commit that referenced this pull request Jul 4, 2017
If passive event listening is supported, we should use it.

5.x version of #4440.

Fixes #4432.
biggun1860 added a commit to biggun1860/video.js that referenced this pull request Jul 29, 2017
fix: Use passive event listeners for touchstart/touchmove (videojs#4440)
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

Successfully merging this pull request may close these issues.

Chrome Violation: Non-passive scroll handlers
3 participants