1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #4774 from thornbill/owner-of-a-lonely-if

This commit is contained in:
Bill Thornton 2023-09-14 10:53:21 -04:00 committed by GitHub
commit bb44ba022d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 155 additions and 223 deletions

View file

@ -49,6 +49,7 @@ module.exports = {
'no-empty-function': ['error'], 'no-empty-function': ['error'],
'no-extend-native': ['error'], 'no-extend-native': ['error'],
'no-floating-decimal': ['error'], 'no-floating-decimal': ['error'],
'no-lonely-if': ['error'],
'no-multi-spaces': ['error'], 'no-multi-spaces': ['error'],
'no-multiple-empty-lines': ['error', { 'max': 1 }], 'no-multiple-empty-lines': ['error', { 'max': 1 }],
'no-nested-ternary': ['error'], 'no-nested-ternary': ['error'],

View file

@ -803,19 +803,17 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
} else { } else {
lines.push(escapeHtml(item.SeriesName)); lines.push(escapeHtml(item.SeriesName));
} }
} else if (isUsingLiveTvNaming(item)) {
lines.push(escapeHtml(item.Name));
if (!item.EpisodeTitle && !item.IndexNumber) {
titleAdded = true;
}
} else { } else {
if (isUsingLiveTvNaming(item)) { const parentTitle = item.SeriesName || item.Series || item.Album || item.AlbumArtist || '';
lines.push(escapeHtml(item.Name));
if (!item.EpisodeTitle && !item.IndexNumber) { if (parentTitle || showTitle) {
titleAdded = true; lines.push(escapeHtml(parentTitle));
}
} else {
const parentTitle = item.SeriesName || item.Series || item.Album || item.AlbumArtist || '';
if (parentTitle || showTitle) {
lines.push(escapeHtml(parentTitle));
}
} }
} }
} }
@ -898,13 +896,11 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
if (item.Type === 'Series') { if (item.Type === 'Series') {
if (item.Status === 'Continuing') { if (item.Status === 'Continuing') {
lines.push(globalize.translate('SeriesYearToPresent', productionYear || '')); lines.push(globalize.translate('SeriesYearToPresent', productionYear || ''));
} else if (item.EndDate && item.ProductionYear) {
const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false });
lines.push(productionYear + ((endYear === item.ProductionYear) ? '' : (' - ' + endYear)));
} else { } else {
if (item.EndDate && item.ProductionYear) { lines.push(productionYear || '');
const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false });
lines.push(productionYear + ((endYear === item.ProductionYear) ? '' : (' - ' + endYear)));
} else {
lines.push(productionYear || '');
}
} }
} else { } else {
lines.push(productionYear || ''); lines.push(productionYear || '');

View file

@ -762,12 +762,10 @@ function Guide(options) {
} else { } else {
container.scrollTo(0, pos); container.scrollTo(0, pos);
} }
} else if (horizontal) {
container.scrollLeft = Math.round(pos);
} else { } else {
if (horizontal) { container.scrollTop = Math.round(pos);
container.scrollLeft = Math.round(pos);
} else {
container.scrollTop = Math.round(pos);
}
} }
} }

View file

