async swiper load

This commit is contained in:
Igor Lobanov 2023-11-13 16:46:23 +01:00
parent 0466eef16b
commit 8ac7b104a8
2 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import { For, onMount, Show } from 'solid-js'
import { Icon } from '../Icon'
import { register } from 'swiper/element/bundle'
import SwiperCore, { Manipulation, Navigation, Pagination } from 'swiper'
import { SwiperRef } from './swiper'
import { clsx } from 'clsx'
@ -15,7 +15,8 @@ type Props = {
export const ArticleCardSwiper = (props: Props) => {
const mainSwipeRef: { current: SwiperRef } = { current: null }
onMount(() => {
onMount(async () => {
const { register } = await import('swiper/element/bundle')
register()
SwiperCore.use([Pagination, Navigation, Manipulation])
})

View File

@ -3,7 +3,6 @@ import { MediaItem, UploadedFile } from '../../../pages/types'
import { Icon } from '../Icon'
import { Popover } from '../Popover'
import { useLocalize } from '../../../context/localize'
import { register } from 'swiper/element/bundle'
import { DropArea } from '../DropArea'
import { createFileUploader } from '@solid-primitives/upload'
import SwiperCore, { Manipulation, Navigation, Pagination } from 'swiper'
@ -135,7 +134,8 @@ export const ImageSwiper = (props: Props) => {
handleSlideDescriptionChange(slideIndex(), 'body', slideBody())
}
onMount(() => {
onMount(async () => {
const { register } = await import('swiper/element/bundle')
register()
SwiperCore.use([Pagination, Navigation, Manipulation])
})