init-swiper.js 968 B

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