@ -216,14 +216,12 @@ function getFetchLatestItemsFn(serverId, parentId, collectionType) {
if (collectionType === 'music') { if (collectionType === 'music') {
limit = 30; limit = 30;
} }
} else if (collectionType === 'tvshows') {
limit = 5;
} else if (collectionType === 'music') {
limit = 9;
} else { } else {
if (collectionType === 'tvshows') { limit = 8;
limit = 5;
} else if (collectionType === 'music') {
limit = 9;
} else {
limit = 8;
}
} }
const options = { const options = {

View file

@ -76,20 +76,18 @@ export function handleHlsJsMediaError(instance, reject) {
recoverDecodingErrorDate = now; recoverDecodingErrorDate = now;
console.debug('try to recover media Error ...'); console.debug('try to recover media Error ...');
hlsPlayer.recoverMediaError(); hlsPlayer.recoverMediaError();
} else if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) {
recoverSwapAudioCodecDate = now;
console.debug('try to swap Audio Codec and recover media Error ...');
hlsPlayer.swapAudioCodec();
hlsPlayer.recoverMediaError();
} else { } else {
if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) { console.error('cannot recover, last media error recovery failed ...');
recoverSwapAudioCodecDate = now;
console.debug('try to swap Audio Codec and recover media Error ...');
hlsPlayer.swapAudioCodec();
hlsPlayer.recoverMediaError();
} else {
console.error('cannot recover, last media error recovery failed ...');
if (reject) { if (reject) {
reject(); reject();
} else { } else {
onErrorInternal(instance, 'mediadecodeerror'); onErrorInternal(instance, 'mediadecodeerror');
}
} }
} }
} }

View file

@ -171,14 +171,12 @@ function getRemoteImageHtml(image, imageType) {
shape = 'banner'; shape = 'banner';
} else if (imageType === 'Disc') { } else if (imageType === 'Disc') {
shape = 'square'; shape = 'square';
} else if (currentItemType === 'Episode') {
shape = 'backdrop';
} else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') {
shape = 'square';
} else { } else {
if (currentItemType === 'Episode') { shape = 'portrait';
shape = 'backdrop';
} else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') {
shape = 'square';
} else {
shape = 'portrait';
}
} }
cssClass += ' ' + shape + 'Card ' + shape + 'Card-scalable'; cssClass += ' ' + shape + 'Card ' + shape + 'Card-scalable';
@ -230,10 +228,8 @@ function getRemoteImageHtml(image, imageType) {
if (image.Language) { if (image.Language) {
html += ' • ' + image.Language; html += ' • ' + image.Language;
} }
} else { } else if (image.Language) {
if (image.Language) { html += image.Language;
html += image.Language;
}
} }
html += '</div>'; html += '</div>';
@ -244,16 +240,14 @@ function getRemoteImageHtml(image, imageType) {
if (image.RatingType === 'Likes') { if (image.RatingType === 'Likes') {
html += image.CommunityRating + (image.CommunityRating === 1 ? ' like' : ' likes'); html += image.CommunityRating + (image.CommunityRating === 1 ? ' like' : ' likes');
} else { } else if (image.CommunityRating) {
if (image.CommunityRating) { html += image.CommunityRating.toFixed(1);
html += image.CommunityRating.toFixed(1);
if (image.VoteCount) { if (image.VoteCount) {
html += ' • ' + image.VoteCount + (image.VoteCount === 1 ? ' vote' : ' votes'); html += ' • ' + image.VoteCount + (image.VoteCount === 1 ? ' vote' : ' votes');
}
} else {
html += 'Unrated';
} }
} else {
html += 'Unrated';
} }
html += '</div>'; html += '</div>';

View file

@ -164,10 +164,8 @@ function getCardHtml(image, apiClient, options) {
} else { } else {
html += '<button type="button" is="paper-icon-button-light" class="autoSize" disabled title="' + globalize.translate('MoveRight') + '"><span class="material-icons chevron_right" aria-hidden="true"></span></button>'; html += '<button type="button" is="paper-icon-button-light" class="autoSize" disabled title="' + globalize.translate('MoveRight') + '"><span class="material-icons chevron_right" aria-hidden="true"></span></button>';
} }
} else { } else if (options.imageProviders.length) {
if (options.imageProviders.length) { html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('Search') + '"><span class="material-icons search" aria-hidden="true"></span></button>';
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('Search') + '"><span class="material-icons search" aria-hidden="true"></span></button>';
}
} }
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" data-index="' + (image.ImageIndex != null ? image.ImageIndex : 'null') + '" class="btnDeleteImage autoSize" title="' + globalize.translate('Delete') + '"><span class="material-icons delete" aria-hidden="true"></span></button>'; html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" data-index="' + (image.ImageIndex != null ? image.ImageIndex : 'null') + '" class="btnDeleteImage autoSize" title="' + globalize.translate('Delete') + '"><span class="material-icons delete" aria-hidden="true"></span></button>';

