slideNext.js 826 B

1234567891011121314151617181920212223242526272829
  1. export default function slideNext(speed = this.params.speed, runCallbacks = true, internal) {
  2. const swiper = this;
  3. const {
  4. animating,
  5. enabled,
  6. params
  7. } = swiper;
  8. if (!enabled) return swiper;
  9. let perGroup = params.slidesPerGroup;
  10. if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
  11. perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
  12. }
  13. const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
  14. if (params.loop) {
  15. if (animating && params.loopPreventsSlide) return false;
  16. swiper.loopFix();
  17. }
  18. if (params.rewind && swiper.isEnd) {
  19. return swiper.slideTo(0, speed, runCallbacks, internal);
  20. }
  21. setTimeout(() => {
  22. swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal)
  23. }, 0)
  24. return true;
  25. }