|
| 1 | +import React from "react"; |
| 2 | + |
| 3 | +type RenderArrowProps = { |
| 4 | + type: "PREV" | "NEXT"; |
| 5 | + onClick: () => void; |
| 6 | +}; |
| 7 | + |
| 8 | +type RenderPaginationProps = { |
| 9 | + pages: number; |
| 10 | + activatePage: number; |
| 11 | + // The onClick event that sets the state of the carousel and sends |
| 12 | + // it to a specific page. |
| 13 | + onClick: (indicatorId: string) => void; |
| 14 | +}; |
| 15 | + |
| 16 | +type ItemObject = { |
| 17 | + // Children's props |
| 18 | + object: any; |
| 19 | + index: number; |
| 20 | +}; |
| 21 | + |
| 22 | +type Breakpoint = { |
| 23 | + itemsToScroll: number; |
| 24 | + itemsToShow: number; |
| 25 | +}; |
| 26 | + |
| 27 | +export interface ReactElasticCarouselProps { |
| 28 | + className?: string; |
| 29 | + itemsToShow?: number; |
| 30 | + // Defaults to false |
| 31 | + verticalMode?: boolean; |
| 32 | + // Defaults to true |
| 33 | + pagination?: boolean; |
| 34 | + // Defaults to 500 |
| 35 | + transitionMs?: number; |
| 36 | + // Defaults to "ease" |
| 37 | + easing?: string; |
| 38 | + // Defaults to "ease" |
| 39 | + tiltEasing?: string; |
| 40 | + // Defaults to true. |
| 41 | + enableTilt?: boolean; |
| 42 | + // Defaults to 1 |
| 43 | + itemsToScroll?: number; |
| 44 | + breakpoints?: { |
| 45 | + width: number; |
| 46 | + itemsToShow: number; |
| 47 | + itemsToScroll: number; |
| 48 | + }[]; |
| 49 | + // Defaults to 0 |
| 50 | + initialFirstItem?: number; |
| 51 | + // Defaults to true |
| 52 | + showArrows?: boolean; |
| 53 | + // Defaults to true |
| 54 | + disableArrosOnEnd?: boolean; |
| 55 | + // Defaults to boolean |
| 56 | + focusOnSelect?: boolean; |
| 57 | + // Function to generate your own navigation arrows. |
| 58 | + renderArrow?: (props: RenderArrowProps) => void; |
| 59 | + // Function to generate your own pagination component. |
| 60 | + renderPagination?: (props: RenderPaginationProps) => JSX.Element; |
| 61 | + // Defaults to "CENTER" |
| 62 | + itemPosition?: "START" | "CENTER" | "END"; |
| 63 | + // A padding for each element - Defaults to [0,0,0,0] |
| 64 | + itemPadding: number[]; |
| 65 | + // Enable or disable swipe - Defaults to true |
| 66 | + enableSwipe?: boolean; |
| 67 | + /** Enable or disable mouse swipe */ |
| 68 | + enableMouseSwipe?: boolean; |
| 69 | + /** Prevent page scroll on touchmove. |
| 70 | + * Use this to stop the browser from scrolling while a user swipes. |
| 71 | + * More details: https://github.com/FormidableLabs/react-swipeable#preventdefaulttouchmoveevent-details |
| 72 | + */ |
| 73 | + preventDefaultTouchmoveEvent?: boolean; |
| 74 | + // Enable or disable auto play - Defaults to true |
| 75 | + enableAutoPlay?: boolean; |
| 76 | + /** Set auto play speed (ms) - Defaults to 2000 */ |
| 77 | + autoPlaySpeed?: number; |
| 78 | + onChange?: (currentItemObject: ItemObject, currentPageIndex: number) => void; |
| 79 | + // A callback for the beginning of the next transition |
| 80 | + onNextStart?: ( |
| 81 | + prevItemObject: ItemObject, |
| 82 | + nextItemObject: ItemObject |
| 83 | + ) => void; |
| 84 | + // A callback for the beginning of the prev transition |
| 85 | + onPrevStart?: ( |
| 86 | + prevItemObject: ItemObject, |
| 87 | + nextItemObject: ItemObject |
| 88 | + ) => void; |
| 89 | + // A callback for the end of the next transition |
| 90 | + onNextEnd?: (nextItemObject: ItemObject, currentPageIndex: number) => void; |
| 91 | + // A callback for the end of the prev transition |
| 92 | + onPrevEnd?: (nextItemObject: ItemObject, currentPageIndex: number) => void; |
| 93 | + // A callback for the "slider-container" resize |
| 94 | + onResize?: (currentBreakpoint: Breakpoint) => void; |
| 95 | +} |
| 96 | + |
| 97 | +declare class ReactElasticCarousel extends React.Component< |
| 98 | + ReactElasticCarouselProps |
| 99 | +> {} |
| 100 | + |
| 101 | +export default ReactElasticCarousel; |
0 commit comments