Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onPageChanged callback #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Customized arrow button
- Customized dots
- Support SSR
- Add custom callback for page changement

## Install

Expand Down Expand Up @@ -82,6 +83,7 @@ const Gallery = () => {
| arrowRight | Element | | Customized left arrow button |
| [dot](#dot) | Element | | Customized dot component with prop `isActive` |
| containerStyle | Object | | Style object for carousel container |
| onPageChanged | Function | | Callback triggered for page changement |

### responsiveLayout

Expand Down
15 changes: 15 additions & 0 deletions examples/home/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ const App = () => {
</Carousel.Item>
))}
</Carousel>
<h4 className="thin">Single column with onPageChanged callback</h4>
<Carousel
showDots
containerStyle={{ maxWidth: '500px' }}
onPageChanged={currentPage => console.log(currentPage)}
>
{[...Array(4)].map((_, i) => (
<Carousel.Item key={i}>
<img
width="100%"
src={randomImgUrl.replace('{x}', 400).replace('{y}', 280) + i}
/>
</Carousel.Item>
))}
</Carousel>
<h4 className="thin">Multiple columns</h4>
<Carousel showDots cols={5}>
{[...Array(15)].map((_, i) => (
Expand Down
Loading