@evermade/overflow-slider 3.0.0 → 3.2.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 (63) hide show
  1. package/README.md +73 -8
  2. package/dist/core/details.esm.js +5 -5
  3. package/dist/core/details.min.js +1 -1
  4. package/dist/core/overflow-slider.esm.js +1 -0
  5. package/dist/core/overflow-slider.min.js +1 -1
  6. package/dist/core/slider.esm.js +113 -44
  7. package/dist/core/slider.min.js +1 -1
  8. package/dist/core/utils.esm.js +15 -1
  9. package/dist/core/utils.min.js +1 -1
  10. package/dist/overflow-slider.css +1 -1
  11. package/dist/plugins/arrows/arrows/index.esm.js +20 -10
  12. package/dist/plugins/arrows/arrows/index.min.js +1 -1
  13. package/dist/plugins/dots/dots/index.esm.js +0 -4
  14. package/dist/plugins/drag-scrolling/drag-scrolling/index.esm.js +1 -1
  15. package/dist/plugins/drag-scrolling/drag-scrolling/index.min.js +1 -1
  16. package/dist/plugins/fade/fade/index.esm.js +7 -7
  17. package/dist/plugins/fade/fade/index.min.js +1 -1
  18. package/dist/plugins/full-width/full-width/index.esm.js +7 -2
  19. package/dist/plugins/full-width/full-width/index.min.js +1 -1
  20. package/dist/plugins/scroll-indicator/scroll-indicator/index.esm.js +22 -22
  21. package/dist/plugins/scroll-indicator/scroll-indicator/index.min.js +1 -1
  22. package/dist/plugins/thumbnails/thumbnails/index.esm.js +7 -4
  23. package/dist/plugins/thumbnails/thumbnails/index.min.js +1 -1
  24. package/docs/assets/demo.css +11 -1
  25. package/docs/assets/demo.js +38 -12
  26. package/docs/dist/core/details.esm.js +5 -5
  27. package/docs/dist/core/details.min.js +1 -1
  28. package/docs/dist/core/overflow-slider.esm.js +1 -0
  29. package/docs/dist/core/overflow-slider.min.js +1 -1
  30. package/docs/dist/core/slider.esm.js +113 -44
  31. package/docs/dist/core/slider.min.js +1 -1
  32. package/docs/dist/core/utils.esm.js +15 -1
  33. package/docs/dist/core/utils.min.js +1 -1
  34. package/docs/dist/overflow-slider.css +1 -1
  35. package/docs/dist/plugins/arrows/arrows/index.esm.js +20 -10
  36. package/docs/dist/plugins/arrows/arrows/index.min.js +1 -1
  37. package/docs/dist/plugins/dots/dots/index.esm.js +0 -4
  38. package/docs/dist/plugins/drag-scrolling/drag-scrolling/index.esm.js +1 -1
  39. package/docs/dist/plugins/drag-scrolling/drag-scrolling/index.min.js +1 -1
  40. package/docs/dist/plugins/fade/fade/index.esm.js +7 -7
  41. package/docs/dist/plugins/fade/fade/index.min.js +1 -1
  42. package/docs/dist/plugins/full-width/full-width/index.esm.js +7 -2
  43. package/docs/dist/plugins/full-width/full-width/index.min.js +1 -1
  44. package/docs/dist/plugins/scroll-indicator/scroll-indicator/index.esm.js +22 -22
  45. package/docs/dist/plugins/scroll-indicator/scroll-indicator/index.min.js +1 -1
  46. package/docs/dist/plugins/thumbnails/thumbnails/index.esm.js +7 -4
  47. package/docs/dist/plugins/thumbnails/thumbnails/index.min.js +1 -1
  48. package/docs/index-rtl.html +396 -0
  49. package/docs/index.html +1 -1
  50. package/package.json +1 -1
  51. package/src/core/details.ts +5 -5
  52. package/src/core/overflow-slider.ts +1 -0
  53. package/src/core/slider.ts +125 -47
  54. package/src/core/types.ts +5 -0
  55. package/src/core/utils.ts +19 -1
  56. package/src/plugins/arrows/index.ts +20 -10
  57. package/src/plugins/dots/index.ts +0 -4
  58. package/src/plugins/drag-scrolling/index.ts +1 -1
  59. package/src/plugins/fade/index.ts +7 -8
  60. package/src/plugins/fade/styles.scss +10 -0
  61. package/src/plugins/full-width/index.ts +8 -2
  62. package/src/plugins/scroll-indicator/index.ts +62 -64
  63. package/src/plugins/thumbnails/index.ts +7 -5
@@ -32,41 +32,40 @@ function ScrollIndicatorPlugin(args) {
32
32
  setDataAttributes();
33
33
  const getScrollbarButtonLeftOffset = () => {
34
34
  const contentRatio = scrollbarButton.offsetWidth / slider.details.containerWidth;
35
- return slider.container.scrollLeft * contentRatio;
35
+ const scrollAmount = slider.getScrollLeft() * contentRatio;
36
+ if (slider.options.rtl) {
37
+ return scrollbar.offsetWidth - scrollbarButton.offsetWidth - scrollAmount;
38
+ }
39
+ return scrollAmount;
36
40
  };
37
- // scrollbarbutton width and position is calculated based on the scroll position and available width
38
41
  let requestId = 0;
39
42
  const update = () => {
40
43
  if (requestId) {
41
44
  window.cancelAnimationFrame(requestId);
42
45
  }
43
46
  requestId = window.requestAnimationFrame(() => {
44
- const scrollbarButtonWidth = (slider.details.containerWidth / slider.details.scrollableAreaWidth) * 100;
47
+ const scrollbarButtonWidth = (slider.details.containerWidth / slider.container.scrollWidth) * 100;
45
48
  const scrollLeftInPortion = getScrollbarButtonLeftOffset();
46
49
  scrollbarButton.style.width = `${scrollbarButtonWidth}%`;
47
50
  scrollbarButton.style.transform = `translateX(${scrollLeftInPortion}px)`;
48
- // aria-valuenow
49
- const scrollLeft = slider.container.scrollLeft;
50
- const scrollWidth = slider.container.scrollWidth;
51
+ const scrollLeft = slider.getScrollLeft();
52
+ const scrollWidth = slider.getInclusiveScrollWidth();
51
53
  const containerWidth = slider.container.offsetWidth;
52
54
  const scrollPercentage = (scrollLeft / (scrollWidth - containerWidth)) * 100;
53
55
  scrollbarContainer.setAttribute('aria-valuenow', Math.round(Number.isNaN(scrollPercentage) ? 0 : scrollPercentage).toString());
54
56
  });
55
57
  };
56
- // insert to DOM
57
58
  if (options.container) {
58
59
  options.container.appendChild(scrollbarContainer);
59
60
  }
60
61
  else {
61
62
  (_c = slider.container.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(scrollbarContainer, slider.container.nextSibling);
62
63
  }
63
- // update the scrollbar when the slider is scrolled
64
64
  update();
65
65
  slider.on('scroll', update);
66
66
  slider.on('contentsChanged', update);
67
67
  slider.on('containerSizeChanged', update);
68
68
  slider.on('detailsChanged', setDataAttributes);
69
- // handle arrow keys while focused
70
69
  scrollbarContainer.addEventListener('keydown', (e) => {
71
70
  if (e.key === 'ArrowLeft') {
72
71
  slider.moveToDirection('prev');
@@ -75,29 +74,29 @@ function ScrollIndicatorPlugin(args) {
75
74
  slider.moveToDirection('next');
76
75
  }
77
76
  });
78
- // handle click to before or after the scrollbar button
77
+ let isInteractionDown = false;
78
+ let startX = 0;
79
+ let scrollLeft = slider.getScrollLeft();
79
80
  scrollbarContainer.addEventListener('click', (e) => {
81
+ if (e.target == scrollbarButton) {
82
+ return;
83
+ }
80
84
  const scrollbarButtonWidth = scrollbarButton.offsetWidth;
81
85
  const scrollbarButtonLeft = getScrollbarButtonLeftOffset();
82
86
  const scrollbarButtonRight = scrollbarButtonLeft + scrollbarButtonWidth;
83
- const clickX = e.pageX - scrollbarContainer.offsetLeft;
84
- if (clickX < scrollbarButtonLeft) {
85
- slider.moveToDirection('prev');
87
+ const clickX = e.pageX - Math.abs(scrollbarContainer.offsetLeft);
88
+ if (Math.floor(clickX) < Math.floor(scrollbarButtonLeft)) {
89
+ slider.moveToDirection(slider.options.rtl ? 'next' : 'prev');
86
90
  }
87
- else if (clickX > scrollbarButtonRight) {
88
- slider.moveToDirection('next');
91
+ else if (Math.floor(clickX) > Math.floor(scrollbarButtonRight)) {
92
+ slider.moveToDirection(slider.options.rtl ? 'prev' : 'next');
89
93
  }
90
94
  });
91
- // make scrollbar button draggable via mouse/touch and update the scroll position
92
- let isInteractionDown = false;
93
- let startX = 0;
94
- let scrollLeft = 0;
95
95
  const onInteractionDown = (e) => {
96
96
  isInteractionDown = true;
97
97
  const pageX = e.pageX || e.touches[0].pageX;
98
98
  startX = pageX - scrollbarContainer.offsetLeft;
99
- scrollLeft = slider.container.scrollLeft;
100
- // change cursor to grabbing
99
+ scrollLeft = slider.getScrollLeft();
101
100
  scrollbarButton.style.cursor = 'grabbing';
102
101
  scrollbarButton.setAttribute('data-is-grabbed', 'true');
103
102
  e.preventDefault();
@@ -112,7 +111,8 @@ function ScrollIndicatorPlugin(args) {
112
111
  const x = pageX - scrollbarContainer.offsetLeft;
113
112
  const scrollingFactor = slider.details.scrollableAreaWidth / scrollbarContainer.offsetWidth;
114
113
  const walk = (x - startX) * scrollingFactor;
115
- slider.container.scrollLeft = scrollLeft + walk;
114
+ const distance = slider.options.rtl ? scrollLeft - walk : scrollLeft + walk;
115
+ slider.setScrollLeft(distance);
116
116
  };
117
117
  const onInteractionUp = () => {
118
118
  isInteractionDown = false;
@@ -1 +1 @@
1
- const t={scrollIndicator:"overflow-slider__scroll-indicator",scrollIndicatorBar:"overflow-slider__scroll-indicator-bar",scrollIndicatorButton:"overflow-slider__scroll-indicator-button"};function e(e){return n=>{var o,r,a;const i={classNames:Object.assign(Object.assign({},t),(null==e?void 0:e.classNames)||[]),container:null!==(o=null==e?void 0:e.container)&&void 0!==o?o:null},s=document.createElement("div");s.setAttribute("class",i.classNames.scrollIndicator),s.setAttribute("tabindex","0"),s.setAttribute("role","scrollbar"),s.setAttribute("aria-controls",null!==(r=n.container.getAttribute("id"))&&void 0!==r?r:""),s.setAttribute("aria-orientation","horizontal"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuenow","0");const l=document.createElement("div");l.setAttribute("class",i.classNames.scrollIndicatorBar);const c=document.createElement("div");c.setAttribute("class",i.classNames.scrollIndicatorButton),c.setAttribute("data-is-grabbed","false"),l.appendChild(c),s.appendChild(l);const d=()=>{s.setAttribute("data-has-overflow",n.details.hasOverflow.toString())};d();const u=()=>{const t=c.offsetWidth/n.details.containerWidth;return n.container.scrollLeft*t};let v=0;const f=()=>{v&&window.cancelAnimationFrame(v),v=window.requestAnimationFrame((()=>{const t=n.details.containerWidth/n.details.scrollableAreaWidth*100,e=u();c.style.width=`${t}%`,c.style.transform=`translateX(${e}px)`;const o=n.container.scrollLeft/(n.container.scrollWidth-n.container.offsetWidth)*100;s.setAttribute("aria-valuenow",Math.round(Number.isNaN(o)?0:o).toString())}))};i.container?i.container.appendChild(s):null===(a=n.container.parentNode)||void 0===a||a.insertBefore(s,n.container.nextSibling),f(),n.on("scroll",f),n.on("contentsChanged",f),n.on("containerSizeChanged",f),n.on("detailsChanged",d),s.addEventListener("keydown",(t=>{"ArrowLeft"===t.key?n.moveToDirection("prev"):"ArrowRight"===t.key&&n.moveToDirection("next")})),s.addEventListener("click",(t=>{const e=c.offsetWidth,o=u(),r=o+e,a=t.pageX-s.offsetLeft;a<o?n.moveToDirection("prev"):a>r&&n.moveToDirection("next")}));let b=!1,m=0,h=0;const w=t=>{b=!0;const e=t.pageX||t.touches[0].pageX;m=e-s.offsetLeft,h=n.container.scrollLeft,c.style.cursor="grabbing",c.setAttribute("data-is-grabbed","true"),t.preventDefault(),t.stopPropagation()},p=t=>{if(!b)return;t.preventDefault();const e=(t.pageX||t.touches[0].pageX)-s.offsetLeft,o=n.details.scrollableAreaWidth/s.offsetWidth,r=(e-m)*o;n.container.scrollLeft=h+r},A=()=>{b=!1,c.style.cursor="",c.setAttribute("data-is-grabbed","false")};c.addEventListener("mousedown",w),c.addEventListener("touchstart",w),window.addEventListener("mousemove",p),window.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("mouseup",A),window.addEventListener("touchend",A)}}export{e as default};
1
+ const t={scrollIndicator:"overflow-slider__scroll-indicator",scrollIndicatorBar:"overflow-slider__scroll-indicator-bar",scrollIndicatorButton:"overflow-slider__scroll-indicator-button"};function e(e){return o=>{var r,n,i;const a={classNames:Object.assign(Object.assign({},t),(null==e?void 0:e.classNames)||[]),container:null!==(r=null==e?void 0:e.container)&&void 0!==r?r:null},s=document.createElement("div");s.setAttribute("class",a.classNames.scrollIndicator),s.setAttribute("tabindex","0"),s.setAttribute("role","scrollbar"),s.setAttribute("aria-controls",null!==(n=o.container.getAttribute("id"))&&void 0!==n?n:""),s.setAttribute("aria-orientation","horizontal"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuenow","0");const l=document.createElement("div");l.setAttribute("class",a.classNames.scrollIndicatorBar);const c=document.createElement("div");c.setAttribute("class",a.classNames.scrollIndicatorButton),c.setAttribute("data-is-grabbed","false"),l.appendChild(c),s.appendChild(l);const d=()=>{s.setAttribute("data-has-overflow",o.details.hasOverflow.toString())};d();const u=()=>{const t=c.offsetWidth/o.details.containerWidth,e=o.getScrollLeft()*t;return o.options.rtl?l.offsetWidth-c.offsetWidth-e:e};let f=0;const v=()=>{f&&window.cancelAnimationFrame(f),f=window.requestAnimationFrame((()=>{const t=o.details.containerWidth/o.container.scrollWidth*100,e=u();c.style.width=`${t}%`,c.style.transform=`translateX(${e}px)`;const r=o.getScrollLeft()/(o.getInclusiveScrollWidth()-o.container.offsetWidth)*100;s.setAttribute("aria-valuenow",Math.round(Number.isNaN(r)?0:r).toString())}))};a.container?a.container.appendChild(s):null===(i=o.container.parentNode)||void 0===i||i.insertBefore(s,o.container.nextSibling),v(),o.on("scroll",v),o.on("contentsChanged",v),o.on("containerSizeChanged",v),o.on("detailsChanged",d),s.addEventListener("keydown",(t=>{"ArrowLeft"===t.key?o.moveToDirection("prev"):"ArrowRight"===t.key&&o.moveToDirection("next")}));let b=!1,h=0,m=o.getScrollLeft();s.addEventListener("click",(t=>{if(t.target==c)return;const e=c.offsetWidth,r=u(),n=r+e,i=t.pageX-Math.abs(s.offsetLeft);Math.floor(i)<Math.floor(r)?o.moveToDirection(o.options.rtl?"next":"prev"):Math.floor(i)>Math.floor(n)&&o.moveToDirection(o.options.rtl?"prev":"next")}));const g=t=>{b=!0;const e=t.pageX||t.touches[0].pageX;h=e-s.offsetLeft,m=o.getScrollLeft(),c.style.cursor="grabbing",c.setAttribute("data-is-grabbed","true"),t.preventDefault(),t.stopPropagation()},p=t=>{if(!b)return;t.preventDefault();const e=(t.pageX||t.touches[0].pageX)-s.offsetLeft,r=o.details.scrollableAreaWidth/s.offsetWidth,n=(e-h)*r,i=o.options.rtl?m-n:m+n;o.setScrollLeft(i)},w=()=>{b=!1,c.style.cursor="",c.setAttribute("data-is-grabbed","false")};c.addEventListener("mousedown",g),c.addEventListener("touchstart",g),window.addEventListener("mousemove",p),window.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("mouseup",w),window.addEventListener("touchend",w)}}export{e as default};
@@ -27,13 +27,16 @@ function FullWidthPlugin(args) {
27
27
  };
28
28
  setActiveThumbnail();
29
29
  addClickListeners();
30
- // @todo debounce on scroll
31
30
  mainSlider.on('scrollEnd', () => {
32
31
  setTimeout(() => {
33
- const activeSlideIdx = mainSlider.activeSlideIdx;
34
- const activeThumbnail = slider.slides[activeSlideIdx];
32
+ const mainActiveSlideIdx = mainSlider.activeSlideIdx;
33
+ const thumbActiveSlideIdx = slider.activeSlideIdx;
34
+ if (thumbActiveSlideIdx === mainActiveSlideIdx) {
35
+ return;
36
+ }
37
+ const activeThumbnail = slider.slides[mainActiveSlideIdx];
35
38
  setActiveThumbnail(activeThumbnail);
36
- slider.moveToSlide(activeSlideIdx);
39
+ slider.moveToSlide(mainActiveSlideIdx);
37
40
  }, 50);
38
41
  });
39
42
  };
@@ -1 +1 @@
1
- function e(e){return i=>{const l={mainSlider:e.mainSlider}.mainSlider,t=(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"))};t(),i.slides.forEach(((e,i)=>{e.addEventListener("click",(()=>{l.moveToSlide(i),t(e)}))})),l.on("scrollEnd",(()=>{setTimeout((()=>{const e=l.activeSlideIdx,r=i.slides[e];t(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};
@@ -0,0 +1,396 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-US" dir="rtl">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <link href="dist/overflow-slider.css" rel="stylesheet" />
7
+ <link href="assets/demo.css" rel="stylesheet" />
8
+ <title>Demo – overflow-slider</title>
9
+ <meta property="og:description" content="overflow-slider" />
10
+ </head>
11
+ <body>
12
+ <div class="site">
13
+ <header class="site-header">
14
+ <div class="site-header__inner">
15
+ <div class="site-branding">
16
+ <a href="https://github.com/evermade/overflow-slider" class="site-logo" aria-label="Evermade">
17
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 270 270" width="64" height="64">
18
+ <path fill="#F04D37" d="M0 0h270v270H0z"/>
19
+ <path fill="#fff" d="M134.748 73.7339c-13.949-.1043-27.398 5.1741-37.535 14.7314-10.1368 9.5573-16.1761 22.6537-16.8549 36.5487H189.235c-.715-13.9-6.779-26.9892-16.929-36.5417-10.15-9.5525-23.603-14.8318-37.558-14.7384Zm85.532 74.6601H79.2372c2.228 13.263 9.1042 25.307 19.4039 33.986 10.2999 8.679 23.3539 13.43 36.8379 13.406 9.931.362 19.754-2.16 28.276-7.26 8.521-5.099 15.375-12.557 19.729-21.467h32.848c-13.354 35.921-41.474 54.926-82.072 54.926-11.548.213-23.019-1.905-33.726-6.227-10.7059-4.321-20.4256-10.757-28.5743-18.921-8.1488-8.163-14.5585-17.886-18.8439-28.583-4.2854-10.697-6.358-22.148-6.0933-33.664 0-49.9195 35.7237-87.59 87.7255-87.59 50.588 0 87.238 37.476 87.238 85.743.118 5.275-.489 10.541-1.804 15.651"/>
20
+ </svg>
21
+ <span>@evermade/overflow-slider</span>
22
+ </a>
23
+ </div>
24
+ </div>
25
+ </header>
26
+ <script type="module" src="assets/demo.js"></script>
27
+ <main id="main" class="site-main">
28
+ <article class="entry">
29
+ <div class="entry__content">
30
+ <h1>Overflow Slider Demos RTL</h1>
31
+
32
+ <section class="entry__section">
33
+ <h2>Basic Demos</h2>
34
+ <div class="entry__item">
35
+ <h3>Pure CSS</h3>
36
+ <p>No plugins applied. Using only CSS.</p>
37
+ <div class="overflow-slider example-container example-container-1-css">
38
+ <a href="#1" class="example-item example-item--1">1</a>
39
+ <a href="#2" class="example-item example-item--2">2</a>
40
+ <a href="#3" class="example-item example-item--3">3</a>
41
+ <a href="#4" class="example-item example-item--4">4</a>
42
+ <a href="#5" class="example-item example-item--5">5</a>
43
+ <a href="#6" class="example-item example-item--6">6</a>
44
+ <a href="#7" class="example-item example-item--7">7</a>
45
+ <a href="#8" class="example-item example-item--8">8</a>
46
+ <a href="#9" class="example-item example-item--9">9</a>
47
+ <a href="#10" class="example-item example-item--10">10</a>
48
+ <a href="#11" class="example-item example-item--11">11</a>
49
+ <a href="#12" class="example-item example-item--12">12</a>
50
+ <a href="#13" class="example-item example-item--13">13</a>
51
+ </div>
52
+ </div>
53
+
54
+ <div class="entry__item">
55
+ <h3>Mouse Dragging</h3>
56
+ <p>Drag slides with mouse. Uses DragScrollingPlugin. These slides are clickable.</p>
57
+ <div class="overflow-slider example-container example-container-1-drag-scrolling-clickable">
58
+ <a href="#1" class="example-item example-item--1">1</a>
59
+ <a href="#2" class="example-item example-item--2">2</a>
60
+ <a href="#3" class="example-item example-item--3">3</a>
61
+ <a href="#4" class="example-item example-item--4">4</a>
62
+ <a href="#5" class="example-item example-item--5">5</a>
63
+ <a href="#6" class="example-item example-item--6">6</a>
64
+ <a href="#7" class="example-item example-item--7">7</a>
65
+ <a href="#8" class="example-item example-item--8">8</a>
66
+ <a href="#9" class="example-item example-item--9">9</a>
67
+ <a href="#10" class="example-item example-item--10">10</a>
68
+ <a href="#11" class="example-item example-item--11">11</a>
69
+ <a href="#12" class="example-item example-item--12">12</a>
70
+ <a href="#13" class="example-item example-item--13">13</a>
71
+ </div>
72
+ <p style="margin-top:1.5rem;">These slides are not clickable.</p>
73
+ <div class="overflow-slider example-container example-container-1-drag-scrolling-not-clickable">
74
+ <div class="example-item example-item--1">1</div>
75
+ <div class="example-item example-item--2">2</div>
76
+ <div class="example-item example-item--3">3</div>
77
+ <div class="example-item example-item--4">4</div>
78
+ <div class="example-item example-item--5">5</div>
79
+ <div class="example-item example-item--6">6</div>
80
+ <div class="example-item example-item--7">7</div>
81
+ <div class="example-item example-item--8">8</div>
82
+ <div class="example-item example-item--9">9</div>
83
+ <div class="example-item example-item--10">10</div>
84
+ <div class="example-item example-item--11">11</div>
85
+ <div class="example-item example-item--12">12</div>
86
+ <div class="example-item example-item--13">13</div>
87
+ </div>
88
+ <p style="margin-top:1.5rem;">Scroll-snap emulation enabled.</p>
89
+ <div class="overflow-slider example-container example-container-1-drag-scrolling-scroll-snap">
90
+ <div class="example-item example-item--1">1</div>
91
+ <div class="example-item example-item--2">2</div>
92
+ <div class="example-item example-item--3">3</div>
93
+ <div class="example-item example-item--4">4</div>
94
+ <div class="example-item example-item--5">5</div>
95
+ <div class="example-item example-item--6">6</div>
96
+ <div class="example-item example-item--7">7</div>
97
+ <div class="example-item example-item--8">8</div>
98
+ <div class="example-item example-item--9">9</div>
99
+ <div class="example-item example-item--10">10</div>
100
+ <div class="example-item example-item--11">11</div>
101
+ <div class="example-item example-item--12">12</div>
102
+ <div class="example-item example-item--13">13</div>
103
+ </div>
104
+ </div>
105
+
106
+ <div class="entry__item">
107
+ <h3>Arrows</h3>
108
+ <p>Display buttons to move slides. Uses ArrowsPlugin.</p>
109
+ <div class="overflow-slider example-container example-container-1-arrows">
110
+ <a href="#1" class="example-item example-item--1">1</a>
111
+ <a href="#2" class="example-item example-item--2">2</a>
112
+ <a href="#3" class="example-item example-item--3">3</a>
113
+ <a href="#4" class="example-item example-item--4">4</a>
114
+ <a href="#5" class="example-item example-item--5">5</a>
115
+ <a href="#6" class="example-item example-item--6">6</a>
116
+ <a href="#7" class="example-item example-item--7">7</a>
117
+ <a href="#8" class="example-item example-item--8">8</a>
118
+ <a href="#9" class="example-item example-item--9">9</a>
119
+ <a href="#10" class="example-item example-item--10">10</a>
120
+ <a href="#11" class="example-item example-item--11">11</a>
121
+ <a href="#12" class="example-item example-item--12">12</a>
122
+ <a href="#13" class="example-item example-item--13">13</a>
123
+ </div>
124
+ </div>
125
+
126
+ <div class="entry__item">
127
+ <h3>Scroll Indicator</h3>
128
+ <p>Display scroll indicator. Uses ScrollIndicatorPlugin.</p>
129
+ <div class="overflow-slider example-container example-container-1-scroll-indicator">
130
+ <a href="#1" class="example-item example-item--1">1</a>
131
+ <a href="#2" class="example-item example-item--2">2</a>
132
+ <a href="#3" class="example-item example-item--3">3</a>
133
+ <a href="#4" class="example-item example-item--4">4</a>
134
+ <a href="#5" class="example-item example-item--5">5</a>
135
+ <a href="#6" class="example-item example-item--6">6</a>
136
+ <a href="#7" class="example-item example-item--7">7</a>
137
+ <a href="#8" class="example-item example-item--8">8</a>
138
+ <a href="#9" class="example-item example-item--9">9</a>
139
+ <a href="#10" class="example-item example-item--10">10</a>
140
+ </div>
141
+ </div>
142
+
143
+ <div class="entry__item">
144
+ <h3>Dots</h3>
145
+ <p>Display dots indicator. Uses DotsPlugin.</p>
146
+ <div class="overflow-slider example-container example-container-1-dots">
147
+ <a href="#1" class="example-item example-item--1">1</a>
148
+ <a href="#2" class="example-item example-item--2">2</a>
149
+ <a href="#3" class="example-item example-item--3">3</a>
150
+ <a href="#4" class="example-item example-item--4">4</a>
151
+ <a href="#5" class="example-item example-item--5">5</a>
152
+ <a href="#6" class="example-item example-item--6">6</a>
153
+ </div>
154
+ </div>
155
+
156
+ <div class="entry__item">
157
+ <h3>Fade</h3>
158
+ <p>Display fade. Uses FadePlugin. Fade can be on both sides but having it only at end is more usable.</p>
159
+ <div class="example-container-1-fade-wrap">
160
+ <div class="example-container-1-fade__start"></div>
161
+ <div class="overflow-slider example-container example-container-1-fade">
162
+ <a href="#1" class="example-item example-item--1">1</a>
163
+ <a href="#2" class="example-item example-item--2">2</a>
164
+ <a href="#3" class="example-item example-item--3">3</a>
165
+ <a href="#4" class="example-item example-item--4">4</a>
166
+ <a href="#5" class="example-item example-item--5">5</a>
167
+ <a href="#6" class="example-item example-item--6">6</a>
168
+ <a href="#7" class="example-item example-item--7">7</a>
169
+ <a href="#8" class="example-item example-item--8">8</a>
170
+ <a href="#9" class="example-item example-item--9">9</a>
171
+ <a href="#10" class="example-item example-item--10">10</a>
172
+ </div>
173
+ <div class="example-container-1-fade__end"></div>
174
+ </div>
175
+ </div>
176
+
177
+ </section>
178
+
179
+ <section class="entry__section">
180
+
181
+ <h2>Slide Contents</h2>
182
+
183
+ <div class="entry__item">
184
+ <h3>Perfectly Fitting Slides</h3>
185
+ <p>Slides fill the container perfectly.</p>
186
+ <div class="overflow-slider example-container example-container-2-perfect-fit">
187
+ <a href="#1" class="example-item example-item--1">1</a>
188
+ <a href="#2" class="example-item example-item--2">2</a>
189
+ <a href="#3" class="example-item example-item--3">3</a>
190
+ <a href="#4" class="example-item example-item--4">4</a>
191
+ <a href="#5" class="example-item example-item--5">5</a>
192
+ <a href="#6" class="example-item example-item--6">6</a>
193
+ <a href="#7" class="example-item example-item--7">7</a>
194
+ <a href="#8" class="example-item example-item--8">8</a>
195
+ <a href="#9" class="example-item example-item--9">9</a>
196
+ <a href="#10" class="example-item example-item--10">10</a>
197
+ </div>
198
+ </div>
199
+
200
+ <div class="entry__item">
201
+ <h3>Varying Width Slides</h3>
202
+ <p>Slides are not equal width.</p>
203
+ <div class="overflow-slider example-container example-container-2-varying-widths">
204
+ <a href="#1" class="example-item example-item--1">1</a>
205
+ <a href="#2" class="example-item example-item--2">2</a>
206
+ <a href="#3" class="example-item example-item--3">3</a>
207
+ <a href="#4" class="example-item example-item--4">4</a>
208
+ <a href="#5" class="example-item example-item--5">5</a>
209
+ <a href="#6" class="example-item example-item--6">6</a>
210
+ <a href="#7" class="example-item example-item--7">7</a>
211
+ <a href="#8" class="example-item example-item--8">8</a>
212
+ </div>
213
+ </div>
214
+
215
+ <div class="entry__item">
216
+ <h3>Only Few Slides</h3>
217
+ <p>Not enough slides to have a slider (on mobile has though).</p>
218
+ <div class="overflow-slider example-container example-container-2-only-few-slides">
219
+ <a href="#1" class="example-item example-item--1">1</a>
220
+ <a href="#2" class="example-item example-item--2">2</a>
221
+ <a href="#3" class="example-item example-item--3">3</a>
222
+ </div>
223
+ </div>
224
+
225
+ </section>
226
+
227
+ <section class="entry__section">
228
+
229
+ <h2>CSS Trickery</h2>
230
+
231
+ <div class="entry__item">
232
+ <h3>Scroll Snapping (mandatory)</h3>
233
+ <p>Force scrolling to snap to slide always.</p>
234
+ <div class="overflow-slider example-container example-container-3-scroll-snapping-mandatory">
235
+ <a href="#1" class="example-item example-item--1">1</a>
236
+ <a href="#2" class="example-item example-item--2">2</a>
237
+ <a href="#3" class="example-item example-item--3">3</a>
238
+ <a href="#4" class="example-item example-item--4">4</a>
239
+ <a href="#5" class="example-item example-item--5">5</a>
240
+ <a href="#6" class="example-item example-item--6">6</a>
241
+ <a href="#7" class="example-item example-item--7">7</a>
242
+ <a href="#8" class="example-item example-item--8">8</a>
243
+ <a href="#9" class="example-item example-item--9">9</a>
244
+ <a href="#10" class="example-item example-item--10">10</a>
245
+ </div>
246
+ </div>
247
+
248
+ <div class="entry__item">
249
+ <h3>Scroll Snapping (proximity)</h3>
250
+ <p>Force scrolling to snap to slide not so strictly.</p>
251
+ <div class="overflow-slider example-container example-container-3-scroll-snapping-proximity">
252
+ <a href="#1" class="example-item example-item--1">1</a>
253
+ <a href="#2" class="example-item example-item--2">2</a>
254
+ <a href="#3" class="example-item example-item--3">3</a>
255
+ <a href="#4" class="example-item example-item--4">4</a>
256
+ <a href="#5" class="example-item example-item--5">5</a>
257
+ <a href="#6" class="example-item example-item--6">6</a>
258
+ <a href="#7" class="example-item example-item--7">7</a>
259
+ <a href="#8" class="example-item example-item--8">8</a>
260
+ <a href="#9" class="example-item example-item--9">9</a>
261
+ <a href="#10" class="example-item example-item--10">10</a>
262
+ </div>
263
+ </div>
264
+
265
+ <div class="entry__item">
266
+ <h3>Entrance and Exit Animations (experimental)</h3>
267
+ <p>Animate slides when they appear and disappear. Seem to only work on Chrome.</p>
268
+ <div class="overflow-slider example-container example-container-3-entrance-animation">
269
+ <a href="#1" class="example-item example-item--1">1</a>
270
+ <a href="#2" class="example-item example-item--2">2</a>
271
+ <a href="#3" class="example-item example-item--3">3</a>
272
+ <a href="#4" class="example-item example-item--4">4</a>
273
+ <a href="#5" class="example-item example-item--5">5</a>
274
+ <a href="#6" class="example-item example-item--6">6</a>
275
+ <a href="#7" class="example-item example-item--7">7</a>
276
+ <a href="#8" class="example-item example-item--8">8</a>
277
+ <a href="#9" class="example-item example-item--9">9</a>
278
+ <a href="#10" class="example-item example-item--10">10</a>
279
+ </div>
280
+ </div>
281
+
282
+ </section>
283
+
284
+ <section class="entry__section">
285
+
286
+ <h2>Real Life Usage</h2>
287
+
288
+ <div class="entry__item">
289
+ <h3>Filters</h3>
290
+ <p>Display filter buttons in one line that overflows when necessary.</p>
291
+ <div class="example-4-filters-wrapper">
292
+ <div class="example-4-filters-previous">
293
+ </div>
294
+ <div class="overflow-slider example-container-4-filters">
295
+ <a href="#1" class="example-filter">Development</a>
296
+ <a href="#2" class="example-filter">Design</a>
297
+ <a href="#3" class="example-filter">Marketing</a>
298
+ <a href="#4" class="example-filter">Sales</a>
299
+ <a href="#5" class="example-filter">Support</a>
300
+ <a href="#6" class="example-filter">Management</a>
301
+ <a href="#7" class="example-filter">HR</a>
302
+ <a href="#8" class="example-filter">Finance</a>
303
+ <a href="#9" class="example-filter">Legal</a>
304
+ <a href="#10" class="example-filter">Customer Service</a>
305
+ <a href="#11" class="example-filter">Operations</a>
306
+ <a href="#12" class="example-filter">Other</a>
307
+ </div>
308
+ <div class="example-4-filters-next"></div>
309
+ </div>
310
+ </div>
311
+
312
+ <div class="entry__item">
313
+ <h3>Grid On Desktop, Slider On Mobile</h3>
314
+ <p>Display contents differently for different sized screens.</p>
315
+ <div class="overflow-slider example-container-4-grid-or-slider">
316
+ <a href="#1" class="example-item example-item--1">1</a>
317
+ <a href="#2" class="example-item example-item--2">2</a>
318
+ <a href="#3" class="example-item example-item--3">3</a>
319
+ <a href="#4" class="example-item example-item--4">4</a>
320
+ <a href="#5" class="example-item example-item--5">5</a>
321
+ <a href="#6" class="example-item example-item--6">6</a>
322
+ <a href="#7" class="example-item example-item--7">7</a>
323
+ <a href="#8" class="example-item example-item--8">8</a>
324
+ </div>
325
+ </div>
326
+
327
+ <div class="entry__item">
328
+ <h3>Full Width Slider</h3>
329
+ <p>Allow slides to flow in full screen but center them accoring to your content. Uses FullWidthPlugin.</p>
330
+ <div class="example-container-4-full-width-wrapper">
331
+ <div class="overflow-slider example-container-4-full-width">
332
+ <a href="#1" class="example-item example-item--1">1</a>
333
+ <a href="#2" class="example-item example-item--2">2</a>
334
+ <a href="#3" class="example-item example-item--3">3</a>
335
+ <a href="#4" class="example-item example-item--4">4</a>
336
+ <a href="#5" class="example-item example-item--5">5</a>
337
+ <a href="#6" class="example-item example-item--6">6</a>
338
+ <a href="#7" class="example-item example-item--7">7</a>
339
+ <a href="#8" class="example-item example-item--8">8</a>
340
+ <a href="#9" class="example-item example-item--9">9</a>
341
+ <a href="#10" class="example-item example-item--10">10</a>
342
+ <a href="#11" class="example-item example-item--11">11</a>
343
+ <a href="#12" class="example-item example-item--12">12</a>
344
+ </div>
345
+ </div>
346
+ </div>
347
+
348
+ <div class="entry__item">
349
+ <h3>Synced Slider</h3>
350
+ <p>Sync slides from thumbnails. </p>
351
+ <div class="example-container-4-thumbnails-wrapper">
352
+ <div class="overflow-slider example-container-4-synced-main">
353
+ <a href="#1" class="example-item example-item--1">1</a>
354
+ <a href="#2" class="example-item example-item--2">2</a>
355
+ <a href="#3" class="example-item example-item--3">3</a>
356
+ <a href="#4" class="example-item example-item--4">4</a>
357
+ <a href="#5" class="example-item example-item--5">5</a>
358
+ <a href="#6" class="example-item example-item--6">6</a>
359
+ <a href="#7" class="example-item example-item--7">7</a>
360
+ <a href="#8" class="example-item example-item--8">8</a>
361
+ <a href="#9" class="example-item example-item--9">9</a>
362
+ <a href="#10" class="example-item example-item--10">10</a>
363
+ <a href="#11" class="example-item example-item--11">11</a>
364
+ <a href="#12" class="example-item example-item--12">12</a>
365
+ </div>
366
+ <div class="overflow-slider example-container-4-synced-thumbnails">
367
+ <button class="example-item example-item--1">1</button>
368
+ <button class="example-item example-item--2">2</button>
369
+ <button class="example-item example-item--3">3</button>
370
+ <button class="example-item example-item--4">4</button>
371
+ <button class="example-item example-item--5">5</button>
372
+ <button class="example-item example-item--6">6</button>
373
+ <button class="example-item example-item--7">7</button>
374
+ <button class="example-item example-item--8">8</button>
375
+ <button class="example-item example-item--9">9</button>
376
+ <button class="example-item example-item--10">10</button>
377
+ <button class="example-item example-item--11">11</button>
378
+ <button class="example-item example-item--12">12</button>
379
+ </div>
380
+ </div>
381
+ </div>
382
+
383
+ </section>
384
+
385
+ </div>
386
+ </article>
387
+ </main>
388
+ <div class="site-footer">
389
+ <p>
390
+ This is demo for the
391
+ <a href="https://github.com/evermade/overflow-slider">@evermade/overflow-slider</a>.
392
+ </p>
393
+ </div>
394
+ </div>
395
+ </body>
396
+ </html>
package/docs/index.html CHANGED
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en-US">
2
+ <html lang="en-US" dir="ltr">
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evermade/overflow-slider",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Accessible slider tha works with overflow: auto.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,7 @@ export default function details( slider: Slider) {
11
11
  let amountOfPages = 0;
12
12
  let currentPage = 1;
13
13
 
14
- if (slider.container.scrollWidth > slider.container.clientWidth) {
14
+ if ( Math.floor( slider.getInclusiveScrollWidth() ) > Math.floor( slider.getInclusiveClientWidth() ) ) {
15
15
  hasOverflow = true;
16
16
  }
17
17
 
@@ -19,14 +19,14 @@ export default function details( slider: Slider) {
19
19
 
20
20
  containerWidth = slider.container.offsetWidth;
21
21
 
22
- scrollableAreaWidth = slider.container.scrollWidth;
22
+ scrollableAreaWidth = slider.getInclusiveScrollWidth();
23
23
 
24
24
  amountOfPages = Math.ceil(scrollableAreaWidth / containerWidth);
25
25
 
26
- if (slider.container.scrollLeft >= 0) {
27
- currentPage = Math.floor(slider.container.scrollLeft / containerWidth);
26
+ if ( Math.floor( slider.getScrollLeft() ) >= 0) {
27
+ currentPage = Math.floor(slider.getScrollLeft() / containerWidth);
28
28
  // consider as last page if the scrollLeft + containerWidth is equal to scrollWidth
29
- if (slider.container.scrollLeft + containerWidth === scrollableAreaWidth) {
29
+ if (Math.floor( slider.getScrollLeft() + containerWidth ) === Math.floor( scrollableAreaWidth ) ) {
30
30
  currentPage = amountOfPages - 1;
31
31
  }
32
32
  }
@@ -23,6 +23,7 @@ export default function OverflowSlider (
23
23
  slidesSelector: ":scope > *",
24
24
  emulateScrollSnap: false,
25
25
  emulateScrollSnapMaxThreshold: 64,
26
+ rtl: false,
26
27
  };
27
28
 
28
29
  const sliderOptions = { ...defaults, ...options };