mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-21 13:39:30 -07:00
fix(gallery.ts): fix swiper init bug
This commit is contained in:
@@ -115,13 +115,7 @@ export function initGallery(ijs: ImageJSON[]): void {
|
|||||||
mounted.addWatcher((o) => {
|
mounted.addWatcher((o) => {
|
||||||
if (!o) return
|
if (!o) return
|
||||||
scrollable.set(true)
|
scrollable.set(true)
|
||||||
swiper = new _Swiper(swiperNode, { spaceBetween: 20 })
|
|
||||||
swiper.on('slideChange', ({ realIndex }) => {
|
|
||||||
setIndex(realIndex)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
// mounted
|
|
||||||
mounted.set(true)
|
|
||||||
// dynamic import
|
// dynamic import
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
'touchstart',
|
'touchstart',
|
||||||
@@ -137,6 +131,10 @@ export function initGallery(ijs: ImageJSON[]): void {
|
|||||||
loadSwiper()
|
loadSwiper()
|
||||||
.then((s) => {
|
.then((s) => {
|
||||||
_Swiper = s
|
_Swiper = s
|
||||||
|
swiper = new _Swiper(swiperNode, { spaceBetween: 20 })
|
||||||
|
swiper.on('slideChange', ({ realIndex }) => {
|
||||||
|
setIndex(realIndex)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -145,6 +143,8 @@ export function initGallery(ijs: ImageJSON[]): void {
|
|||||||
},
|
},
|
||||||
{ once: true, passive: true }
|
{ once: true, passive: true }
|
||||||
)
|
)
|
||||||
|
// mounted
|
||||||
|
mounted.set(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user