View file

@ -374,14 +374,12 @@ export function getListViewHtml(options) {
if (options.artist !== false && item.AlbumArtist && item.Type === 'MusicAlbum') { if (options.artist !== false && item.AlbumArtist && item.Type === 'MusicAlbum') {
textlines.push(item.AlbumArtist); textlines.push(item.AlbumArtist);
} }
} else { } else if (options.artist) {
if (options.artist) { const artistItems = item.ArtistItems;
const artistItems = item.ArtistItems; if (artistItems && item.Type !== 'MusicAlbum') {
if (artistItems && item.Type !== 'MusicAlbum') { textlines.push(artistItems.map(a => {
textlines.push(artistItems.map(a => { return a.Name;
return a.Name; }).join(', '));
}).join(', '));
}
} }
} }

View file

@ -649,10 +649,8 @@ function onPlaybackStopped(e, state) {
if (state.NextMediaType !== 'Audio') { if (state.NextMediaType !== 'Audio') {
hideNowPlayingBar(); hideNowPlayingBar();
} }
} else { } else if (!state.NextMediaType) {
if (!state.NextMediaType) { hideNowPlayingBar();
hideNowPlayingBar();
}
} }
} }

View file

@ -1416,15 +1416,13 @@ class PlaybackManager {
if (Screenfull.isEnabled) { if (Screenfull.isEnabled) {
Screenfull.toggle(); Screenfull.toggle();
} else { } else if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
// iOS Safari // iOS Safari
if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { document.webkitCancelFullscreen();
document.webkitCancelFullscreen(); } else {
} else { const elem = document.querySelector('video');
const elem = document.querySelector('video'); if (elem?.webkitEnterFullscreen) {
if (elem?.webkitEnterFullscreen) { elem.webkitEnterFullscreen();
elem.webkitEnterFullscreen();
}
} }
} }
}; };

View file

@ -191,15 +191,13 @@ function onRecordChange(e) {
loading.hide(); loading.hide();
}); });
} }
} else { } else if (hasEnabledTimer) {
if (hasEnabledTimer) { loading.show();
loading.show(); recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () {
recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () { Events.trigger(self, 'recordingchanged');
Events.trigger(self, 'recordingchanged'); fetchData(self);
fetchData(self); loading.hide();
loading.hide(); });
});
}
} }
} }
@ -223,13 +221,11 @@ function onRecordSeriesChange(e) {
fetchData(self); fetchData(self);
}); });
} }
} else { } else if (this.SeriesTimerId) {
if (this.SeriesTimerId) { apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () {
apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () { toast(globalize.translate('RecordingCancelled'));
toast(globalize.translate('RecordingCancelled')); fetchData(self);
fetchData(self); });
});
}
} }
} }

View file

