From 1dc5d62ccfb839a402e0f010b6025348ce553a34 Mon Sep 17 00:00:00 2001 From: Sped0n Date: Fri, 3 Nov 2023 16:04:41 +0800 Subject: [PATCH] fix(gallery.ts): fix swiper init bug --- assets/ts/mobile/gallery.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/ts/mobile/gallery.ts b/assets/ts/mobile/gallery.ts index 0696512..8deb762 100644 --- a/assets/ts/mobile/gallery.ts +++ b/assets/ts/mobile/gallery.ts @@ -115,13 +115,7 @@ export function initGallery(ijs: ImageJSON[]): void { mounted.addWatcher((o) => { if (!o) return scrollable.set(true) - swiper = new _Swiper(swiperNode, { spaceBetween: 20 }) - swiper.on('slideChange', ({ realIndex }) => { - setIndex(realIndex) - }) }) - // mounted - mounted.set(true) // dynamic import window.addEventListener( 'touchstart', @@ -137,6 +131,10 @@ export function initGallery(ijs: ImageJSON[]): void { loadSwiper() .then((s) => { _Swiper = s + swiper = new _Swiper(swiperNode, { spaceBetween: 20 }) + swiper.on('slideChange', ({ realIndex }) => { + setIndex(realIndex) + }) }) .catch((e) => { console.log(e) @@ -145,6 +143,8 @@ export function initGallery(ijs: ImageJSON[]): void { }, { once: true, passive: true } ) + // mounted + mounted.set(true) } /**