Merge pull request #3941 from thornbill/defer-swiper

Defer loading of swiper until used
This commit is contained in:
Bill Thornton 2022-09-22 10:30:46 -04:00 committed by GitHub
commit 3e269bf3f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 95 additions and 91 deletions

View File

@ -13,10 +13,6 @@ import './style.scss';
import 'material-design-icons-iconfont';
import '../../elements/emby-button/paper-icon-button-light';
import ServerConnections from '../ServerConnections';
//eslint-disable-next-line import/no-unresolved
import { Swiper } from 'swiper/bundle';
//eslint-disable-next-line import/no-unresolved
import 'swiper/css/bundle';
import screenfull from 'screenfull';
/**
@ -345,6 +341,11 @@ export default function (options) {
slides = currentOptions.items;
}
//eslint-disable-next-line import/no-unresolved
import('swiper/css/bundle');
// eslint-disable-next-line import/no-unresolved
import('swiper/bundle').then(({ Swiper }) => {
swiperInstance = new Swiper(dialog.querySelector('.slideshowSwiperContainer'), {
direction: 'horizontal',
// Loop is disabled due to the virtual slides option not supporting it.
@ -384,6 +385,7 @@ export default function (options) {
}
if (swiperInstance.autoplay?.running) onAutoplayStart();
});
}
/**

View File

@ -6,10 +6,6 @@ import keyboardnavigation from '../../scripts/keyboardNavigation';
import { appRouter } from '../../components/appRouter';
import ServerConnections from '../../components/ServerConnections';
import * as userSettings from '../../scripts/settings/userSettings';
//eslint-disable-next-line import/no-unresolved
import { Swiper } from 'swiper/bundle';
//eslint-disable-next-line import/no-unresolved
import 'swiper/css/bundle';
import './style.scss';
@ -292,7 +288,13 @@ export class ComicsPlayer {
const downloadUrl = apiClient.getItemDownloadUrl(item.Id);
this.archiveSource = new ArchiveSource(downloadUrl);
return this.archiveSource.load().then(() => {
//eslint-disable-next-line import/no-unresolved
import('swiper/css/bundle');
return this.archiveSource.load()
// eslint-disable-next-line import/no-unresolved
.then(() => import('swiper/bundle'))
.then(({ Swiper }) => {
loading.hide();
this.pageCount = this.archiveSource.urls.length;