@evermade/overflow-slider 3.3.1 → 4.1.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.
Files changed (119) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +158 -33
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.esm.js +645 -1
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/index.min.js +2 -1
  7. package/dist/index.min.js.map +1 -0
  8. package/dist/mixins.scss +14 -0
  9. package/dist/overflow-slider.css +1 -1
  10. package/dist/plugins/arrows/index.d.ts +26 -0
  11. package/dist/plugins/arrows/index.min.js +1 -1
  12. package/dist/plugins/autoplay/index.d.ts +41 -0
  13. package/dist/plugins/autoplay/index.esm.js +233 -0
  14. package/dist/plugins/autoplay/index.min.js +1 -0
  15. package/dist/plugins/classnames/index.d.ts +14 -0
  16. package/dist/plugins/classnames/index.esm.js +108 -0
  17. package/dist/plugins/classnames/index.min.js +1 -0
  18. package/dist/plugins/core/index.d.ts +76 -0
  19. package/dist/plugins/core/index.d2.ts +23 -0
  20. package/dist/plugins/dots/index.d.ts +16 -0
  21. package/dist/plugins/dots/index.min.js +1 -1
  22. package/dist/plugins/drag-scrolling/index.d.ts +9 -0
  23. package/dist/plugins/drag-scrolling/index.esm.js +2 -2
  24. package/dist/plugins/drag-scrolling/index.min.js +1 -1
  25. package/dist/plugins/fade/index.d.ts +16 -0
  26. package/dist/plugins/fade/index.min.js +1 -1
  27. package/dist/plugins/full-width/index.d.ts +11 -0
  28. package/dist/plugins/full-width/index.esm.js +37 -9
  29. package/dist/plugins/full-width/index.min.js +1 -1
  30. package/dist/plugins/infinite-scroll/index.d.ts +25 -0
  31. package/dist/plugins/infinite-scroll/index.esm.js +75 -0
  32. package/dist/plugins/infinite-scroll/index.min.js +1 -0
  33. package/dist/plugins/scroll-indicator/index.d.ts +14 -0
  34. package/dist/plugins/scroll-indicator/index.esm.js +3 -1
  35. package/dist/plugins/scroll-indicator/index.min.js +1 -1
  36. package/dist/plugins/skip-links/index.d.ts +17 -0
  37. package/dist/plugins/skip-links/index.esm.js +7 -1
  38. package/dist/plugins/skip-links/index.min.js +1 -1
  39. package/dist/plugins/thumbnails/index.d.ts +9 -0
  40. package/dist/plugins/thumbnails/index.min.js +1 -1
  41. package/dist/{core/utils.min.js → utils-Sxwcz8zp.js} +1 -1
  42. package/dist/{core/utils.esm.js → utils-ayDxlweP.js} +1 -1
  43. package/docs/assets/demo.css +156 -0
  44. package/docs/assets/demo.js +92 -8
  45. package/docs/dist/index.d.ts +1 -0
  46. package/docs/dist/index.esm.js +645 -1
  47. package/docs/dist/index.esm.js.map +1 -0
  48. package/docs/dist/index.min.js +2 -1
  49. package/docs/dist/index.min.js.map +1 -0
  50. package/docs/dist/mixins.scss +14 -0
  51. package/docs/dist/overflow-slider.css +1 -1
  52. package/docs/dist/plugins/arrows/index.d.ts +26 -0
  53. package/docs/dist/plugins/arrows/index.min.js +1 -1
  54. package/docs/dist/plugins/autoplay/index.d.ts +41 -0
  55. package/docs/dist/plugins/autoplay/index.esm.js +233 -0
  56. package/docs/dist/plugins/autoplay/index.min.js +1 -0
  57. package/docs/dist/plugins/classnames/index.d.ts +14 -0
  58. package/docs/dist/plugins/classnames/index.esm.js +108 -0
  59. package/docs/dist/plugins/classnames/index.min.js +1 -0
  60. package/docs/dist/plugins/core/index.d.ts +76 -0
  61. package/docs/dist/plugins/core/index.d2.ts +23 -0
  62. package/docs/dist/plugins/dots/index.d.ts +16 -0
  63. package/docs/dist/plugins/dots/index.min.js +1 -1
  64. package/docs/dist/plugins/drag-scrolling/index.d.ts +9 -0
  65. package/docs/dist/plugins/drag-scrolling/index.esm.js +2 -2
  66. package/docs/dist/plugins/drag-scrolling/index.min.js +1 -1
  67. package/docs/dist/plugins/fade/index.d.ts +16 -0
  68. package/docs/dist/plugins/fade/index.min.js +1 -1
  69. package/docs/dist/plugins/full-width/index.d.ts +11 -0
  70. package/docs/dist/plugins/full-width/index.esm.js +37 -9
  71. package/docs/dist/plugins/full-width/index.min.js +1 -1
  72. package/docs/dist/plugins/infinite-scroll/index.d.ts +25 -0
  73. package/docs/dist/plugins/infinite-scroll/index.esm.js +75 -0
  74. package/docs/dist/plugins/infinite-scroll/index.min.js +1 -0
  75. package/docs/dist/plugins/scroll-indicator/index.d.ts +14 -0
  76. package/docs/dist/plugins/scroll-indicator/index.esm.js +3 -1
  77. package/docs/dist/plugins/scroll-indicator/index.min.js +1 -1
  78. package/docs/dist/plugins/skip-links/index.d.ts +17 -0
  79. package/docs/dist/plugins/skip-links/index.esm.js +7 -1
  80. package/docs/dist/plugins/skip-links/index.min.js +1 -1
  81. package/docs/dist/plugins/thumbnails/index.d.ts +9 -0
  82. package/docs/dist/plugins/thumbnails/index.min.js +1 -1
  83. package/docs/dist/{core/utils.min.js → utils-Sxwcz8zp.js} +1 -1
  84. package/docs/dist/{core/utils.esm.js → utils-ayDxlweP.js} +1 -1
  85. package/docs/index-rtl.html +78 -2
  86. package/docs/index.html +86 -1
  87. package/package.json +50 -27
  88. package/rollup.config.js +90 -66
  89. package/src/core/details.ts +4 -0
  90. package/src/core/overflow-slider.ts +4 -2
  91. package/src/core/slider.ts +127 -62
  92. package/src/core/types.ts +30 -1
  93. package/src/mixins.scss +14 -0
  94. package/src/overflow-slider.scss +12 -10
  95. package/src/plugins/arrows/index.ts +2 -2
  96. package/src/plugins/autoplay/index.ts +276 -0
  97. package/src/plugins/autoplay/styles.scss +11 -0
  98. package/src/plugins/classnames/index.ts +147 -0
  99. package/src/plugins/dots/index.ts +2 -2
  100. package/src/plugins/drag-scrolling/index.ts +4 -4
  101. package/src/plugins/fade/index.ts +2 -2
  102. package/src/plugins/full-width/index.ts +43 -11
  103. package/src/plugins/scroll-indicator/index.ts +5 -3
  104. package/src/plugins/skip-links/index.ts +2 -2
  105. package/src/plugins/thumbnails/index.ts +2 -2
  106. package/tsconfig.json +4 -2
  107. package/changelog.md +0 -5
  108. package/dist/core/details.esm.js +0 -35
  109. package/dist/core/details.min.js +0 -1
  110. package/dist/core/overflow-slider.esm.js +0 -29
  111. package/dist/core/overflow-slider.min.js +0 -1
  112. package/dist/core/slider.esm.js +0 -499
  113. package/dist/core/slider.min.js +0 -1
  114. package/docs/dist/core/details.esm.js +0 -35
  115. package/docs/dist/core/details.min.js +0 -1
  116. package/docs/dist/core/overflow-slider.esm.js +0 -29
  117. package/docs/dist/core/overflow-slider.min.js +0 -1
  118. package/docs/dist/core/slider.esm.js +0 -499
  119. package/docs/dist/core/slider.min.js +0 -1
