fix: add eventType support for touch devices (#3508)

fixes Not selectable items in quality settings menu #3368
This commit is contained in:
Varun Gujarathi 2024-01-10 11:15:57 +05:30 committed by GitHub
parent d3a8ffb3b7
commit 139ec51dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,10 +58,17 @@ export function createVideoSettingsMenuButton(
});
});
let clickEvent;
if ('ontouchstart' in window) {
clickEvent = 'touchend'; // Use touchend event for touch devices
} else {
clickEvent = 'click'; // Use click for all other devices
}
for (let i = 0; i < items.length; i += 1) {
const item = items[i];
// Quality selected
item.on('click', () => {
item.on(clickEvent, () => {
// If for some reason tech doesn't exist, then don't do anything
if (!tech) {
console.warn('Invalid attempt to access null player tech');
@ -77,7 +84,7 @@ export function createVideoSettingsMenuButton(
});
}
defaultAutoItem.on('click', () => {
defaultAutoItem.on(clickEvent, () => {
// Re-enable all representations.
tech.vhs.representations().forEach(rep => {
rep.enabled(true);