1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-02 06:32:07 +02:00

fix: Support MacOS trackpad with tap-to-click (#8700)

This commit is contained in:
mister-ben 2024-04-25 18:38:05 +02:00 committed by GitHub
parent 466fa9761c
commit cb76a24bd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -773,6 +773,11 @@ export function isSingleLeftClick(event) {
return true;
}
// MacOS Sonoma trackpad when "tap to click enabled"
if (event.type === 'mousedown' && event.button === 0 && event.buttons === 0) {
return true;
}
if (event.button !== 0 || event.buttons !== 1) {
// This is the reason we have those if else block above
// if any special case we can catch and let it slide

View File

@ -656,12 +656,6 @@ QUnit.test('isSingleLeftClick() returns true for mouseup event', function(assert
QUnit.test('isSingleLeftClick() checks return values for mousedown event', function(assert) {
const mouseEvent = TestHelpers.createEvent('mousedown');
// Left mouse click
mouseEvent.button = 0;
mouseEvent.buttons = 0;
assert.notOk(Dom.isSingleLeftClick(mouseEvent), 'a left mouse click on an older browser (Safari) is a single left click');
// Left mouse click
mouseEvent.button = 0;
mouseEvent.buttons = 1;
@ -685,6 +679,12 @@ QUnit.test('isSingleLeftClick() checks return values for mousedown event', funct
mouseEvent.buttons = undefined;
assert.ok(Dom.isSingleLeftClick(mouseEvent), 'a touch event on simulated mobiles is a single left click');
// MacOS trackpad "tap to click". Sonoma always does this, previous MacOS did this inconsistently, buttons was usally 1.
mouseEvent.button = 0;
mouseEvent.buttons = 0;
assert.ok(Dom.isSingleLeftClick(mouseEvent), 'a tap-to-click on Mac trackpad is a single left click');
});
QUnit.test('Dom.copyStyleSheetsToWindow() copies all style sheets to a window', function(assert) {