UNPKG

4.75 kBTypeScriptView Raw
1import React from 'react';
2import Thumbs from './Thumbs';
3export interface Props {
4 axis: 'horizontal' | 'vertical';
5 autoFocus?: boolean;
6 autoPlay?: boolean;
7 centerMode?: boolean;
8 centerSlidePercentage: number;
9 children?: React.ReactChild[];
10 className?: string;
11 dynamicHeight?: boolean;
12 emulateTouch?: boolean;
13 infiniteLoop?: boolean;
14 interval: number;
15 labels: {
16 leftArrow: string;
17 rightArrow: string;
18 item: string;
19 };
20 onClickItem: (index: number, item: React.ReactNode) => void;
21 onClickThumb: (index: number, item: React.ReactNode) => void;
22 onChange: (index: number, item: React.ReactNode) => void;
23 onSwipeStart: (event: React.TouchEvent) => void;
24 onSwipeEnd: (event: React.TouchEvent) => void;
25 onSwipeMove: (event: React.TouchEvent) => boolean;
26 preventMovementUntilSwipeScrollTolerance: boolean;
27 renderArrowPrev: (clickHandler: () => void, hasPrev: boolean, label: string) => React.ReactNode;
28 renderArrowNext: (clickHandler: () => void, hasNext: boolean, label: string) => React.ReactNode;
29 renderIndicator: (clickHandler: (e: React.MouseEvent | React.KeyboardEvent) => void, isSelected: boolean, index: number, label: string) => React.ReactNode;
30 renderItem: (item: React.ReactNode, options?: {
31 isSelected: boolean;
32 }) => React.ReactNode;
33 renderThumbs: (children: React.ReactChild[]) => React.ReactChild[];
34 selectedItem: number;
35 showArrows: boolean;
36 showStatus: boolean;
37 showIndicators: boolean;
38 showThumbs: boolean;
39 statusFormatter: (currentItem: number, total: number) => string;
40 stopOnHover: boolean;
41 swipeable: boolean;
42 swipeScrollTolerance: number;
43 thumbWidth?: number;
44 transitionTime: number;
45 useKeyboardArrows?: boolean;
46 verticalSwipe: 'natural' | 'standard';
47 width: number | string;
48}
49interface State {
50 autoPlay?: boolean;
51 cancelClick: boolean;
52 hasMount: boolean;
53 initialized: boolean;
54 isMouseEntered: boolean;
55 itemSize: number;
56 selectedItem: number;
57 swiping?: boolean;
58 swipeMovementStarted: boolean;
59}
60export default class Carousel extends React.Component<Props, State> {
61 private thumbsRef?;
62 private carouselWrapperRef?;
63 private listRef?;
64 private itemsRef?;
65 private timer?;
66 static displayName: string;
67 static defaultProps: Props;
68 constructor(props: Props);
69 componentDidMount(): void;
70 componentDidUpdate(prevProps: Props, prevState: State): void;
71 componentWillUnmount(): void;
72 setThumbsRef: (node: Thumbs) => void;
73 setCarouselWrapperRef: (node: HTMLDivElement) => void;
74 setListRef: (node: HTMLElement | HTMLUListElement) => void;
75 setItemsRef: (node: HTMLElement, index: number) => void;
76 setupCarousel(): void;
77 destroyCarousel(): void;
78 setupAutoPlay(): void;
79 destroyAutoPlay(): void;
80 bindEvents(): void;
81 unbindEvents(): void;
82 autoPlay: () => void;
83 clearAutoPlay: () => void;
84 resetAutoPlay: () => void;
85 stopOnHover: () => void;
86 startOnLeave: () => void;
87 forceFocus(): void;
88 isFocusWithinTheCarousel: () => boolean;
89 navigateWithKeyboard: (e: KeyboardEvent) => void;
90 updateSizes: () => void;
91 setMountState: () => void;
92 handleClickItem: (index: number, item: React.ReactNode) => void;
93 handleOnChange: (index: number, item: React.ReactNode) => void;
94 handleClickThumb: (index: number, item: React.ReactNode) => void;
95 onSwipeStart: (event: React.TouchEvent) => void;
96 onSwipeEnd: (event: React.TouchEvent) => void;
97 onSwipeMove: (delta: {
98 x: number;
99 y: number;
100 }, event: React.TouchEvent) => boolean;
101 getPosition(index: number): number;
102 setPosition: (position: number, forceReflow?: boolean | undefined) => void;
103 resetPosition: () => void;
104 decrement: (positions?: number, fromSwipe?: boolean) => void;
105 increment: (positions?: number, fromSwipe?: boolean) => void;
106 moveTo: (position?: number | undefined, fromSwipe?: boolean | undefined) => void;
107 onClickNext: () => void;
108 onClickPrev: () => void;
109 onSwipeForward: () => void;
110 onSwipeBackwards: () => void;
111 changeItem: (newIndex: number) => (e: React.MouseEvent | React.KeyboardEvent) => void;
112 selectItem: (state: Pick<State, 'selectedItem' | 'swiping'>, cb?: (() => void) | undefined) => void;
113 getInitialImage: () => HTMLImageElement;
114 getVariableItemHeight: (position: number) => number | null;
115 renderItems(isClone?: boolean): JSX.Element[];
116 renderControls(): JSX.Element | null;
117 renderStatus(): JSX.Element | null;
118 renderThumbs(): JSX.Element | null;
119 render(): JSX.Element | null;
120}
121export {};
122//# sourceMappingURL=Carousel.d.ts.map
\No newline at end of file