Skip to main content

Callbacks

Before/After Slide

Functions that are invoked when the progression methods (goBack()/goForward()) are called or when carousel changes its scroll position.

Details

Prop NameTypeDefault Value
beforeSlide(currentSlideIndex: number, endSlideIndex: number) => voidundefined
afterSlide(endSlideIndex: number) => voidundefined
  • beforeSlide - Runs a given function before scrolling when a progression method is called. It will also run right before the carousel registers that it has been scrolled on if manually scrolled.
  • afterSlide - Runs a given function after scrolling when a progression method is called or after manually scrolling.

Example

<Carousel beforeSlide={() => myCustomBeforeFunction()}>{/* Cards */}</Carousel>
<Carousel afterSlide={() => myCustomAfterFunction()}>{/* Cards */}</Carousel>