init-swiper.js 931 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Swiper from '../../index.js';
  2. import {
  3. needsNavigation,
  4. needsPagination,
  5. needsScrollbar
  6. } from './utils.js';
  7. function initSwiper(swiperParams, native) {
  8. return new Swiper(swiperParams, native);
  9. }
  10. function mountSwiper({
  11. el,
  12. nextEl,
  13. prevEl,
  14. paginationEl,
  15. scrollbarEl,
  16. swiper
  17. }, swiperParams) {
  18. if (needsNavigation(swiperParams) && nextEl && prevEl) {
  19. swiper.params.navigation.nextEl = nextEl;
  20. swiper.originalParams.navigation.nextEl = nextEl;
  21. swiper.params.navigation.prevEl = prevEl;
  22. swiper.originalParams.navigation.prevEl = prevEl;
  23. }
  24. if (needsPagination(swiperParams) && paginationEl) {
  25. swiper.params.pagination.el = paginationEl;
  26. swiper.originalParams.pagination.el = paginationEl;
  27. }
  28. if (needsScrollbar(swiperParams) && scrollbarEl) {
  29. swiper.params.scrollbar.el = scrollbarEl;
  30. swiper.originalParams.scrollbar.el = scrollbarEl;
  31. }
  32. swiper.init(el);
  33. }
  34. export {
  35. initSwiper,
  36. mountSwiper
  37. };