Skip to content

Commit 59869b9

Browse files
bcdariusgkatsev
authored andcommitted
fix(slider): suppress console warnings in Chrome for Android when scrubbing (videojs#5219)
Instead of calling preventDefault() on touchstart in Chrome, set touch-action: none style on progress control to prevent unintended scrolling. Fixes videojs#4650.
1 parent a29156c commit 59869b9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/css/components/_progress.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@include flex(auto);
77
@include display-flex(center);
88
min-width: 4em;
9+
touch-action: none;
910
}
1011

1112
.video-js .vjs-progress-control.disabled {

src/js/slider/slider.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import Component from '../component.js';
55
import * as Dom from '../utils/dom.js';
66
import {assign} from '../utils/obj';
7+
import {IS_CHROME} from '../utils/browser.js';
78

89
/**
910
* The base functionality for a slider. Can be vertical or horizontal.
@@ -145,7 +146,16 @@ class Slider extends Component {
145146
handleMouseDown(event) {
146147
const doc = this.bar.el_.ownerDocument;
147148

148-
event.preventDefault();
149+
if (event.type === 'mousedown') {
150+
event.preventDefault();
151+
}
152+
// Do not call preventDefault() on touchstart in Chrome
153+
// to avoid console warnings. Use a 'touch-action: none' style
154+
// instead to prevent unintented scrolling.
155+
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
156+
if (event.type === 'touchstart' && !IS_CHROME) {
157+
event.preventDefault();
158+
}
149159
Dom.blockTextSelection();
150160

151161
this.addClass('vjs-sliding');

0 commit comments

Comments
 (0)