mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Instant scroll when enter webview. Enums to determine
This commit is contained in:
parent
a4c88e59eb
commit
cfcfbe934b
2 changed files with 17 additions and 6 deletions
|
@ -13,13 +13,14 @@ import LibraryMenu from '../scripts/libraryMenu';
|
|||
import Events from '../utils/events.ts';
|
||||
|
||||
import '../styles/lyrics.scss';
|
||||
import { AutoScrollType } from './lyrics.types';
|
||||
|
||||
let currentPlayer;
|
||||
let currentItem;
|
||||
|
||||
let savedLyrics;
|
||||
let isDynamicLyric = false;
|
||||
let autoScroll = true;
|
||||
let autoScroll = AutoScrollType.Smooth;
|
||||
|
||||
function dynamicLyricHtmlReducer(htmlAccumulator, lyric, index) {
|
||||
if (layoutManager.tv) {
|
||||
|
@ -72,9 +73,14 @@ export default function (view) {
|
|||
if (lyric) {
|
||||
lyric.classList.remove('pastLyric');
|
||||
lyric.classList.remove('futureLyric');
|
||||
if (autoScroll) {
|
||||
if (autoScroll === AutoScrollType.Smooth) {
|
||||
scrollManager.scrollToElement(lyric, true);
|
||||
}
|
||||
if (autoScroll === AutoScrollType.Instant) {
|
||||
// instant scroll is used when the view is first loaded
|
||||
scrollManager.scrollToElement(lyric, false);
|
||||
autoScroll = AutoScrollType.Smooth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +190,7 @@ export default function (view) {
|
|||
}
|
||||
|
||||
function onLyricClick(lyricTime) {
|
||||
autoScroll = true;
|
||||
autoScroll = AutoScrollType.Smooth;
|
||||
playbackManager.seek(lyricTime);
|
||||
if (playbackManager.paused()) {
|
||||
playbackManager.playPause(currentPlayer);
|
||||
|
@ -242,19 +248,19 @@ export default function (view) {
|
|||
}
|
||||
|
||||
function onWheelOrTouchMove() {
|
||||
autoScroll = false;
|
||||
autoScroll = AutoScrollType.None;
|
||||
}
|
||||
|
||||
function onKeyDown(e) {
|
||||
const key = keyboardNavigation.getKeyName(e);
|
||||
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
||||
autoScroll = false;
|
||||
autoScroll = AutoScrollType.None;
|
||||
}
|
||||
}
|
||||
|
||||
view.addEventListener('viewshow', function () {
|
||||
Events.on(playbackManager, 'playerchange', onPlayerChange);
|
||||
autoScroll = true;
|
||||
autoScroll = AutoScrollType.Instant;
|
||||
document.addEventListener('wheel', onWheelOrTouchMove);
|
||||
document.addEventListener('touchmove', onWheelOrTouchMove);
|
||||
document.addEventListener('keydown', onKeyDown);
|
||||
|
|
5
src/controllers/lyrics.types.ts
Normal file
5
src/controllers/lyrics.types.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export enum AutoScrollType {
|
||||
None = 0,
|
||||
Smooth = 1,
|
||||
Instant = 2
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue