From c60c5f721b67254d45b7ce0566a8b4bb24510bfd Mon Sep 17 00:00:00 2001 From: Slava Viktorov Date: Fri, 16 Jul 2021 10:58:10 +0300 Subject: [PATCH] Add a new modules property to the Svelte component. To solve the problem with installing additional Swiper models when used in SvelteKit. Fix #4767 --- src/svelte/init-swiper.js | 3 ++- src/svelte/swiper.svelte | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/svelte/init-swiper.js b/src/svelte/init-swiper.js index 2655cdaf6..9fd185d24 100644 --- a/src/svelte/init-swiper.js +++ b/src/svelte/init-swiper.js @@ -2,7 +2,8 @@ import Swiper from '../../core'; import { needsNavigation, needsPagination, needsScrollbar } from './utils'; -function initSwiper(swiperParams) { +function initSwiper(swiperParams, modules) { + if (modules) Swiper.use(modules); return new Swiper(swiperParams); } diff --git a/src/svelte/swiper.svelte b/src/svelte/swiper.svelte index fffeeda02..ddae76cea 100644 --- a/src/svelte/swiper.svelte +++ b/src/svelte/swiper.svelte @@ -17,6 +17,7 @@ let className = undefined; export { className as class }; + export let modules = null; let containerClasses = 'swiper-container'; let breakpointChanged = false; @@ -79,7 +80,7 @@ }, }); - swiperInstance = initSwiper(swiperParams); + swiperInstance = initSwiper(swiperParams, modules); if (swiperInstance.virtual && swiperInstance.params.virtual.enabled) { const extendWith = { cache: false,