Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dist/vue-carousel.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/themes/vue/source/js/vue-carousel.min.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions src/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -858,20 +858,20 @@ export default {
}

// & snap the new offset on a slide or page if scrollPerPage
const width = this.scrollPerPage
? this.slideWidth * this.currentPerPage
: this.slideWidth;

// lock offset to either the nearest page, or to the last slide
const lastFullPageOffset =
width * Math.floor(this.slideCount / (this.currentPerPage - 1));
const remainderOffset =
lastFullPageOffset +
this.slideWidth * (this.slideCount % this.currentPerPage);
if (this.offset > (lastFullPageOffset + remainderOffset) / 2) {
this.offset = remainderOffset;
} else {
this.offset = width * Math.round(this.offset / width);
if (this.scrollPerPage) {
const width = this.slideWidth * this.currentPerPage;

// lock offset to either the nearest page, or to the last slide
const lastFullPageOffset =
width * Math.floor(this.slideCount / (this.currentPerPage - 1));
const remainderOffset =
lastFullPageOffset +
this.slideWidth * (this.slideCount % this.currentPerPage);
if (this.offset > (lastFullPageOffset + remainderOffset) / 2) {
this.offset = remainderOffset;
} else {
this.offset = width * Math.round(this.offset / width);
}
}

// clamp the offset between 0 -> maxOffset
Expand Down