onResize.js 1006 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. export default function onResize() {
  2. const swiper = this;
  3. const {
  4. params,
  5. el
  6. } = swiper;
  7. if (el && el.offsetWidth === 0) return;
  8. if (params.breakpoints) {
  9. swiper.setBreakpoint();
  10. }
  11. const {
  12. allowSlideNext,
  13. allowSlidePrev,
  14. snapGrid
  15. } = swiper;
  16. swiper.allowSlideNext = true;
  17. swiper.allowSlidePrev = true;
  18. swiper.updateSize();
  19. swiper.updateSlides();
  20. swiper.updateSlidesClasses();
  21. if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
  22. swiper.slideTo(swiper.slides.length - 1, 0, false, true);
  23. } else {
  24. swiper.slideTo(swiper.activeIndex, 0, false, true);
  25. }
  26. if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
  27. swiper.autoplay.run();
  28. }
  29. swiper.allowSlidePrev = allowSlidePrev;
  30. swiper.allowSlideNext = allowSlideNext;
  31. if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
  32. swiper.checkOverflow();
  33. }
  34. }