grab-n-drag-infinite-carousel 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ /**
2
+ * TypeScript definitions for InfiniteScrollCarousel
3
+ *
4
+ * A standalone, dependency-free infinite scrolling carousel component with
5
+ * grab-and-drag interaction, momentum scrolling, and seamless looping.
6
+ */
7
+
8
+ /**
9
+ * Configuration options for InfiniteScrollCarousel
10
+ */
11
+ export interface InfiniteScrollCarouselOptions {
12
+ /**
13
+ * Scroll speed in pixels per second, clamped to minimum 0
14
+ * @default 50
15
+ */
16
+ speed?: number;
17
+
18
+ /**
19
+ * Scroll in reverse direction (right to left)
20
+ * @default false
21
+ */
22
+ reverseDirection?: boolean;
23
+
24
+ /**
25
+ * Pause scrolling on hover
26
+ * @default true
27
+ */
28
+ pauseOnHover?: boolean;
29
+
30
+ /**
31
+ * Recalculate on window resize
32
+ * @default true
33
+ */
34
+ responsive?: boolean;
35
+
36
+ /**
37
+ * Momentum decay factor, clamped to 0.1-0.99
38
+ * @default 0.95
39
+ */
40
+ momentumDecay?: number;
41
+
42
+ /**
43
+ * Max momentum speed in px/ms, clamped to 0.5-25
44
+ * @default 2.0
45
+ */
46
+ maxMomentumSpeed?: number;
47
+
48
+ /**
49
+ * Color of the fade gradient in hex, rgb, or rgba format
50
+ * @default '#ffffff'
51
+ */
52
+ fadeColor?: string;
53
+
54
+ /**
55
+ * Number of item copies for seamless loop
56
+ * @default 3
57
+ */
58
+ copies?: number;
59
+ }
60
+
61
+ /**
62
+ * InfiniteScrollCarousel class
63
+ *
64
+ * A standalone, dependency-free infinite scrolling carousel component with
65
+ * grab-and-drag interaction, momentum scrolling, and seamless looping.
66
+ */
67
+ declare class InfiniteScrollCarousel {
68
+ /**
69
+ * Creates an infinite scrolling carousel instance
70
+ *
71
+ * @param container - Container element or selector
72
+ * @param options - Configuration options
73
+ */
74
+ constructor(container: HTMLElement | string, options?: InfiniteScrollCarouselOptions);
75
+
76
+ /**
77
+ * Validate and clamp option values to valid ranges
78
+ */
79
+ validateOptions(): void;
80
+
81
+ /**
82
+ * Initialize the carousel
83
+ */
84
+ init(): void;
85
+
86
+ /**
87
+ * Perform initialization after DOM is ready
88
+ */
89
+ initialize(): void;
90
+
91
+ /**
92
+ * Convert color string to rgba format with opacity
93
+ * @param color - Color in hex, rgb, or rgba format
94
+ * @param opacity - Opacity value 0-1 (default: 0.3)
95
+ * @returns rgba color string
96
+ */
97
+ colorToRgba(color: string, opacity?: number): string;
98
+
99
+ /**
100
+ * Apply fade color to the wrapper element
101
+ */
102
+ applyFadeColor(): void;
103
+
104
+ /**
105
+ * Duplicate container children to create seamless infinite loop
106
+ */
107
+ duplicateItems(): void;
108
+
109
+ /**
110
+ * Calculate scroll distance for seamless looping
111
+ * @param callback - Callback to execute after calculation
112
+ */
113
+ calculateScrollDistance(callback?: () => void): void;
114
+
115
+ /**
116
+ * Set initial position based on scroll direction
117
+ */
118
+ setInitialPosition(): void;
119
+
120
+ /**
121
+ * Calculate drag boundaries for infinite dragging
122
+ */
123
+ calculateDragBoundaries(): void;
124
+
125
+ /**
126
+ * Setup event listeners for interaction
127
+ */
128
+ setupEventListeners(): void;
129
+
130
+ /**
131
+ * Start dragging interaction
132
+ * @param event - Mouse or touch event
133
+ */
134
+ startDragging(event: MouseEvent | TouchEvent): void;
135
+
136
+ /**
137
+ * Handle drag movement
138
+ * @param event - Mouse or touch event
139
+ */
140
+ handleDrag(event: MouseEvent | TouchEvent): void;
141
+
142
+ /**
143
+ * End dragging interaction
144
+ */
145
+ endDragging(): void;
146
+
147
+ /**
148
+ * Start momentum animation after drag
149
+ */
150
+ startMomentum(): void;
151
+
152
+ /**
153
+ * Animate momentum scrolling
154
+ */
155
+ animateMomentum(): void;
156
+
157
+ /**
158
+ * Snap to valid position after interaction
159
+ */
160
+ snapToValidPosition(): void;
161
+
162
+ /**
163
+ * Start automatic scrolling
164
+ */
165
+ startScrolling(): void;
166
+
167
+ /**
168
+ * Pause automatic scrolling
169
+ */
170
+ pause(): void;
171
+
172
+ /**
173
+ * Resume automatic scrolling
174
+ */
175
+ resume(): void;
176
+
177
+ /**
178
+ * Stop automatic scrolling
179
+ */
180
+ stop(): void;
181
+
182
+ /**
183
+ * Main animation loop
184
+ * @param timestamp - Animation frame timestamp
185
+ */
186
+ animate(timestamp?: number): void;
187
+
188
+ /**
189
+ * Cleanup method for proper resource management
190
+ */
191
+ destroy(): void;
192
+ }
193
+
194
+ export default InfiniteScrollCarousel;
195
+
196
+ // Global declaration for browser usage
197
+ declare global {
198
+ interface Window {
199
+ InfiniteScrollCarousel: typeof InfiniteScrollCarousel;
200
+ }
201
+ }