@ -73,12 +73,10 @@ export function loadView(options) {
} else { } else {
mainAnimatedPages.replaceChild(view, currentPage); mainAnimatedPages.replaceChild(view, currentPage);
} }
} else if (newViewInfo.hasScript && window.$) {
view = $(view).appendTo(mainAnimatedPages)[0];
} else { } else {
if (newViewInfo.hasScript && window.$) { mainAnimatedPages.appendChild(view);
view = $(view).appendTo(mainAnimatedPages)[0];
} else {
mainAnimatedPages.appendChild(view);
}
} }
if (options.type) { if (options.type) {

View file

@ -484,13 +484,11 @@ window.DashboardPage = {
if (nowPlayingItem.Artists?.length) { if (nowPlayingItem.Artists?.length) {
bottomText = topText; bottomText = topText;
topText = escapeHtml(nowPlayingItem.Artists[0]); topText = escapeHtml(nowPlayingItem.Artists[0]);
} else { } else if (nowPlayingItem.SeriesName || nowPlayingItem.Album) {
if (nowPlayingItem.SeriesName || nowPlayingItem.Album) { bottomText = topText;
bottomText = topText; topText = escapeHtml(nowPlayingItem.SeriesName || nowPlayingItem.Album);
topText = escapeHtml(nowPlayingItem.SeriesName || nowPlayingItem.Album); } else if (nowPlayingItem.ProductionYear) {
} else if (nowPlayingItem.ProductionYear) { bottomText = nowPlayingItem.ProductionYear;
bottomText = nowPlayingItem.ProductionYear;
}
} }
if (nowPlayingItem.ImageTags?.Logo) { if (nowPlayingItem.ImageTags?.Logo) {

View file

@ -272,10 +272,8 @@ function renderDirectPlayProfiles(page, profiles) {
if (profile.Type == 'Video') { if (profile.Type == 'Video') {
html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>'; html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>'; html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>';
} else { } else if (profile.Type == 'Audio') {
if (profile.Type == 'Audio') { html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
} }
html += '</a>'; html += '</a>';
@ -333,10 +331,8 @@ function renderTranscodingProfiles(page, profiles) {
if (profile.Type == 'Video') { if (profile.Type == 'Video') {
html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>'; html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>'; html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>';
} else { } else if (profile.Type == 'Audio') {
if (profile.Type == 'Audio') { html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
} }
html += '</a>'; html += '</a>';
@ -561,10 +557,8 @@ function renderResponseProfiles(page, profiles) {
if (profile.Type == 'Video') { if (profile.Type == 'Video') {
html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>'; html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>'; html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>';
} else { } else if (profile.Type == 'Audio') {
if (profile.Type == 'Audio') { html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
} }
if (profile.Conditions?.length) { if (profile.Conditions?.length) {

View file

@ -391,11 +391,9 @@ export default function (view) {
case 'left': case 'left':
if (currentVisibleMenu === 'osd') { if (currentVisibleMenu === 'osd') {
showOsd(); showOsd();
} else { } else if (!currentVisibleMenu) {
if (!currentVisibleMenu) { e.preventDefault();
e.preventDefault(); playbackManager.rewind(player);
playbackManager.rewind(player);
}
} }
break; break;

View file

@ -285,10 +285,8 @@ ItemsContainerPrototype.attachedCallback = function () {
if (browser.touch) { if (browser.touch) {
this.addEventListener('contextmenu', disableEvent); this.addEventListener('contextmenu', disableEvent);
} else { } else if (this.getAttribute('data-contextmenu') !== 'false') {
if (this.getAttribute('data-contextmenu') !== 'false') { this.addEventListener('contextmenu', onContextMenu);
this.addEventListener('contextmenu', onContextMenu);
}
} }
if (layoutManager.desktop || layoutManager.mobile && this.getAttribute('data-multiselect') !== 'false') { if (layoutManager.desktop || layoutManager.mobile && this.getAttribute('data-multiselect') !== 'false') {

View file

@ -227,10 +227,8 @@ async function onAppReady() {
document.body.appendChild(localStyle); document.body.appendChild(localStyle);
} }
localStyle.textContent = localCss; localStyle.textContent = localCss;
} else { } else if (localStyle) {
if (localStyle) { localStyle.textContent = '';
localStyle.textContent = '';
}
} }
}; };

View file

@ -130,17 +130,15 @@ class NavDrawer {
if (this.isPeeking) { if (this.isPeeking) {
this.onMenuTouchMove(e); this.onMenuTouchMove(e);
} else { } else if ((getTouches(e)[0]?.clientX || 0) <= options.handleSize) {
if ((getTouches(e)[0]?.clientX || 0) <= options.handleSize) { this.isPeeking = true;
this.isPeeking = true;
if (e.type === 'touchstart') { if (e.type === 'touchstart') {
dom.removeEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {}); dom.removeEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {});
dom.addEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {}); dom.addEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {});
}
this.onMenuTouchStart(e);
} }
this.onMenuTouchStart(e);
} }
}; };
@ -247,14 +245,10 @@ class NavDrawer {
} else { } else {
this.close(); this.close();
} }
} else { } else if (this.newPos >= 100) {
if (this.newPos >= 100) { this.open();
this.open(); } else if (this.newPos) {
} else { this.close();
if (this.newPos) {
this.close();
}
}
} }
} }
@ -321,19 +315,17 @@ class NavDrawer {
passive: true passive: true
}); });
} }
} else { } else if (this._edgeSwipeEnabled) {
if (this._edgeSwipeEnabled) { this._edgeSwipeEnabled = false;
this._edgeSwipeEnabled = false; dom.removeEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, {
dom.removeEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, { passive: true
passive: true });
}); dom.removeEventListener(this.edgeContainer, 'touchend', this.onEdgeTouchEnd, {
dom.removeEventListener(this.edgeContainer, 'touchend', this.onEdgeTouchEnd, { passive: true
passive: true });
}); dom.removeEventListener(this.edgeContainer, 'touchcancel', this.onEdgeTouchEnd, {
dom.removeEventListener(this.edgeContainer, 'touchcancel', this.onEdgeTouchEnd, { passive: true
passive: true });
});
}
} }
} }
} }

