-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
159 lines (154 loc) · 7.73 KB
/
index.d.ts
File metadata and controls
159 lines (154 loc) · 7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
declare module 'react-responsive-framer-motion-carousel' {
export interface CarouselRef {
/**
* - Use the paginate function from the `carousel` externally (paginate(1), paginate(-1))
*/
ref: React.Ref
}
export interface CarouselProps {
/**
* - The content or images to be displayed within the carousel.
*/
children: React.ReactNode;
/**
* - An optional number (default: `1000`) to set how far the children will animate in or out.
*/
range?: number;
/**
* - An optional CSS className for styling. You should style your outer div to stop overflow.
*/
className?: string;
/**
* - Optional display showing all indexes that can be clicked to navigate.
*/
navigation?: boolean;
/**
* - Type of carousel. Possible values: "horizontal", "vertical".
*/
type?: string;
/**
* - A boolean flag (defaults to `true`) that determines whether dragging/swiping functionality should be enabled.
*/
drag?: boolean;
/**
* - A boolean flag (defaults to `true`) that determines whether control buttons should be enabled.
*/
controls?: boolean;
/**
* - Optional counter configuration (array with two elements):
* - `Element 0 (boolean):` Controls visibility of the counter. Defaults to false.
* - true: Displays the counter.
* - false: Hides the counter.
* - `Element 1 (string, optional):` Custom string to display before the counter (if counter[0] is true). If omitted, no string is displayed.
*/
counter?: [boolean?, string?];
/**
* - A boolean flag (defaults to `false`) useful during issues. If set to `true`, it disables the exit animation, which may be helpful in rendering issues.
*/
noExit?: boolean;
/**
* - A optional number for decreasing or increasing the confidence that a user is swiping.
* - Higher values make swiping easier.
* - Lower values make swiping harder.
*/
swipeConfindence?: number;
/**
* - An optional array that configures automatic pagination using an interval.
* - `Element 0 (boolean)`: Specifies whether automatic pagination is enabled.
* - true: Enables automatic pagination.
* - false: Disables automatic pagination.
* - `Element 1 (number)`: Specifies the duration in seconds between automatic page transitions.
*/
interval?: [boolean, number];
/**
* - A boolean flag (defaults to `true`) that controls whether the configured interval (if any) should be actively used. This provides further control over automatic pagination behavior.
* - Example: To toggle automatic pagination based on hovering over a `<div>` element:
* ```jsx
* import React, { useState } from 'react';
* import Carousel from 'react-responsive-framer-motion-carousel';
*
* const MyComponent = () => {
* const [isHovered, setIsHovered] = useState(false);
*
* return (
* <div
* onMouseEnter={() => setIsHovered(true)}
* onMouseLeave={() => setIsHovered(false)}
* >
* <Carousel intervalActive={isHovered}>
* </Carousel>
* </div>
* );
* };
* ```
*/
intervalActive?: boolean;
/**
* - Optional number u can pass to set the Index of the `carousel`. Remember child 1 is index 0
*/
goToIndex?: number;
/**
* - Optional: Callback function that returns the child Index when sliding.
* - Example:
* ```jsx
* import Carousel from 'react-responsive-framer-motion-carousel';
* import { useState } from 'react';
*
* function MyComponent() {
* const [loading, setLoading] = useState(true);
*
* // Set loading to false when the image is loaded.
* const handleLoad = () => {
* setLoading(false);
* };
* const handleChange = () => {
* setLoading(true)
* };
*
* return (
* <>
* // Conditionally render loading if the content is being loaded
* {loading && 'Loading...'}
* <Carousel onChange={handleChange}>
* <img onLoad={handleLoad} src="" alt="" />
* <img onLoad={handleLoad} src="" alt="" />
* <img onLoad={handleLoad} src="" alt="" />
* </Carousel>
* </>
* );
* }
* ```
*/
onChange?: React.Dispatch<React.SetStateAction<boolean>>;
}
/**
* Carousel - A customizable carousel component for displaying images or content.
*
* This component allows users to navigate through a series of images or content using swiping gestures or navigation buttons. It provides various configuration options for a tailored user experience.
*
* @param {Object} props - Props for the carousel component.
* @param {React.ReactNode} props.children - The content or images to be displayed within the carousel.
* @param {number} [props.range=1000] - An optional number to set how far the children will animate in or out.
* @param {string} [props.className] - An optional CSS className for styling. You should style your outer div to stop overflow.
* @param {string} [pros.navigation] className = carousel-navigation : Clasname = carousel-navigation-button - Optional display showing all indexes that can be clicked to navigate.
* @param {string} [props.type="horizontal"] - Type of carousel. Possible values: "horizontal", "vertical".
* @param {boolean} [props.drag=true] - A boolean flag (defaults to `true`) that determines whether dragging/swiping functionality should be enabled.
* @param {boolean} [props.controls=true] - A boolean flag (defaults to `true`) that determines whether control buttons should be enabled.
*@param {Array} [props.counter] - Optional counter configuration (array with two elements).
- Element 0 (boolean): Controls visibility of the counter. Defaults to false.
true: Displays the counter.
false: Hides the counter.
- Element 1 (string, optional): Custom string to display before the counter (if counter[0] is true). If omitted, no string is displayed.
* @param {boolean} [props.noExit=false] - A boolean flag (defaults to `false`) useful during issues. If set to `true`, it disables the exit animation, which may be helpful in rendering issues with big components.
* @param {number} [props.swipeConfindence=1000] - A optional number for decreasing or increasing the confidence that a user is swiping
* @param {Array} [props.interval=[false, 0]] - An optional array that configures automatic pagination using an interval.
- The first element (`interval[0]`) is a boolean flag (defaults to `false`) that determines whether automatic pagination is enabled.
- The second element (`interval[1]`) is a number (defaults to `0`) that specifies the duration (in seconds) between automatic page transitions.
* @param {boolean} [props.intervalActive=true] - A boolean flag (defaults to `true`) that controls whether the configured interval (if any) should be actively used. This provides further control over automatic pagination behavior.
* @param {number} [props.goToIndex] - Optional number u can pass to set the Index of the `carousel`. Remember child 1 is index 0
* @param {} [props.onChange] - Callback that returns the index when sliding. Useful for knowing when u should display a loading state.
* @param {ref}[ref] - Use the paginate function from the `carousel` externally (paginate(1), paginate(-1))
* @returns {JSX.Element} The carousel component.
*/
export default function Carousel(props: CarouselProps, ref: CarouselRef): JSX.Element;
}