@@ -0,0 +1,9 @@
1
+ import { DeepPartial, Slider } from '../core/index.js';
2
+
3
+ type ThumbnailsOptions = {
4
+ mainSlider: Slider;
5
+ };
6
+ declare function FullWidthPlugin(args: DeepPartial<ThumbnailsOptions>): (slider: Slider) => void;
7
+
8
+ export { FullWidthPlugin as default };
9
+ export type { ThumbnailsOptions };
@@ -1 +1 @@
1
- function e(e){return i=>{const t={mainSlider:e.mainSlider}.mainSlider,l=(e=null)=>{null===e&&i.slides.length>0&&(e=i.slides[0]),null!==e&&(i.slides.forEach((e=>{e.setAttribute("aria-current","false")})),e.setAttribute("aria-current","true"))};l(),i.slides.forEach(((e,i)=>{e.addEventListener("click",(()=>{t.moveToSlide(i),l(e)}))})),t.on("scrollEnd",(()=>{setTimeout((()=>{const e=t.activeSlideIdx;if(i.activeSlideIdx===e)return;const r=i.slides[e];l(r),i.moveToSlide(e)}),50)}))}}export{e as default};
1
+ function e(e){return i=>{const t={mainSlider:e.mainSlider}.mainSlider,l=(e=null)=>{null===e&&i.slides.length>0&&(e=i.slides[0]),null!==e&&(i.slides.forEach(e=>{e.setAttribute("aria-current","false")}),e.setAttribute("aria-current","true"))};l(),i.slides.forEach((e,i)=>{e.addEventListener("click",()=>{t.moveToSlide(i),l(e)})}),t.on("scrollEnd",()=>{setTimeout(()=>{const e=t.activeSlideIdx;if(i.activeSlideIdx===e)return;const r=i.slides[e];l(r),i.moveToSlide(e)},50)})}}export{e as default};
@@ -1 +1 @@
1
- function t(e,n=1){const r=`${e}-${n}`;return document.getElementById(r)?t(e,n+1):r}function e(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1;return!0}function n(t){if(0===t.children.length)return 0;const e=t.children[0],n=getComputedStyle(e),r=parseFloat(n.marginLeft),o=t.children[t.children.length-1],l=getComputedStyle(o);return r+parseFloat(l.marginRight)}export{t as generateId,n as getOutermostChildrenEdgeMarginSum,e as objectsAreEqual};
1
+ function t(e,n=1){const r=`${e}-${n}`;return document.getElementById(r)?t(e,n+1):r}function e(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1;return!0}function n(t){if(0===t.children.length)return 0;const e=t.children[0],n=getComputedStyle(e),r=parseFloat(n.marginLeft),o=t.children[t.children.length-1],l=getComputedStyle(o);return r+parseFloat(l.marginRight)}export{n as a,t as g,e as o};
@@ -34,4 +34,4 @@ function getOutermostChildrenEdgeMarginSum(el) {
34
34
  return firstChildMarginLeft + lastChildMarginRight;
35
35
  }