View file

@ -258,12 +258,10 @@ const scrollerFactory = function (frame, options) {
} else { } else {
container.scrollTo(0, Math.round(pos)); container.scrollTo(0, Math.round(pos));
} }
} else if (o.horizontal) {
container.scrollLeft = Math.round(pos);
} else { } else {
if (o.horizontal) { container.scrollTop = Math.round(pos);
container.scrollLeft = Math.round(pos);
} else {
container.scrollTop = Math.round(pos);
}
} }
} }
@ -507,14 +505,12 @@ const scrollerFactory = function (frame, options) {
// If the pointer was released, the path will not become longer and it's // If the pointer was released, the path will not become longer and it's
// definitely not a drag. If not released yet, decide on next iteration // definitely not a drag. If not released yet, decide on next iteration
return dragging.released ? dragEnd() : undefined; return dragging.released ? dragEnd() : undefined;
} else { } else if (o.horizontal ? Math.abs(dragging.pathX) > Math.abs(dragging.pathY) : Math.abs(dragging.pathX) < Math.abs(dragging.pathY)) {
// If dragging path is sufficiently long we can confidently start a drag // If dragging path is sufficiently long we can confidently start a drag
// if drag is in different direction than scroll, ignore it // if drag is in different direction than scroll, ignore it
if (o.horizontal ? Math.abs(dragging.pathX) > Math.abs(dragging.pathY) : Math.abs(dragging.pathX) < Math.abs(dragging.pathY)) { dragging.init = 1;
dragging.init = 1; } else {
} else { return dragEnd();
return dragEnd();
}
} }
} }

View file

