Created
March 6, 2020 13:26
-
-
Save Shekey/addb1b34ca26717b8919ce3e094b4949 to your computer and use it in GitHub Desktop.
swiper custom fraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swiperOptions = { | |
slidesPerView: 1, | |
centeredSlides: true, | |
spaceBetween: 40, | |
effect: 'fade', | |
pagination: { | |
el: '.swiper-pagination', | |
type: 'fraction', | |
formatFractionTotal: function formatFractionTotal(number) { | |
var formated = ('0' + number).slice(-2); | |
return formated; | |
}, | |
formatFractionCurrent: function formatFractionCurrent(number) { | |
var formated = ('0' + number).slice(-2); | |
return formated; | |
}, | |
renderFraction: function (currentClass, totalClass) { | |
return '<span class="' + currentClass + '"></span>' | |
+ '<span class="swiper-pagination-separator">/</span>' | |
+ '<span class="' + totalClass + '"></span>'; | |
} | |
}, | |
navigation: { | |
nextEl: '.swiper-button-next', | |
prevEl: '.swiper-button-prev' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment