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.
package/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/README.md ADDED
@@ -0,0 +1,493 @@
1
+ # Grab-n-Drag Infinite Scrolling Carousel
2
+
3
+ A lightweight, dependency-free infinite scrolling carousel component with grab-and-drag interaction, momentum scrolling, and seamless looping. Perfect for showcasing logos, skills, testimonials, or any horizontally scrollable content.
4
+
5
+ ## Features
6
+
7
+ - **Infinite Seamless Loop** - Automatically duplicates items for continuous scrolling with no visible jumps
8
+ - **Grab and Drag** - Interactive dragging with mouse and touch support
9
+ - **Momentum Scrolling** - Natural momentum physics after drag release
10
+ - **Responsive** - Automatically recalculates on window resize
11
+ - **Pause on Hover** - Optional pause when hovering over the carousel
12
+ - **Zero Dependencies** - Pure vanilla JavaScript, no jQuery or frameworks required
13
+ - **Lightweight** - Works in all modern browsers
14
+ - **HTML Accessible** - Maintains keyboard navigation and screen reader compatibility
15
+
16
+ ## Demo
17
+
18
+ ![Demo GIF of Infinite Scrolling Carousel](docs/demo.gif)
19
+ <!-- Replace the above with an actual GIF (e.g., demo/demo.gif) after creating a screen capture -->
20
+ View the interactive [demo page](https://www.ethanlegum.com/Open-Source-Grab-n-Drag-Infinite-Scroll-Carousel/) for live examples and usage.
21
+
22
+ ## Installation
23
+
24
+ ### npm (Recommended)
25
+
26
+ ```bash
27
+ npm install grab-n-drag-infinite-carousel
28
+ ```
29
+
30
+ Then import in your project:
31
+
32
+ ```javascript
33
+ // ES Modules
34
+ import InfiniteScrollCarousel from 'grab-n-drag-infinite-carousel';
35
+ import 'grab-n-drag-infinite-carousel/grab-n-drag-infinite-carousel.css';
36
+
37
+ // CommonJS
38
+ const InfiniteScrollCarousel = require('grab-n-drag-infinite-carousel');
39
+ require('grab-n-drag-infinite-carousel/grab-n-drag-infinite-carousel.css');
40
+ ```
41
+
42
+ ### CDN
43
+
44
+ ```html
45
+ <!-- CSS -->
46
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/grab-n-drag-infinite-carousel@latest/grab-n-drag-infinite-carousel.css">
47
+
48
+ <!-- JavaScript -->
49
+ <script src="https://cdn.jsdelivr.net/npm/grab-n-drag-infinite-carousel@latest/grab-n-drag-infinite-carousel.js"></script>
50
+ ```
51
+
52
+ ### Manual Download
53
+
54
+ Download the files directly from the repository:
55
+ - `grab-n-drag-infinite-carousel.js` (or `grab-n-drag-infinite-carousel.min.js` for production)
56
+ - `grab-n-drag-infinite-carousel.css` (or `grab-n-drag-infinite-carousel.min.css` for production)
57
+
58
+ ### TypeScript Support
59
+
60
+ TypeScript definitions are included! If you're using TypeScript, you'll get full type checking and IntelliSense support:
61
+
62
+ ```typescript
63
+ import InfiniteScrollCarousel, { InfiniteScrollCarouselOptions } from 'grab-n-drag-infinite-carousel';
64
+
65
+ const options: InfiniteScrollCarouselOptions = {
66
+ speed: 50,
67
+ pauseOnHover: true
68
+ };
69
+
70
+ const carousel = new InfiniteScrollCarousel('#myCarousel', options);
71
+ ```
72
+
73
+ ## Quickstart
74
+
75
+ ### 1. Include the Files
76
+
77
+ ```html
78
+ <!DOCTYPE html>
79
+ <html>
80
+ <head>
81
+ <link rel="stylesheet" href="grab-n-drag-infinite-carousel.css">
82
+ </head>
83
+ <body>
84
+ <!-- Your carousel markup -->
85
+
86
+ <script src="grab-n-drag-infinite-carousel.js"></script>
87
+ <script>
88
+ // Initialize carousel
89
+ </script>
90
+ </body>
91
+ </html>
92
+ ```
93
+
94
+ ### 2. Basic HTML Structure
95
+
96
+ ```html
97
+ <div class="infinite-scroll-wrapper">
98
+ <div class="infinite-scroll-container" id="myCarousel">
99
+ <div class="infinite-scroll-item">Item 1</div>
100
+ <div class="infinite-scroll-item">Item 2</div>
101
+ <div class="infinite-scroll-item">Item 3</div>
102
+ <!-- Add more items as needed -->
103
+ </div>
104
+ </div>
105
+ ```
106
+
107
+ ### 3. Initialize the Carousel
108
+
109
+ ```javascript
110
+ // Get the container element
111
+ const container = document.querySelector('#myCarousel');
112
+
113
+ // Create carousel instance
114
+ const carousel = new InfiniteScrollCarousel(container, {
115
+ speed: 50, // pixels per second
116
+ pauseOnHover: true, // pause on hover
117
+ momentumDecay: 0.95, // momentum decay factor
118
+ maxMomentumSpeed: 2.0 // max momentum speed
119
+ });
120
+ ```
121
+
122
+ That's it! The carousel will automatically start scrolling.
123
+
124
+ ## API Reference
125
+
126
+ ### Constructor
127
+
128
+ ```javascript
129
+ new InfiniteScrollCarousel(container, options)
130
+ ```
131
+
132
+ #### Parameters
133
+
134
+ - **container** (`HTMLElement` or `string`) - The container element or CSS selector. Must contain direct children that will be scrolled.
135
+ - **options** (`Object`, optional) - Configuration object
136
+
137
+
138
+ ### Options
139
+
140
+ | Option | Type | Default | Description |
141
+ |------|------|---------|-------------|
142
+ | `speed` | number | `50` | Auto-scroll speed (pixels/sec).<br>Set to `0` to disable. |
143
+ | `reverseDirection` | boolean | `false` | Scroll direction.<br>`false`: right → left<br>`true`: left → right |
144
+ | `pauseOnHover` | boolean | `true` | Pauses scrolling when the pointer enters the container. |
145
+ | `responsive` | boolean | `true` | Recalculate dimensions on window resize. |
146
+ | `momentumDecay` | number | `0.95` | Drag momentum decay factor.<br>Range: `0.5–0.99` |
147
+ | `maxMomentumSpeed` | number | `2.0` | Maximum momentum speed (px/ms).<br>Range: `0.5–25` |
148
+ | `fadeColor` | string | `#ffffff` | Edge fade color (`hex`, `rgb`, `rgba`).<br>Use `transparent` to disable. |
149
+ | `copies` | number | `3` | Number of duplicated item sets for seamless looping. |
150
+
151
+
152
+ ### Methods
153
+
154
+ #### `startScrolling()`
155
+ Start automatic scrolling (if stopped).
156
+
157
+ ```javascript
158
+ carousel.startScrolling();
159
+ ```
160
+
161
+ #### `stop()`
162
+ Stop automatic scrolling.
163
+
164
+ ```javascript
165
+ carousel.stop();
166
+ ```
167
+
168
+ #### `pause()`
169
+ Pause scrolling (resumed when interacted).
170
+
171
+ ```javascript
172
+ carousel.pause();
173
+ ```
174
+
175
+ #### `resume()`
176
+ Resume paused scrolling.
177
+
178
+ ```javascript
179
+ carousel.resume();
180
+ ```
181
+
182
+ #### `destroy()`
183
+ Clean up event listeners and reset the carousel. Call this when removing the carousel from an active page.
184
+
185
+ ```javascript
186
+ carousel.destroy();
187
+ ```
188
+
189
+ ## Examples
190
+
191
+ ### Example 1: Logo Carousel
192
+
193
+ ```html
194
+ <div class="infinite-scroll-wrapper">
195
+ <div class="infinite-scroll-container" id="logoCarousel">
196
+ <div class="infinite-scroll-item">
197
+ <img src="logo1.png" alt="Company 1">
198
+ </div>
199
+ <div class="infinite-scroll-item">
200
+ <img src="logo2.png" alt="Company 2">
201
+ </div>
202
+ <div class="infinite-scroll-item">
203
+ <img src="logo3.png" alt="Company 3">
204
+ </div>
205
+ </div>
206
+ </div>
207
+
208
+ <script>
209
+ const carousel = new InfiniteScrollCarousel('#logoCarousel', {
210
+ speed: 30
211
+ });
212
+ </script>
213
+ ```
214
+
215
+ ### Example 2: Skills Icons
216
+
217
+ ```html
218
+ <div class="infinite-scroll-wrapper">
219
+ <div class="infinite-scroll-container" id="skillsCarousel">
220
+ <div class="infinite-scroll-item">
221
+ <i class="fab fa-html5"></i>
222
+ <span>HTML</span>
223
+ </div>
224
+ <div class="infinite-scroll-item">
225
+ <i class="fab fa-css3"></i>
226
+ <span>CSS</span>
227
+ </div>
228
+ <div class="infinite-scroll-item">
229
+ <i class="fab fa-js"></i>
230
+ <span>JavaScript</span>
231
+ </div>
232
+ </div>
233
+ </div>
234
+
235
+ <script>
236
+ const carousel = new InfiniteScrollCarousel('#skillsCarousel', {
237
+ speed: 40,
238
+ pauseOnHover: true
239
+ });
240
+ </script>
241
+ ```
242
+
243
+ ### Example 3: Multiple Carousels
244
+
245
+ ```javascript
246
+ // Initialize multiple carousels with different settings
247
+ const carousel1 = new InfiniteScrollCarousel('#carousel1', {
248
+ speed: 50
249
+ });
250
+
251
+ const carousel2 = new InfiniteScrollCarousel('#carousel2', {
252
+ speed: 30,
253
+ pauseOnHover: false
254
+ });
255
+ ```
256
+
257
+ ### Example 4: Custom Styling
258
+
259
+ ```html
260
+ <style>
261
+ .my-carousel-wrapper {
262
+ max-width: 1200px;
263
+ margin: 0 auto;
264
+ }
265
+
266
+ .my-carousel-item {
267
+ padding: 20px;
268
+ margin-right: 30px;
269
+ background: #f0f0f0;
270
+ border-radius: 8px;
271
+ }
272
+ </style>
273
+
274
+ <div class="infinite-scroll-wrapper my-carousel-wrapper">
275
+ <div class="infinite-scroll-container" id="customCarousel">
276
+ <div class="infinite-scroll-item my-carousel-item">Card 1</div>
277
+ <div class="infinite-scroll-item my-carousel-item">Card 2</div>
278
+ <div class="infinite-scroll-item my-carousel-item">Card 3</div>
279
+ </div>
280
+ </div>
281
+ ```
282
+
283
+ ## Styling
284
+
285
+ ### Required Classes
286
+
287
+ - `.infinite-scroll-wrapper` - Outer wrapper (handles overflow)
288
+ - `.infinite-scroll-container` - Scrolling container
289
+ - `.infinite-scroll-item` - Individual items (direct children of container)
290
+
291
+ ### Customization
292
+
293
+ You can fully customize the look and feel of the carousel by adding your own CSS or extending the default classes.
294
+
295
+ **1. Item Spacing:**
296
+
297
+ Change the spacing between items (adjust margin or padding):
298
+
299
+ ```css
300
+ .infinite-scroll-item {
301
+ margin-right: 40px; /* Increase space between items */
302
+ }
303
+ ```
304
+
305
+ **2. Item Styling:**
306
+
307
+ Style individual items (such as background, border, typography):
308
+
309
+ ```css
310
+ .infinite-scroll-item {
311
+ background: #f8f8fc;
312
+ border-radius: 8px;
313
+ padding: 16px 24px;
314
+ box-shadow: 0 2px 8px rgba(0,0,0,0.03);
315
+ color: #222;
316
+ font-weight: 500;
317
+ }
318
+ ```
319
+
320
+ **3. Fade Gradient Colors:**
321
+
322
+ Override the fade color (defaults to white) on the wrapper edges, either via the API or by customizing CSS if needed. (Set `fadeColor` option in JS.)
323
+
324
+ **4. Carousel Height and Alignment:**
325
+
326
+ Adjust item alignment or carousel height to fit your content:
327
+
328
+ ```css
329
+ .infinite-scroll-container {
330
+ align-items: flex-start; /* or center, flex-end */
331
+ min-height: 50px;
332
+ }
333
+ ```
334
+
335
+ **5. Responsive Layouts:**
336
+
337
+ Make the carousel responsive by adjusting sizes and spacing at different breakpoints:
338
+
339
+ ```css
340
+ @media (max-width: 600px) {
341
+ .infinite-scroll-item {
342
+ margin-right: 16px;
343
+ padding: 10px 14px;
344
+ font-size: 0.95em;
345
+ }
346
+ }
347
+ ```
348
+
349
+ #### Advanced: Add Custom Classes
350
+
351
+ You can apply your own classes to the wrapper, container, or items for more specific targeting, e.g.
352
+
353
+ ```html
354
+ <div class="infinite-scroll-wrapper my-carousel-wrapper">
355
+ <div class="infinite-scroll-container" id="customCarousel">
356
+ <div class="infinite-scroll-item my-carousel-item">Custom 1</div>
357
+ <div class="infinite-scroll-item my-carousel-item">Custom 2</div>
358
+ <div class="infinite-scroll-item my-carousel-item">Custom 3</div>
359
+ </div>
360
+ </div>
361
+ ```
362
+
363
+ And then:
364
+
365
+ ```css
366
+ .my-carousel-wrapper {
367
+ max-width: 900px;
368
+ margin: 0 auto;
369
+ border: 1px solid #ddd;
370
+ background: #fafbfc;
371
+ }
372
+ .my-carousel-item {
373
+ padding: 24px;
374
+ margin-right: 32px;
375
+ font-size: 18px;
376
+ color: #225577;
377
+ }
378
+ ```
379
+
380
+ #### Tip
381
+
382
+ - You can use *any* content inside `.infinite-scroll-item`—icons, images, cards, links, etc.
383
+ - You can stack multiple carousels with different IDs and provide tailored styles for each. [See Demo 🠚](https://www.ethanlegum.com/Open-Source-Grab-n-Drag-Infinite-Scroll-Carousel/)
384
+
385
+ For more advanced interactivity, combine with your JS events or frameworks—just ensure you keep the core class structure for the carousel JavaScript to work.
386
+
387
+
388
+ ## Browser Compatibility
389
+
390
+ - Chrome/Edge: ✅ (latest)
391
+ - Firefox: ✅ (latest)
392
+ - Safari: ✅ (latest)
393
+ - iOS Safari: ✅ (latest)
394
+ - Android Chrome: ✅ (latest)
395
+
396
+ Requires support for:
397
+ - `requestAnimationFrame`
398
+ - `transform` CSS property
399
+ - `addEventListener`
400
+
401
+ ## Accessibility
402
+
403
+ - **Keyboard Navigation**: Items remain keyboard accessible
404
+ - **Screen Readers**: Content is readable by screen readers
405
+ - **Focus Management**: Focus states are preserved
406
+ - **Touch Support**: Full touch gesture support on mobile devices
407
+
408
+ ### Best Practices
409
+
410
+ 1. Ensure items have proper `alt` text for images
411
+ 2. Use semantic HTML for carousel items
412
+ 3. Provide alternative navigation for users who cannot use drag gestures
413
+ 4. Test with keyboard-only navigation
414
+
415
+ ## Performance
416
+
417
+ - Uses `requestAnimationFrame` for smooth 60fps animations
418
+ - Sub-pixel precision for smooth scrolling
419
+ - Efficient event handling with proper cleanup
420
+ - Minimal DOM manipulation
421
+ - Debounced resize calculations
422
+
423
+ ### Optimization Tips
424
+
425
+ 1. **Limit Item Count**: While the carousel handles many items, keep it reasonable (< 100 items)
426
+ 2. **Optimize Images**: Use optimized images for logo/item carousels
427
+ 3. **Use `will-change`**: Already included in the CSS for optimal performance
428
+ 4. **Avoid Heavy Animations**: Don't add heavy CSS animations to items
429
+
430
+ ## Common Pitfalls
431
+
432
+ ### Items Not Scrolling
433
+
434
+ **Problem**: Carousel doesn't scroll or items don't move.
435
+
436
+ **Solutions**:
437
+ - Ensure `.infinite-scroll-wrapper` has `overflow: hidden`
438
+ - Check that container has direct children
439
+ - Verify CSS file is loaded
440
+ - Check browser console for errors
441
+
442
+ ### Items Jumping or Glitching
443
+
444
+ **Problem**: Visible jumps or glitches during scrolling.
445
+
446
+ **Solutions**:
447
+ - Ensure items have consistent widths
448
+ - Don't modify item count after initialization
449
+ - Wait for images to load before initializing (if using images)
450
+
451
+ ### Drag Not Working
452
+
453
+ **Problem**: Can't drag the carousel.
454
+
455
+ **Solutions**:
456
+ - Ensure container has `cursor: grab` (included in CSS)
457
+ - Check for CSS that might be blocking pointer events
458
+ - Verify JavaScript file is loaded
459
+ - Check for JavaScript errors in console
460
+
461
+ ### Items Too Close Together
462
+
463
+ **Problem**: Items are overlapping or too close.
464
+
465
+ **Solution**: Add margin to items:
466
+ ```css
467
+ .infinite-scroll-item {
468
+ margin-right: 30px; /* Adjust as needed */
469
+ }
470
+ ```
471
+
472
+ ### Carousel Too Fast/Slow
473
+
474
+ **Problem**: Scrolling speed is not right.
475
+
476
+ **Solution**: Adjust the `speed` option:
477
+ ```javascript
478
+ const carousel = new InfiniteScrollCarousel(container, {
479
+ speed: 30 // Lower = slower, Higher = faster
480
+ });
481
+ ```
482
+
483
+ ## License
484
+
485
+ This project is licensed under CC0 1.0 Universal - see the [LICENSE](LICENSE) file for details.
486
+
487
+ ## Contributing
488
+
489
+ Contributions are welcome! Please feel free to submit a Pull Request.
490
+
491
+ ## Support
492
+
493
+ For issues, questions, or contributions, please open an issue on the repository.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * InfiniteScrollCarousel CSS
3
+ *
4
+ * Minimal styles required for the infinite scroll carousel component.
5
+ * These styles handle overflow, positioning, and fade gradients.
6
+ */
7
+
8
+ /* Wrapper: Handles overflow and fade gradients */
9
+ .infinite-scroll-wrapper {
10
+ position: relative;
11
+ overflow: hidden;
12
+ width: 100%;
13
+ }
14
+
15
+ /* Container: The scrolling element */
16
+ .infinite-scroll-container {
17
+ display: flex;
18
+ align-items: center;
19
+ white-space: nowrap;
20
+ position: relative;
21
+ cursor: grab;
22
+ will-change: transform;
23
+ }
24
+
25
+ /* Items: Direct children of the container */
26
+ .infinite-scroll-item {
27
+ flex-shrink: 0;
28
+ display: flex;
29
+ align-items: center;
30
+ }
31
+
32
+ /* Fade gradients on left and right edges */
33
+ .infinite-scroll-wrapper::before,
34
+ .infinite-scroll-wrapper::after {
35
+ content: "";
36
+ position: absolute;
37
+ top: 0;
38
+ width: 50px;
39
+ height: 100%;
40
+ pointer-events: none;
41
+ z-index: 1;
42
+ }
43
+
44
+ .infinite-scroll-wrapper::before {
45
+ left: 0;
46
+ background: linear-gradient(to right, rgba(0, 0, 0, 1), transparent);
47
+ }
48
+
49
+ .infinite-scroll-wrapper::after {
50
+ right: 0;
51
+ background: linear-gradient(to left, rgba(0, 0, 0, 1), transparent);
52
+ }
53
+
54
+ /* Customize fade gradient colors using CSS variables */
55
+ .infinite-scroll-wrapper[data-fade-color]::before {
56
+ background: var(--fade-gradient-left, linear-gradient(to right, rgba(0, 0, 0, 1), transparent));
57
+ }
58
+
59
+ .infinite-scroll-wrapper[data-fade-color]::after {
60
+ background: var(--fade-gradient-right, linear-gradient(to left, rgba(0, 0, 0, 1), transparent));
61
+ }
62
+
63
+ /* Cursor states */
64
+ .infinite-scroll-container:active {
65
+ cursor: grabbing;
66
+ }
67
+
68
+ /* Mobile optimizations */
69
+ @media (max-width: 768px) {
70
+ .infinite-scroll-wrapper {
71
+ overflow: hidden;
72
+ width: 100%;
73
+ }
74
+
75
+ .infinite-scroll-container {
76
+ /* Ensure container is wide enough for smooth scrolling */
77
+ min-width: 300%;
78
+ }
79
+
80
+ .infinite-scroll-item {
81
+ flex-shrink: 0;
82
+ }
83
+ }
84
+