36
36
 
37
- export { generateId, getOutermostChildrenEdgeMarginSum, objectsAreEqual };
37
+ export { getOutermostChildrenEdgeMarginSum as a, generateId as g, objectsAreEqual as o };
@@ -370,6 +370,77 @@ h3:before {
370
370
  gap: 1rem;
371
371
  }
372
372
 
373
+ .overflow-slider__autoplay {
374
+ --autoplay-bg-color: #e5e5e5;
375
+ --autoplay-progress-color: #303030;
376
+ --autoplay-icon-color: #303030;
377
+ cursor: pointer;
378
+ border-radius: 50%;
379
+ position: relative;
380
+ display: inline-flex;
381
+ align-items: center;
382
+ justify-content: center;
383
+ width: 2.5rem;
384
+ height: 2.5rem;
385
+ border: none;
386
+ background: var(--autoplay-bg-color);
387
+ color: var(--autoplay-icon-color);
388
+ /* ensure the pseudo-element paints on its own layer */
389
+ will-change: background;
390
+ }
391
+
392
+ .overflow-slider__autoplay::before {
393
+ content: "";
394
+
395
+ position: absolute;
396
+ inset: 0;
397
+ border-radius: 50%;
398
+ /* draw the circular progress using conic-gradient */
399
+ background:
400
+ conic-gradient(
401
+ var(--autoplay-progress-color) calc(var(--autoplay-delay-progress) * 1%),
402
+ transparent 0
403
+ );
404
+ /* rotate so “0%” starts at top */
405
+ transform: rotate(-90deg);
406
+ }
407
+
408
+ .overflow-slider__autoplay::after {
409
+ content: "";
410
+ position: absolute;
411
+ border-radius: 50%;
412
+ left: 10%;
413
+ width: 80%;
414
+ height: 80%;
415
+ top: 10%;
416
+ background: var(--autoplay-bg-color);
417
+ }
418
+
419
+ .overflow-slider__autoplay:hover,
420
+ .overflow-slider__autoplay:focus {
421
+ background: var(--color-primary);
422
+ }
423
+
424
+ .overflow-slider__autoplay:hover::before,
425
+ .overflow-slider__autoplay:focus::before {
426
+ background: transparent;
427
+ }
428
+
429
+ .overflow-slider__autoplay:hover::after,
430
+ .overflow-slider__autoplay:focus::after {
431
+ background: transparent;
432
+ }
433
+
434
+ .overflow-slider__autoplay svg {
435
+ position: absolute;
436
+ z-index: 2;
437
+ width: 1.25rem;
438
+ height: 1.25rem;
439
+ left: 50%;
440
+ top: 50%;
441
+ transform: translate(-50%, -50%);
442
+ }
443
+
373
444
  .example-item {
374
445
  aspect-ratio: 3/4;
375
446
  width: 240px;
@@ -451,11 +522,21 @@ h3:before {
451
522
  grid-template-columns: repeat(var(--slider-slides-count, 1), var(--slider-container-width, 900px));
452
523
  }
453
524
 
525
+ .example-container-1-autoplay-wrap-view,
526
+ .example-container-1-autoplay-wrap-slide {
527
+ margin-top: 16px;
528
+ }
529
+
454
530
  .example-container-1-dots .example-item {
455
531
  aspect-ratio: 16/7;
456
532
  width: 100%;
457
533
  }
458
534
 
535
+ .example-container-1-infinite > * {
536
+ width: var(--slider-container-width, 400px);
537
+ aspect-ratio: 16/8;
538
+ }
539
+
459
540
  .example-container-1-fade-wrap {
460
541
  position: relative;
461
542
  }
@@ -544,6 +625,46 @@ h3:before {
544
625
  height: 1.625rem !important;
545
626
  }
546
627
 
628
+ .example-container-1-classname-opacity .example-item {
629
+ transition: .5s ease-in-out;
630
+ }
631
+
632
+ .example-container-1-classname-opacity .is-visible {
633
+ opacity: 1;
634
+ }
635
+ .example-container-1-classname-opacity .is-hidden {
636
+ opacity: 0;
637
+ }
638
+
639
+ .example-container-1-classname-partly {
640
+ width: 100vw;
641
+ margin-inline-start: calc(-50vw + 50%);
642
+ scroll-snap-type: x mandatory;
643
+ }
644
+
645
+ @media (min-width: 768px) {
646
+ .example-container-1-classname-partly .example-item {
647
+ width: calc( ( var( --slider-container-target-width ) / 4 ) - ( 3 / 4 * var( --slide-gap ) ) );
648
+ }
649
+
650
+ .example-container-1-classname-partly .example-item {
651
+ transition: .2s ease-in-out;
652
+ }
653
+
654
+ .example-container-1-classname-partly .is-visible {
655
+ opacity: 1;
656
+ /* transform: scale(1); */
657
+ }
658
+
659
+ .example-container-1-classname-partly .is-partly-visible {
660
+ opacity: .5;
661
+ /* transform: scale(0.85); */
662
+ }
663
+ .example-container-1-classname-partly .is-hidden {
664
+ opacity: .2;
665
+ /* transform: scale(0); */
666
+ }
667
+
547
668
  /* ===========================================================================
548
669
  Example 4: Filters
549
670
  =========================================================================== */
@@ -641,6 +762,7 @@ h3:before {
641
762
  .example-container-4-full-width {
642
763
  width: 100vw;
643
764
  margin-inline-start: calc(-50vw + 50%);
765
+ scroll-snap-type: x mandatory;
644
766
  }
645
767
 
646
768
  /* ===========================================================================
@@ -683,3 +805,37 @@ h3:before {
683
805
  background: var(--color-grey-800);
684
806
  color: #fff;
685
807
  }
808
+
809
+ /* ===========================================================================
810
+ Example 4: Hero
811
+ =========================================================================== */
812
+
813
+ .example-container-4-hero__wrapper {
814
+ position: relative;
815
+ }
816
+
817
+ .example-container-4-hero {
818
+ --slider-gap: 0;
819
+ gap: 0;
820
+ }
821
+
822
+ .example-container-4-hero > * {
823
+ width: var(--slider-container-width, 900px);
824
+ aspect-ratio: 16/9;
825
+ }
826
+
827
+ .example-container-4-hero__autoplay {
828
+ position: absolute;
829
+ bottom: 1rem;
830
+ right: 1rem;
831
+ }
832
+
833
+ .example-container-4-hero__dots {
834
+ z-index: 10;
835
+ position: absolute;
836
+ bottom: 1rem;
837
+ left: 50%;
838
+ transform: translateX(-50%);
839
+ --overflow-slider-dot-inactive-color: rgba(0, 0, 0, 0.2);
840
+ --overflow-slider-dot-active-color: rgba(0, 0, 0, .8);
841
+ }
@@ -14,11 +14,14 @@ import { OverflowSlider } from '../dist/index.esm.js';
14
14
  import DragScrollingPlugin from '../dist/plugins/drag-scrolling/index.esm.js';
15
15
  import SkipLinksPlugin from '../dist/plugins/skip-links/index.esm.js';
16
16
  import ArrowsPlugin from '../dist/plugins/arrows/index.esm.js';
17
+ import AutoplayPlugin from '../dist/plugins/autoplay/index.esm.js';
17
18
  import ScrollIndicatorPlugin from '../dist/plugins/scroll-indicator/index.esm.js';
18
19
  import DotsPlugin from '../dist/plugins/dots/index.esm.js';
19
20
  import FullWidthPlugin from '../dist/plugins/full-width/index.esm.js';
20
21
  import ThumbnailsPlugin from '../dist/plugins/thumbnails/index.esm.js';
21
22
  import FadePlugin from '../dist/plugins/fade/index.esm.js';
23
+ import ClassNamesPlugin from '../dist/plugins/classnames/index.esm.js';
24
+
22
25
 
23
26
  (function () {
24
27
  const init = () => {
@@ -133,6 +136,71 @@ import FadePlugin from '../dist/plugins/fade/index.esm.js';
133
136
  );
134
137
  console.log( '1-fade', example1Fade );
135
138
 
139
+ const example1ClassNames = new OverflowSlider(
140
+ document.querySelector( '.example-container-1-classname-opacity' ),
141
+ {
142
+ emulateScrollSnap: true,
143
+ rtl: document.documentElement.dir === 'rtl',
144
+ },
145
+ [
146
+ DragScrollingPlugin(),
147
+ ClassNamesPlugin(),
148
+ ]
149
+ );
150
+ console.log( '1-classname-opacity', example1ClassNames );
151
+
152
+ const example1ClassNamesPartly = new OverflowSlider(
153
+ document.querySelector( '.example-container-1-classname-partly' ),
154
+ {
155
+ emulateScrollSnap: true,
156
+ rtl: document.documentElement.dir === 'rtl',
157
+ targetWidth: (slider) => {
158
+ return slider.container.parentElement.clientWidth;
159
+ }
160
+ },
161
+ [
162
+ DragScrollingPlugin(),
163
+ FullWidthPlugin(),
164
+ ClassNamesPlugin(
165
+ {
166
+ classnames: {
167
+ partlyVisible: 'is-partly-visible',
168
+ },
169
+ freezeStateOnVisible: true,
170
+ }
171
+ ),
172
+ ]
173
+ );
174
+ console.log( '1-classname-partly', example1ClassNamesPartly );
175
+
176
+ const example1AutoplaySlide = new OverflowSlider(
177
+ document.querySelector( '.example-container-1-autoplay-slide' ),
178
+ {
179
+ emulateScrollSnap: true,
180
+ rtl: document.documentElement.dir === 'rtl',
181
+ },
182
+ [
183
+ DragScrollingPlugin(),
184
+ AutoplayPlugin({
185
+ movementType: 'slide',
186
+ })
187
+ ]
188
+ );
189
+ console.log( '1-autoplay-slide', example1AutoplaySlide );
190
+
191
+ const example1AutoplayView = new OverflowSlider(
192
+ document.querySelector( '.example-container-1-autoplay-view' ),
193
+ {
194
+ emulateScrollSnap: true,
195
+ rtl: document.documentElement.dir === 'rtl',
196
+ },
197
+ [
198
+ DragScrollingPlugin(),
199
+ AutoplayPlugin()
200
+ ]
201
+ );
202
+ console.log( '1-autoplay-view', example1AutoplayView );
203
+
136
204
  const example2PerfectFit = new OverflowSlider(
137
205
  document.querySelector( '.example-container-2-perfect-fit' ),
138
206
  {
@@ -239,17 +307,14 @@ import FadePlugin from '../dist/plugins/fade/index.esm.js';
239
307
  document.querySelector( '.example-container-4-full-width' ),
240
308
  {
241
309
  rtl: document.documentElement.dir === 'rtl',
310
+ emulateScrollSnap: true,
311
+ targetWidth: (slider) => {
312
+ return slider.container.parentElement.clientWidth;
313
+ }
242
314
  },
243
315
  [
244
316
  DragScrollingPlugin(),
245
- FullWidthPlugin(
246
- {
247
- targetWidth: (slider) => {
248
- // copy the width of the parent element
249
- return slider.container.parentElement.clientWidth;
250
- }
251
- }
252
- ),
317
+ FullWidthPlugin(),
253
318
  ScrollIndicatorPlugin(),
254
319
  ]
255
320
  );
@@ -282,6 +347,25 @@ import FadePlugin from '../dist/plugins/fade/index.esm.js';
282
347
  );
283
348
  console.log( '4-synced-thumbnails', example4SyncedThumbnails );
284
349
 
350
+ const example4Hero = new OverflowSlider(
351
+ document.querySelector( '.example-container-4-hero' ),
352
+ {
353
+ emulateScrollSnap: true,
354
+ rtl: document.documentElement.dir === 'rtl',
355
+ },
356
+ [
357
+ DragScrollingPlugin(),
358
+ DotsPlugin({
359
+ container: document.querySelector( '.example-container-4-hero__dots' ),
360
+ }),
361
+ AutoplayPlugin({
362
+ movementType: 'slide',
363
+ container: document.querySelector( '.example-container-4-hero__autoplay' ),
364
+ })
365
+ ]
366
+ );
367
+ console.log( '4-hero', example4Hero );
368
+
285
369
  };
286
370
 
287
371
  init();
@@ -0,0 +1 @@
1
+ export { default as OverflowSlider } from './plugins/core/index.d2.ts';