@ -864,11 +864,9 @@ export class HtmlVideoPlayer {
if (Screenfull.isEnabled) { if (Screenfull.isEnabled) {
Screenfull.exit(); Screenfull.exit();
} else { } else if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
// iOS Safari // iOS Safari
if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { document.webkitCancelFullscreen();
document.webkitCancelFullscreen();
}
} }
} }
@ -1106,15 +1104,14 @@ export class HtmlVideoPlayer {
tryRemoveElement(this.#videoSecondarySubtitlesElem); tryRemoveElement(this.#videoSecondarySubtitlesElem);
this.#videoSecondarySubtitlesElem = null; this.#videoSecondarySubtitlesElem = null;
} }
} else { // destroy all } else if (this.#videoSubtitlesElem) {
if (this.#videoSubtitlesElem) { // destroy all
const subtitlesContainer = this.#videoSubtitlesElem.parentNode; const subtitlesContainer = this.#videoSubtitlesElem.parentNode;
if (subtitlesContainer) { if (subtitlesContainer) {
tryRemoveElement(subtitlesContainer); tryRemoveElement(subtitlesContainer);
}
this.#videoSubtitlesElem = null;
this.#videoSecondarySubtitlesElem = null;
} }
this.#videoSubtitlesElem = null;
this.#videoSecondarySubtitlesElem = null;
} }
} }
@ -1818,10 +1815,8 @@ export class HtmlVideoPlayer {
} else { } else {
Windows.UI.ViewManagement.ApplicationView.getForCurrentView().tryEnterViewModeAsync(Windows.UI.ViewManagement.ApplicationViewMode.default); Windows.UI.ViewManagement.ApplicationView.getForCurrentView().tryEnterViewModeAsync(Windows.UI.ViewManagement.ApplicationViewMode.default);
} }
} else { } else if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') {
if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') { video.webkitSetPresentationMode(isEnabled ? 'picture-in-picture' : 'inline');
video.webkitSetPresentationMode(isEnabled ? 'picture-in-picture' : 'inline');
}
} }
} }

View file

@ -352,10 +352,8 @@ class YoutubePlayer {
if (currentYoutubePlayer) { if (currentYoutubePlayer) {
currentYoutubePlayer.mute(); currentYoutubePlayer.mute();
} }
} else { } else if (currentYoutubePlayer) {
if (currentYoutubePlayer) { currentYoutubePlayer.unMute();
currentYoutubePlayer.unMute();
}
} }
} }
isMuted() { isMuted() {

View file

@ -835,26 +835,24 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {
bodyClassList.remove('dashboardDocument'); bodyClassList.remove('dashboardDocument');
bodyClassList.remove('hideMainDrawer'); bodyClassList.remove('hideMainDrawer');
if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(true);
}
} else if (isDashboardPage) {
bodyClassList.remove('libraryDocument');
bodyClassList.add('dashboardDocument');
bodyClassList.remove('hideMainDrawer');
if (navDrawerInstance) { if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(true); navDrawerInstance.setEdgeSwipeEnabled(true);
} }
} else { } else {
if (isDashboardPage) { bodyClassList.remove('libraryDocument');
bodyClassList.remove('libraryDocument'); bodyClassList.remove('dashboardDocument');
bodyClassList.add('dashboardDocument'); bodyClassList.add('hideMainDrawer');
bodyClassList.remove('hideMainDrawer');
if (navDrawerInstance) { if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(true); navDrawerInstance.setEdgeSwipeEnabled(false);
}
} else {
bodyClassList.remove('libraryDocument');
bodyClassList.remove('dashboardDocument');
bodyClassList.add('hideMainDrawer');
if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(false);
}
} }
} }
} }

View file

@ -54,12 +54,10 @@ export function toCenter(container, elem, horizontal, skipWhenVisible) {
} else { } else {
container.scrollTo(0, pos.center); container.scrollTo(0, pos.center);
} }
} else if (horizontal) {
container.scrollLeft = Math.round(pos.center);
} else { } else {
if (horizontal) { container.scrollTop = Math.round(pos.center);
container.scrollLeft = Math.round(pos.center);
} else {
container.scrollTop = Math.round(pos.center);
}
} }
} }
@ -76,12 +74,10 @@ export function toStart(container, elem, horizontal, skipWhenVisible) {
} else { } else {
container.scrollTo(0, pos.start); container.scrollTo(0, pos.start);
} }
} else if (horizontal) {
container.scrollLeft = Math.round(pos.start);
} else { } else {
if (horizontal) { container.scrollTop = Math.round(pos.start);
container.scrollLeft = Math.round(pos.start);
} else {
container.scrollTop = Math.round(pos.start);
}
} }
} }