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 Events from '../utils/events.ts';
|
||||||
|
|
||||||
import '../styles/lyrics.scss';
|
import '../styles/lyrics.scss';
|
||||||
|
import { AutoScrollType } from './lyrics.types';
|
||||||
|
|
||||||
let currentPlayer;
|
let currentPlayer;
|
||||||
let currentItem;
|
let currentItem;
|
||||||
|
|
||||||
let savedLyrics;
|
let savedLyrics;
|
||||||
let isDynamicLyric = false;
|
let isDynamicLyric = false;
|
||||||
let autoScroll = true;
|
let autoScroll = AutoScrollType.Smooth;
|
||||||
|
|
||||||
function dynamicLyricHtmlReducer(htmlAccumulator, lyric, index) {
|
function dynamicLyricHtmlReducer(htmlAccumulator, lyric, index) {
|
||||||
if (layoutManager.tv) {
|
if (layoutManager.tv) {
|
||||||
|
@ -72,9 +73,14 @@ export default function (view) {
|
||||||
if (lyric) {
|
if (lyric) {
|
||||||
lyric.classList.remove('pastLyric');
|
lyric.classList.remove('pastLyric');
|
||||||
lyric.classList.remove('futureLyric');
|
lyric.classList.remove('futureLyric');
|
||||||
if (autoScroll) {
|
if (autoScroll === AutoScrollType.Smooth) {
|
||||||
scrollManager.scrollToElement(lyric, true);
|
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) {
|
function onLyricClick(lyricTime) {
|
||||||
autoScroll = true;
|
autoScroll = AutoScrollType.Smooth;
|
||||||
playbackManager.seek(lyricTime);
|
playbackManager.seek(lyricTime);
|
||||||
if (playbackManager.paused()) {
|
if (playbackManager.paused()) {
|
||||||
playbackManager.playPause(currentPlayer);
|
playbackManager.playPause(currentPlayer);
|
||||||
|
@ -242,19 +248,19 @@ export default function (view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWheelOrTouchMove() {
|
function onWheelOrTouchMove() {
|
||||||
autoScroll = false;
|
autoScroll = AutoScrollType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(e) {
|
function onKeyDown(e) {
|
||||||
const key = keyboardNavigation.getKeyName(e);
|
const key = keyboardNavigation.getKeyName(e);
|
||||||
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
||||||
autoScroll = false;
|
autoScroll = AutoScrollType.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
Events.on(playbackManager, 'playerchange', onPlayerChange);
|
Events.on(playbackManager, 'playerchange', onPlayerChange);
|
||||||
autoScroll = true;
|
autoScroll = AutoScrollType.Instant;
|
||||||
document.addEventListener('wheel', onWheelOrTouchMove);
|
document.addEventListener('wheel', onWheelOrTouchMove);
|
||||||
document.addEventListener('touchmove', onWheelOrTouchMove);
|
document.addEventListener('touchmove', onWheelOrTouchMove);
|
||||||
document.addEventListener('keydown', onKeyDown);
|
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