- 1afterTransition(callback) {
- 2 const handler = () => {
- 3 callback();
- 4 this.$refs.carouselInner.removeEventListener('transitionend', handler);
- 5 };
- 6 this.$refs.carouselInner.addEventListener('transitionend', handler);
- 7},
- 8
- 9withoutTransition(fn) {
- 10 this.disableTransition();
- 11 fn();
- 12 this.$refs.carouselInner.offsetHeight; // Force reflow
- 13 setTimeout(() => this.enableTransition(), 50);
- 14},
- 15
- 16next() {
- 17 this.afterTransition(() => {
- 18 const maxIndex = this.originalSlides.length * 2;
- 19 if (this.currentSlide >= maxIndex) {
- 20 this.withoutTransition(() => {
- 21 this.currentSlide -= this.originalSlides.length;
- 22 });
- 23 }
- 24 });
- 25 this.currentSlide++;
- 26},
- 27
- 28prev() {
- 29 this.afterTransition(() => {
- 30 if (this.currentSlide < this.originalSlides.length) {
- 31 this.withoutTransition(() => {
- 32 this.currentSlide += this.originalSlides.length;
- 33 });
- 34 }
- 35 });
- 36 this.currentSlide--;
- 37},
Raw Paste