mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Focus on corresponding button
This commit is contained in:
parent
51bd2bef1a
commit
884ce171ea
1 changed files with 21 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
import escapeHtml from 'escape-html';
|
||||
import debounce from 'lodash-es/debounce';
|
||||
import { playbackManager } from '../../../components/playback/playbackmanager';
|
||||
import SyncPlay from '../../../components/syncPlay/core';
|
||||
import browser from '../../../scripts/browser';
|
||||
|
@ -217,9 +218,9 @@ import { appRouter } from '../../../components/appRouter';
|
|||
|
||||
let mouseIsDown = false;
|
||||
|
||||
function showOsd() {
|
||||
function showOsd(focusElement) {
|
||||
slideDownToShow(headerElement);
|
||||
showMainOsdControls();
|
||||
showMainOsdControls(focusElement);
|
||||
resetIdle();
|
||||
}
|
||||
|
||||
|
@ -273,7 +274,9 @@ import { appRouter } from '../../../components/appRouter';
|
|||
});
|
||||
}
|
||||
|
||||
function showMainOsdControls() {
|
||||
const _focus = debounce((focusElement) => focusManager.focus(focusElement), 50);
|
||||
|
||||
function showMainOsdControls(focusElement) {
|
||||
if (!currentVisibleMenu) {
|
||||
const elem = osdBottomElement;
|
||||
currentVisibleMenu = 'osd';
|
||||
|
@ -281,12 +284,14 @@ import { appRouter } from '../../../components/appRouter';
|
|||
elem.classList.remove('hide');
|
||||
elem.classList.remove('videoOsdBottom-hidden');
|
||||
|
||||
focusElement ||= elem.querySelector('.btnPause');
|
||||
|
||||
if (!layoutManager.mobile) {
|
||||
setTimeout(function () {
|
||||
focusManager.focus(elem.querySelector('.btnPause'));
|
||||
}, 50);
|
||||
_focus(focusElement);
|
||||
}
|
||||
toggleSubtitleSync();
|
||||
} else if (currentVisibleMenu === 'osd' && focusElement && !layoutManager.mobile) {
|
||||
_focus(focusElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1035,15 +1040,19 @@ import { appRouter } from '../../../components/appRouter';
|
|||
const key = keyboardnavigation.getKeyName(e);
|
||||
const isKeyModified = e.ctrlKey || e.altKey || e.metaKey;
|
||||
|
||||
const btnPlayPause = osdBottomElement.querySelector('.btnPause');
|
||||
|
||||
if (e.keyCode === 32) {
|
||||
if (e.target.tagName !== 'BUTTON' || !layoutManager.tv) {
|
||||
playbackManager.playPause(currentPlayer);
|
||||
showOsd(btnPlayPause);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Trick Firefox with a null element to skip next click
|
||||
clickedElement = null;
|
||||
} else {
|
||||
showOsd();
|
||||
}
|
||||
showOsd();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1075,7 @@ import { appRouter } from '../../../components/appRouter';
|
|||
break;
|
||||
case 'k':
|
||||
playbackManager.playPause(currentPlayer);
|
||||
showOsd();
|
||||
showOsd(btnPlayPause);
|
||||
break;
|
||||
case 'ArrowUp':
|
||||
case 'Up':
|
||||
|
@ -1080,13 +1089,13 @@ import { appRouter } from '../../../components/appRouter';
|
|||
case 'ArrowRight':
|
||||
case 'Right':
|
||||
playbackManager.fastForward(currentPlayer);
|
||||
showOsd();
|
||||
showOsd(btnFastForward);
|
||||
break;
|
||||
case 'j':
|
||||
case 'ArrowLeft':
|
||||
case 'Left':
|
||||
playbackManager.rewind(currentPlayer);
|
||||
showOsd();
|
||||
showOsd(btnRewind);
|
||||
break;
|
||||
case 'f':
|
||||
if (!e.ctrlKey && !e.metaKey) {
|
||||
|
@ -1114,7 +1123,7 @@ import { appRouter } from '../../../components/appRouter';
|
|||
// Ignores gamepad events that are always triggered, even when not focused.
|
||||
if (document.hasFocus()) { /* eslint-disable-line compat/compat */
|
||||
playbackManager.rewind(currentPlayer);
|
||||
showOsd();
|
||||
showOsd(btnRewind);
|
||||
}
|
||||
break;
|
||||
case 'NavigationRight':
|
||||
|
@ -1123,7 +1132,7 @@ import { appRouter } from '../../../components/appRouter';
|
|||
// Ignores gamepad events that are always triggered, even when not focused.
|
||||
if (document.hasFocus()) { /* eslint-disable-line compat/compat */
|
||||
playbackManager.fastForward(currentPlayer);
|
||||
showOsd();
|
||||
showOsd(btnFastForward);
|
||||
}
|
||||
break;
|
||||
case 'Home':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue