Skip to content

Commit

Permalink
feat(carousel): emit local event on pageChange (SSENSE#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamindedonder authored and toddlawton committed Mar 3, 2017
1 parent b83b496 commit dd3ca55
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions play/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,28 @@ play("Carousel", module)
h, containerWidth, [h('style', '.VueCarousel-navigation-button { font-size: 36px; }'), h(Carousel, { props: { paginationColor: '#fac232', paginationActiveColor: '#c9750c', navigationEnabled: true, navigationNextLabel: '👉', navigationPrevLabel: '👈' } }, generateSlideImages(h))]
)
)
.add("with local event on pageChange", {
template:
`<div style="width: 100%; display: flex; justify-content: center; margin-top: 40px;">
<carousel style="width: 500px;" @pageChange="onPageChange">
<slide v-for="slide in slides">
<img style="width: 100%;" :src="slide" />
</slide>
</carousel>
</div>`,
components: {
Carousel,
Slide
},
data() {
return {
slides: images
}
},
methods: {
onPageChange(currentPage) {
this.$log(`page changed to ${currentPage}`)
},
}
})

1 change: 1 addition & 0 deletions src/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
goToPage(page) {
if ((page >= 0) && (page <= this.pageCount)) {
this.currentPage = page
this.$emit('pageChange', this.currentPage)
}
},
/**
Expand Down

0 comments on commit dd3ca55

Please sign in to comment.