Skip to content

Commit

Permalink
fix(carousel): flush the slides left when they don't fill the width (#…
Browse files Browse the repository at this point in the history
…323)

* fix(carousel): Flush the slides left when they don't fill the width (#323)

When there are too few slides to fill the row, with scrollPerPage, the slides were flushed right instead of left.
By bounding maxOffest to a minimum of 0, the slides are aligned on the left-hand-side

Fix #323

* style(play): Use capitals in tests for consistency
  • Loading branch information
AdminXVII authored and quinnlangille committed Dec 7, 2018
1 parent 727c190 commit 6138baa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions play/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ play("Carousel", module)
h, containerWidth, [h(Carousel, {}, generateSlideImages(h))]
)
)
.add("Too few per page", h => createContainer(
h, containerWidth, [h(Carousel, { props: { perPage: 10, scrollPerPage: false } }, generateSlideImages(h))]
)
)
.add("3 per page", h => createContainer(
h, containerWidth, [h(Carousel, { props: { perPage: 3 } }, generateSlideImages(h))]
)
Expand Down
5 changes: 3 additions & 2 deletions src/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,10 @@ export default {
* @return {Number}
*/
maxOffset() {
return (
return Math.max(
this.slideWidth * (this.slideCount - this.currentPerPage) -
this.spacePadding * this.spacePaddingMaxOffsetFactor
this.spacePadding * this.spacePaddingMaxOffsetFactor,
0
);
},
/**
Expand Down

0 comments on commit 6138baa

Please sign in to comment.