Skip to content

Commit

Permalink
Feat: #195 (#284)
Browse files Browse the repository at this point in the history
Feat: #184 (#283)

Feat: #184

Feat: #195

Revert "Feat: #195"

This reverts commit 961ce8b.

Feat: #195

v0.14.0
  • Loading branch information
BocchiTheCode authored and quinnlangille committed Oct 19, 2018
1 parent f1e6314 commit ca50172
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/public/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ <h3 id="autoplayHoverPause"><a href="#autoplayHoverPause" class="headerlink" tit
<li><strong>Type</strong>: <code>Boolean</code></li>
<li><strong>Default</strong>: <code>true</code></li>
</ul>
<h3 id="autoplayDirection"><a href="#autoplayDirection" class="headerlink" title="autoplayDirection"></a>autoplayDirection</h3><p>Set to "backward" to change the autoplay direction to right to left instead of the default left to right movement.</p>
<ul>
<li><strong>Type</strong>: <code>String</code></li>
<li><strong>Default</strong>: <code>forward</code></li>
</ul>
<h3 id="loop"><a href="#loop" class="headerlink" title="loop"></a>loop</h3><p>Flag to make the carousel loop (wrap) when it reaches either end.</p>
<ul>
<li><strong>Type</strong>: <code>Boolean</code></li>
Expand Down
20 changes: 19 additions & 1 deletion src/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,19 @@ export default {
this.goToPage(this.getNextPage(), "navigation");
}
},
goToLastSlide() {
// following code is to disable animation
this.dragging = true;
// clear dragging after refresh rate
setTimeout(() => {
this.dragging = false;
}, this.refreshRate);
this.$nextTick(() => {
this.goToPage(this.pageCount);
});
},
/**
* A mutation observer is used to detect changes to the containing node
* in order to keep the magnet container in sync with the height its reference node.
Expand Down Expand Up @@ -824,7 +837,12 @@ export default {
);
this.$emit("mounted");
},
// when autoplay direction is backward start from the last slide
if (this.autoplayDirection === "backward") {
this.goToLastSlide();
}
},
beforeDestroy() {
this.detachMutationObserver();
window.removeEventListener("resize", this.getBrowserWidth);
Expand Down
12 changes: 11 additions & 1 deletion src/mixins/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const autoplay = {
autoplayHoverPause: {
type: Boolean,
default: true
},
/**
* Autoplay direction. User can insert backward to make autoplay move from right to left
*/
autoplayDirection: {
type: String,
default: "forward"
}
},
data() {
Expand All @@ -42,14 +49,17 @@ const autoplay = {
startAutoplay() {
if (this.autoplay) {
this.autoplayInterval = setInterval(
this.advancePage,
this.autoplayAdvancePage,
this.autoplayTimeout
);
}
},
restartAutoplay() {
this.pauseAutoplay();
this.startAutoplay();
},
autoplayAdvancePage() {
this.advancePage(this.autoplayDirection);
}
},
mounted() {
Expand Down

0 comments on commit ca50172

Please sign in to comment.