Skip to content

Commit

Permalink
Added support for reverse autoplay.
Browse files Browse the repository at this point in the history
  • Loading branch information
EAGLERD\orip committed Dec 13, 2017
1 parent c8d63f9 commit d474e98
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ const Autoplay = {
delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
}
swiper.autoplay.timeout = Utils.nextTick(() => {
if (swiper.params.loop) {
if (swiper.params.autoplay.reverseDirection) {
if (swiper.params.loop) {
swiper.loopFix();
swiper.slidePrev(swiper.params.speed, true, true);
swiper.emit('autoplay');
} else if (!swiper.isBeginning) {
swiper.slidePrev(swiper.params.speed, true, true);
swiper.emit('autoplay');
} else if (!swiper.params.autoplay.stopOnLastSlide) {
swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
swiper.emit('autoplay');
} else {
swiper.autoplay.stop();
}
} else if (swiper.params.loop) {
swiper.loopFix();
swiper.slideNext(swiper.params.speed, true, true);
swiper.emit('autoplay');
Expand Down Expand Up @@ -77,6 +91,7 @@ export default {
delay: 3000,
disableOnInteraction: true,
stopOnLastSlide: false,
reverseDirection: false,
},
},
create() {
Expand Down

1 comment on commit d474e98

@DanielRuf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, oversaw that Swiper already reorders the slides.

But can you add this to the documentation? @orijel

Please sign in to comment.