Created
July 3, 2018 09:03
-
-
Save radislaw/9aef927842411a27aa2767aa6cc9ab83 to your computer and use it in GitHub Desktop.
hide buttons in first and last slide in swiper
This file contains hidden or 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
| let productShowcase = this.initSwiper('.product-showcase', { | |
| slidesPerView: 3, | |
| onInit(e) { | |
| if(e.isBeginning) { | |
| e.prevButton[0].style.display = 'none' | |
| } | |
| }, | |
| }) | |
| productShowcase.forEach((item) => { | |
| // hide buttons in first and last slide | |
| item.on('progress', ((e) => { | |
| if(e.isBeginning) { | |
| e.prevButton[0].style.display = 'none' | |
| } else if(e.isEnd) { | |
| e.nextButton[0].style.display = 'none' | |
| } else { | |
| e.prevButton[0].style.display = 'block' | |
| e.nextButton[0].style.display = 'block' | |
| } | |
| })) | |
| // remove arrows and destroy slider when num of slides per view <= num of total slides | |
| if(item.slides) { | |
| if(item.slides.length < numOfSlides) { | |
| item.destroy(false) | |
| item.nextButton[0].parentNode.removeChild(item.nextButton[0]) | |
| item.prevButton[0].parentNode.removeChild(item.prevButton[0]) | |
| } | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment