index.js 860 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. function checkOverflow() {
  2. const swiper = this;
  3. const {
  4. isLocked: wasLocked,
  5. params
  6. } = swiper;
  7. const {
  8. slidesOffsetBefore
  9. } = params;
  10. if (slidesOffsetBefore) {
  11. const lastSlideIndex = swiper.slides.length - 1;
  12. const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] +
  13. slidesOffsetBefore * 2;
  14. swiper.isLocked = swiper.size > lastSlideRightEdge;
  15. } else {
  16. swiper.isLocked = swiper.snapGrid.length === 1;
  17. }
  18. if (params.allowSlideNext === true) {
  19. swiper.allowSlideNext = !swiper.isLocked;
  20. }
  21. if (params.allowSlidePrev === true) {
  22. swiper.allowSlidePrev = !swiper.isLocked;
  23. }
  24. if (wasLocked && wasLocked !== swiper.isLocked) {
  25. swiper.isEnd = false;
  26. }
  27. if (wasLocked !== swiper.isLocked) {
  28. swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
  29. }
  30. }
  31. export default {
  32. checkOverflow
  33. };