@evermade/overflow-slider 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,2 @@
1
+ /*! @evermade/overflow-slider 1.0.0 */
2
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).OverflowSlider={})}(this,(function(t){"use strict";function e(t,n=1){const o=`${t}-${n}`;return document.getElementById(o)?e(t,n+1):o}function n(t,n,o){let r,i={};function s(t=!1){const e=r.details,n=function(t){let e,n=!1,o=0,r=0,i=0,s=0,a=1;return t.container.scrollWidth>t.container.clientWidth&&(n=!0),o=Array.from(t.container.querySelectorAll(":scope > *")).length,r=t.container.offsetWidth,i=t.container.scrollWidth,s=Math.ceil(i/r),t.container.scrollLeft>=0&&(a=Math.floor(t.container.scrollLeft/r),t.container.scrollLeft+r===i&&(a=s-1)),e={hasOverflow:n,slideCount:o,containerWidth:r,scrollableAreaWidth:i,amountOfPages:s,currentPage:a},e}(r);r.details=n,t||function(t,e){const n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(let o of n)if(!1===e.hasOwnProperty(o)||t[o]!==e[o])return!1;return!0}(e,n)?t&&r.emit("detailsChanged"):r.emit("detailsChanged")}function a(){r.container.style.setProperty("--slider-container-width",`${r.details.containerWidth}px`),r.container.style.setProperty("--slider-scrollable-width",`${r.details.scrollableAreaWidth}px`),r.container.style.setProperty("--slider-slides-count",`${r.details.slideCount}`)}function l(){r.container.setAttribute("data-has-overflow",r.details.hasOverflow?"true":"false")}return r={emit:function(t){var e;i&&i[t]&&i[t].forEach((t=>{t(r)}));const n=null===(e=null==r?void 0:r.options)||void 0===e?void 0:e[t];"function"==typeof n&&n(r)},moveToDirection:function(t="prev"){const e=r.options.scrollStrategy,n=r.container.scrollLeft,o=r.container.getBoundingClientRect(),i=r.container.offsetWidth;let s=n;if("prev"===t?s=Math.max(0,n-r.container.offsetWidth):"next"===t&&(s=Math.min(r.container.scrollWidth,n+r.container.offsetWidth)),"fullSlide"===e){let e=null;const a=Array.from(r.container.querySelectorAll(":scope > *"));let l=0;if(a.length>1){const t=a[0].getBoundingClientRect();l=a[1].getBoundingClientRect().left-t.right}if(e="prev"===t?Math.max(0,s-l):Math.min(r.container.scrollWidth,s+l),"next"===t){let t=!1;for(let r of a){const i=r.getBoundingClientRect(),a=i.left-o.left+n,l=a+i.width;if(a<s&&l>s){e=a,t=!0;break}}t||(e=Math.min(s,r.container.scrollWidth-r.container.offsetWidth)),e&&e>n&&(s=e)}else{let t=!1;for(let r of a){const s=r.getBoundingClientRect(),a=s.left-o.left+n,l=a+s.width;if(a<n&&l>n){e=l-i,t=!0;break}}t||(e=Math.max(0,n-i)),e&&e<n&&(s=e)}}r.container.style.scrollBehavior="smooth",r.container.scrollLeft=s,setTimeout((()=>r.container.style.scrollBehavior=""),50)},on:function(t,e){i[t]||(i[t]=[]),i[t].push(e)},options:n},function(){r.container=t;let n=t.getAttribute("id");null===n&&(n=e("overflow-slider"),t.setAttribute("id",n)),s(!0),r.on("contentsChanged",(()=>s())),r.on("containerSizeChanged",(()=>s()));let i=0;if(r.on("scroll",(()=>{i&&window.cancelAnimationFrame(i),i=window.requestAnimationFrame((()=>{s()}))})),function(){new MutationObserver((()=>r.emit("contentsChanged"))).observe(r.container,{childList:!0});new ResizeObserver((()=>r.emit("containerSizeChanged"))).observe(r.container),r.container.addEventListener("scroll",(()=>r.emit("scroll")));let t=!1;r.container.addEventListener("mousedown",(()=>{t=!0})),r.container.addEventListener("touchstart",(()=>{t=!0}),{passive:!0}),r.container.addEventListener("focusin",(e=>{if(!t){let t=e.target;for(;t.parentElement!==r.container&&t.parentElement;)t=t.parentElement;!function(t){const e=t.getBoundingClientRect(),n=r.container.getBoundingClientRect(),o=r.container.offsetWidth,i=r.container.scrollLeft,s=e.left-n.left+i,a=s+e.width;let l=null;s<i?l=s:a>i+o&&(l=a-o);l&&(r.container.style.scrollSnapType="none",r.container.scrollLeft=l)}(t)}t=!1}))}(),l(),a(),o)for(const t of o)t(r);r.on("detailsChanged",(()=>{l(),a()})),r.emit("created")}(),r}const o={skipList:"Skip list"},r={skipLink:"screen-reader-text",skipLinkTarget:"overflow-slider__skip-link-target"};const i={buttonPrevious:"Previous items",buttonNext:"Next items"},s={prev:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.6 3.4l-7.6 7.6 7.6 7.6 1.4-1.4-5-5h12.6v-2h-12.6l5-5z"/></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.4 3.4l-1.4 1.4 5 5h-12.6v2h12.6l-5 5 1.4 1.4 7.6-7.6z"/></svg>'},a={navContainer:"overflow-slider__arrows",prevButton:"overflow-slider__arrows-button overflow-slider__arrows-button--prev",nextButton:"overflow-slider__arrows-button overflow-slider__arrows-button--next"};const l={scrollIndicator:"overflow-slider__scroll-indicator",scrollIndicatorBar:"overflow-slider__scroll-indicator-bar",scrollIndicatorButton:"overflow-slider__scroll-indicator-button"};const c={dotDescription:"Page %d of %d"},d={dotsContainer:"overflow-slider__dots",dotsItem:"overflow-slider__dot-item"};t.ArrowsPlugin=function(t){return e=>{var n,o,r,l;const c={texts:Object.assign(Object.assign({},i),(null==t?void 0:t.texts)||[]),icons:Object.assign(Object.assign({},s),(null==t?void 0:t.icons)||[]),classNames:Object.assign(Object.assign({},a),(null==t?void 0:t.classNames)||[]),container:null!==(n=null==t?void 0:t.container)&&void 0!==n?n:null},d=document.createElement("div");d.classList.add(c.classNames.navContainer);const u=document.createElement("button");u.setAttribute("class",c.classNames.prevButton),u.setAttribute("type","button"),u.setAttribute("aria-label",c.texts.buttonPrevious),u.setAttribute("aria-controls",null!==(o=e.container.getAttribute("id"))&&void 0!==o?o:""),u.setAttribute("data-type","prev"),u.innerHTML=c.icons.prev,u.addEventListener("click",(()=>e.moveToDirection("prev")));const f=document.createElement("button");f.setAttribute("class",c.classNames.nextButton),f.setAttribute("type","button"),f.setAttribute("aria-label",c.texts.buttonNext),f.setAttribute("aria-controls",null!==(r=e.container.getAttribute("id"))&&void 0!==r?r:""),f.setAttribute("data-type","next"),f.innerHTML=c.icons.next,f.addEventListener("click",(()=>e.moveToDirection("next"))),d.appendChild(u),d.appendChild(f);const v=()=>{const t=e.container.scrollLeft,n=e.container.scrollWidth,o=e.container.clientWidth;0===t?u.setAttribute("data-has-content","false"):u.setAttribute("data-has-content","true"),t+o>=n?f.setAttribute("data-has-content","false"):f.setAttribute("data-has-content","true")};c.container?c.container.appendChild(d):null===(l=e.container.parentNode)||void 0===l||l.insertBefore(d,e.container.nextSibling),v(),e.on("scroll",v),e.on("contentsChanged",v),e.on("containerSizeChanged",v)}},t.DotsPlugin=function(t){return e=>{var n,o;const r={texts:Object.assign(Object.assign({},c),(null==t?void 0:t.texts)||[]),classNames:Object.assign(Object.assign({},d),(null==t?void 0:t.classNames)||[]),container:null!==(n=null==t?void 0:t.container)&&void 0!==n?n:null},i=document.createElement("div");i.classList.add(r.classNames.dotsContainer);let s=null;const a=()=>{i.setAttribute("data-has-content",e.details.hasOverflow.toString()),i.innerHTML="";const t=document.createElement("ul"),n=e.details.amountOfPages,o=e.details.currentPage;if(!(n<=1)){for(let e=0;e<n;e++){const a=document.createElement("li"),c=document.createElement("button");c.setAttribute("type","button"),c.setAttribute("class",r.classNames.dotsItem),c.setAttribute("aria-label",r.texts.dotDescription.replace("%d",(e+1).toString()).replace("%d",n.toString())),c.setAttribute("aria-pressed",(e===o).toString()),c.setAttribute("data-page",(e+1).toString()),a.appendChild(c),t.appendChild(a),c.addEventListener("click",(()=>l(e+1))),c.addEventListener("focus",(()=>s=e+1)),c.addEventListener("keydown",(t=>{var e;const o=i.querySelector('[aria-pressed="true"]');if(!o)return;const r=parseInt(null!==(e=o.getAttribute("data-page"))&&void 0!==e?e:"1");if("ArrowLeft"===t.key){const t=r-1;if(t>0){const e=i.querySelector(`[data-page="${t}"]`);e&&e.focus(),l(t)}}if("ArrowRight"===t.key){const t=r+1;if(t<=n){const e=i.querySelector(`[data-page="${t}"]`);e&&e.focus(),l(t)}}}))}if(i.appendChild(t),s){const t=i.querySelector(`[data-page="${s}"]`);t&&t.focus()}}},l=t=>{const n=e.details.containerWidth*(t-1);e.container.style.scrollBehavior=e.options.scrollBehavior,e.container.style.scrollSnapType="none",e.container.scrollLeft=n,e.container.style.scrollBehavior="",e.container.style.scrollSnapType=""};a(),r.container?r.container.appendChild(i):null===(o=e.container.parentNode)||void 0===o||o.insertBefore(i,e.container.nextSibling),e.on("detailsChanged",(()=>{a()}))}},t.DragScrollingPlugin=function(t){var e;const n=null!==(e=null==t?void 0:t.draggedDistanceThatPreventsClick)&&void 0!==e?e:20;return t=>{let e=!1,o=0,r=0;const i=()=>t.details.hasOverflow;t.container.addEventListener("mousedown",(n=>{i()&&(e=!0,o=n.pageX-t.container.offsetLeft,r=t.container.scrollLeft,t.container.style.cursor="grabbing",t.container.style.scrollSnapType="none")})),window.addEventListener("mouseup",(()=>{i()&&(e=!1,t.container.style.cursor="",t.container.style.scrollSnapType="",setTimeout((()=>{t.container.querySelectorAll(":scope > *").forEach((t=>{t.style.pointerEvents=""}))}),50))})),window.addEventListener("mousemove",(s=>{if(!i())return;if(!e)return;s.preventDefault();const a=s.pageX-t.container.offsetLeft-o;t.container.scrollLeft=r-a;const l=Math.abs(a),c=t.container.querySelectorAll(":scope > *"),d=l>n?"none":"";c.forEach((t=>{t.style.pointerEvents=d}))}))}},t.OverflowSlider=function(t,e,o){try{if(!(t instanceof Element))throw new Error("Container must be HTML element, found "+typeof t);const r={scrollBehavior:"smooth",scrollStrategy:"fullSlide"},i=Object.assign(Object.assign({},r),e);return window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(i.scrollBehavior="auto"),n(t,i,o)}catch(t){console.error(t)}},t.ScrollIndicatorPlugin=function(t){return e=>{var n,o,r;const i={classNames:Object.assign(Object.assign({},l),(null==t?void 0:t.classNames)||[]),container:null!==(n=null==t?void 0:t.container)&&void 0!==n?n:null},s=document.createElement("div");s.setAttribute("class",i.classNames.scrollIndicator),s.setAttribute("tabindex","0"),s.setAttribute("role","scrollbar"),s.setAttribute("aria-controls",null!==(o=e.container.getAttribute("id"))&&void 0!==o?o:""),s.setAttribute("aria-orientation","horizontal"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuenow","0");const a=document.createElement("div");a.setAttribute("class",i.classNames.scrollIndicatorBar);const c=document.createElement("div");c.setAttribute("class",i.classNames.scrollIndicatorButton),c.setAttribute("data-is-grabbed","false"),a.appendChild(c),s.appendChild(a);const d=()=>{s.setAttribute("data-has-overflow",e.details.hasOverflow.toString())};d();const u=()=>{const t=e.container.offsetWidth/e.container.scrollWidth;return e.container.scrollLeft*t};let f=0;const v=()=>{f&&window.cancelAnimationFrame(f),f=window.requestAnimationFrame((()=>{const t=e.container.offsetWidth/e.container.scrollWidth*100,n=u();c.style.width=`${t}%`,c.style.transform=`translateX(${n}px)`;const o=e.container.scrollLeft/(e.container.scrollWidth-e.container.offsetWidth)*100;s.setAttribute("aria-valuenow",Math.round(Number.isNaN(o)?0:o).toString())}))};i.container?i.container.appendChild(s):null===(r=e.container.parentNode)||void 0===r||r.insertBefore(s,e.container.nextSibling),v(),e.on("scroll",v),e.on("contentsChanged",v),e.on("containerSizeChanged",v),e.on("detailsChanged",d),s.addEventListener("keydown",(t=>{"ArrowLeft"===t.key?e.moveToDirection("prev"):"ArrowRight"===t.key&&e.moveToDirection("next")})),s.addEventListener("click",(t=>{const n=c.offsetWidth,o=u(),r=o+n,i=t.pageX-s.offsetLeft;i<o?e.moveToDirection("prev"):i>r&&e.moveToDirection("next")}));let p=!1,h=0,b=0;c.addEventListener("mousedown",(t=>{p=!0,h=t.pageX-s.offsetLeft,b=e.container.scrollLeft,c.style.cursor="grabbing",e.container.style.scrollSnapType="none",c.setAttribute("data-is-grabbed","true"),t.preventDefault(),t.stopPropagation()})),window.addEventListener("mouseup",(()=>{p=!1,c.style.cursor="",e.container.style.scrollSnapType="",c.setAttribute("data-is-grabbed","false")})),window.addEventListener("mousemove",(t=>{if(!p)return;t.preventDefault();const n=t.pageX-s.offsetLeft,o=e.container.scrollWidth/s.offsetWidth,r=(n-h)*o;e.container.scrollLeft=b+r}))}},t.SkipLinksPlugin=function(t){return n=>{var i,s,a,l,c,d;const u={texts:Object.assign(Object.assign({},o),(null==t?void 0:t.texts)||[]),classNames:Object.assign(Object.assign({},r),(null==t?void 0:t.classNames)||[]),containerBefore:null!==(i=null==t?void 0:t.containerAfter)&&void 0!==i?i:null,containerAfter:null!==(s=null==t?void 0:t.containerAfter)&&void 0!==s?s:null},f=e("overflow-slider-skip"),v=document.createElement("a");v.setAttribute("href",`#${f}`),v.textContent=u.texts.skipList,v.classList.add(u.classNames.skipLink);const p=document.createElement("div");p.setAttribute("id",f),p.setAttribute("tabindex","-1"),u.containerBefore?null===(a=u.containerBefore.parentNode)||void 0===a||a.insertBefore(v,u.containerBefore):null===(l=n.container.parentNode)||void 0===l||l.insertBefore(v,n.container),u.containerAfter?null===(c=u.containerAfter.parentNode)||void 0===c||c.insertBefore(p,u.containerAfter.nextSibling):null===(d=n.container.parentNode)||void 0===d||d.insertBefore(p,n.container.nextSibling)}},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -0,0 +1 @@
1
+ .overflow-slider{display:grid;grid-auto-flow:column;grid-template-columns:max-content;max-width:-moz-max-content;max-width:max-content;overflow:auto;width:100%}.overflow-slider::-webkit-scrollbar{display:none}.overflow-slider>*{outline-offset:-2px;scroll-snap-align:start}:root{--overflow-slider-arrows-size:1.5rem;--overflow-slider-arrows-gap:.5rem;--overflow-slider-arrows-inactive-opacity:0.5}.overflow-slider__arrows{display:flex;gap:var(--overflow-slider-arrows-gap)}.overflow-slider__arrows-button{align-items:center;cursor:pointer;display:flex;outline-offset:-2px}.overflow-slider__arrows-button svg{height:var(--overflow-slider-arrows-size);width:var(--overflow-slider-arrows-size)}.overflow-slider__arrows-button[data-has-content=false]{opacity:var(--overflow-slider-arrows-inactive-opacity)}:root{--overflow-slider-dots-gap:0.5rem;--overflow-slider-dot-size:0.75rem;--overflow-slider-dot-inactive-color:rgba(0,0,0,.1);--overflow-slider-dot-active-color:rgba(0,0,0,.8)}.overflow-slider__dots{align-items:center;display:flex;justify-content:center}.overflow-slider__dots ul{display:flex;flex-wrap:wrap;gap:var(--overflow-slider-dots-gap);list-style:none;margin:0;padding:0}.overflow-slider__dots li{line-height:0;margin:0;padding:0}.overflow-slider__dot-item{background:var(--overflow-slider-dot-inactive-color);border-radius:50%;cursor:pointer;height:var(--overflow-slider-dot-size);margin:0;outline-offset:2px;padding:0;position:relative;width:var(--overflow-slider-dot-size)}.overflow-slider__dot-item:after{bottom:calc(var(--overflow-slider-dots-gap)*-1);content:"";display:block;left:calc(var(--overflow-slider-dots-gap)*-1);position:absolute;right:calc(var(--overflow-slider-dots-gap)*-1);top:calc(var(--overflow-slider-dots-gap)*-1)}.overflow-slider__dot-item:focus,.overflow-slider__dot-item:hover,.overflow-slider__dot-item[aria-pressed=true]{background:var(--overflow-slider-dot-active-color)}:root{--overflow-slider-scroll-indicator-button-height:4px;--overflow-slider-scroll-indicator-padding:1rem;--overflow-slider-scroll-indicator-button-color:rgba(0,0,0,.75);--overflow-slider-scroll-indicator-bar-color:rgba(0,0,0,.25)}.overflow-slider__scroll-indicator{cursor:pointer;outline:0;padding-block:var(--overflow-slider-scroll-indicator-padding);position:relative;width:100%}.overflow-slider__scroll-indicator[data-has-overflow=false]{display:none}.overflow-slider__scroll-indicator:focus-visible .overflow-slider__scroll-indicator-button{outline:2px solid;outline-offset:2px}.overflow-slider__scroll-indicator-bar{background:var(--overflow-slider-scroll-indicator-bar-color);border-radius:3px;height:2px;left:0;position:absolute;top:50%;transform:translateY(-50%);width:100%}.overflow-slider__scroll-indicator-button{background:var(--overflow-slider-scroll-indicator-button-color);border-radius:3px;cursor:grab;height:var(--overflow-slider-scroll-indicator-button-height);left:0;position:absolute;top:calc(50% - var(--overflow-slider-scroll-indicator-button-height)/2)}.overflow-slider__scroll-indicator-button:hover,.overflow-slider__scroll-indicator-button[data-is-grabbed=true]{--overflow-slider-scroll-indicator-button-height:6px}.overflow-slider__scroll-indicator-button:after{bottom:calc(var(--overflow-slider-scroll-indicator-padding)*-1);content:"";display:block;position:absolute;top:calc(var(--overflow-slider-scroll-indicator-padding)*-1);width:100%}
@@ -0,0 +1,513 @@
1
+ /* ===========================================================================
2
+ Base
3
+ =========================================================================== */
4
+
5
+ :root {
6
+ --slide-gap: 1rem;
7
+
8
+ --color-primary: #f04d37;
9
+ --color-primary-dark: #d13c26;
10
+
11
+ --color-grey-50: hsla(0, 0%, 0%, 0.05);
12
+ --color-grey-100: hsla(0, 0%, 0%, 0.1);
13
+ --color-grey-600: hsla(0, 0%, 0%, 0.6);
14
+ --color-grey-700: hsla(0, 0%, 0%, 0.7);
15
+ --color-grey-800: hsla(0, 0%, 0%, 0.8);
16
+
17
+ --color-white: #fff;
18
+ --color-black: #000;
19
+
20
+ --font-family-sans: -apple-system, "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica", "Arial", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
21
+ --font-family-mono: "Monaco", "Consolas", "Andale Mono", "DejaVu Sans Mono", monospace;
22
+
23
+ --font-size-sm: 0.875rem;
24
+ --font-size-md: 1rem;
25
+ --font-size-lg: 1.125rem;
26
+ --font-size-xl: 1.25rem;
27
+
28
+ --font-size-body: var(--font-size-lg);
29
+
30
+ --line-height-sm: 1.25;
31
+ --line-height-md: 1.5;
32
+
33
+ --max-width-md: 42rem;
34
+ --max-width-lg: 60rem;
35
+ --max-width-xl: 72rem;
36
+
37
+ --transition-duration-md: 0.25s;
38
+ }
39
+
40
+ /* Reset */
41
+ body,
42
+ h1,
43
+ h2,
44
+ h3,
45
+ h4,
46
+ h5,
47
+ h6,
48
+ p,
49
+ li,
50
+ figure,
51
+ figcaption,
52
+ blockquote,
53
+ dl,
54
+ dd {
55
+ margin: 0;
56
+ }
57
+
58
+ [hidden] {
59
+ display: none !important;
60
+ }
61
+
62
+ /* Box sizing */
63
+ html {
64
+ box-sizing: border-box;
65
+ }
66
+
67
+ /**
68
+ * Inherit box-sizing to make it easier to change the property
69
+ * for components that leverage other behavior.
70
+ */
71
+
72
+ *,
73
+ *::before,
74
+ *::after {
75
+ box-sizing: inherit;
76
+ }
77
+
78
+ /* Base styles */
79
+ html {
80
+ font-size: 100%;
81
+ }
82
+
83
+ body,
84
+ button,
85
+ input,
86
+ optgroup,
87
+ select,
88
+ textarea {
89
+ color: var(--color-grey-800);
90
+ font-family: var(--font-family-sans);
91
+ font-size: var(--font-size-body);
92
+ line-height: var(--line-height-md);
93
+ word-wrap: break-word;
94
+ }
95
+
96
+ body {
97
+ background-color: #f7f7f7;
98
+ }
99
+
100
+ a {
101
+ color: var(--color-primary-dark);
102
+
103
+ /* transition: all var(--transition-duration-md) ease-in-out; */
104
+ }
105
+
106
+ a:hover,
107
+ a:focus-visible,
108
+ a:active {
109
+ color: var(--color-primary);
110
+ }
111
+
112
+ :focus-visible {
113
+ outline: 2px solid var(--color-primary);
114
+ }
115
+
116
+ a:hover,
117
+ a:active {
118
+ outline: 0;
119
+ }
120
+
121
+ button,
122
+ .button {
123
+ background: var(--color-primary);
124
+ border: 0;
125
+ border-radius: 0;
126
+ color: var(--color-white);
127
+ display: inline-block;
128
+ font-weight: 500;
129
+ padding: 0.5rem 1rem;
130
+ text-decoration: none;
131
+ }
132
+
133
+ button:hover,
134
+ .button:hover,
135
+ button:active,
136
+ .button:active,
137
+ button:focus,
138
+ .button:focus {
139
+ background-color: var(--color-primary-dark);
140
+ color: var(--color-white);
141
+ }
142
+
143
+ .actions {
144
+ margin-block: 2rem;
145
+ display: flex;
146
+ flex-wrap: wrap;
147
+ gap: .5rem;
148
+ }
149
+
150
+ .code-example {
151
+ display: block;
152
+ background: var(--color-grey-800);
153
+ font-family: var(--font-family-mono);
154
+ color: var(--color-white);
155
+ padding: 1.5rem;
156
+ font-size: 0.9375rem;
157
+ line-height: 1.5;
158
+ overflow-x: auto;
159
+ border-radius: 3px;
160
+ margin-top: 2rem;
161
+
162
+ &:not(:last-child) {
163
+ margin-bottom: 1rem;
164
+ }
165
+
166
+ /* Keep original line breaks */
167
+ white-space: pre-wrap;
168
+
169
+ /* Set tab size */
170
+ tab-size: 4;
171
+ }
172
+
173
+ /* Animations */
174
+ @keyframes fancy-animate-in {
175
+ 0% {
176
+ opacity: 0;
177
+ transform: translateY(1rem) scale(0.85);
178
+ }
179
+
180
+ 100% {
181
+ opacity: 1;
182
+ transform: translateY(0) scale(1);
183
+ }
184
+ }
185
+
186
+ @keyframes fancy-animate-out {
187
+ 0% {
188
+ opacity: 1;
189
+ transform: translateY(0) scale(1);
190
+ }
191
+
192
+ 100% {
193
+ opacity: 0;
194
+ transform: translateY(1rem) scale(0.85);
195
+ }
196
+ }
197
+
198
+
199
+ /* Icons */
200
+ .icon {
201
+ fill: currentcolor;
202
+ display: inline-block;
203
+ height: 1em;
204
+ pointer-events: none;
205
+ position: relative;
206
+ top: -0.0625em;
207
+ vertical-align: middle;
208
+ width: 1em;
209
+ }
210
+
211
+ /* Components */
212
+ .site-main,
213
+ .site-footer {
214
+ margin-left: auto;
215
+ margin-right: auto;
216
+ max-width: var(--max-width-lg);
217
+ padding: 0 1.5rem 3rem;
218
+ }
219
+
220
+ .site-footer {
221
+ padding-top: 0;
222
+ font-size: 0.9375rem;
223
+ }
224
+
225
+ .entry__content > * {
226
+ margin-left: 0;
227
+ margin-right: auto;
228
+ max-width: var(--max-width-lg);
229
+ margin-top: 1rem;
230
+ }
231
+
232
+ .entry__content h1 + * {
233
+ margin-top: 1.5rem;
234
+ }
235
+
236
+ .entry__content > *:first-child {
237
+ margin-top: 0;
238
+ }
239
+
240
+ .entry__content > *:last-child {
241
+ margin-bottom: 0;
242
+ }
243
+
244
+ .entry__section + .entry__section {
245
+ margin-top: 3rem;
246
+ }
247
+
248
+ .entry__section h2 {
249
+ margin-bottom: 1.5rem;
250
+ }
251
+
252
+ .entry__item + .entry__item {
253
+ margin-top: 3rem;
254
+ }
255
+
256
+ .entry__item h3 {
257
+ margin-bottom: .25rem;
258
+ }
259
+
260
+ body {
261
+ counter-reset: section; /* Initialize the main counter */
262
+ }
263
+
264
+ h2 {
265
+ counter-reset: subsection; /* Reset the subsection counter for each new h2 */
266
+ counter-increment: section; /* Increment the main counter for each h2 */
267
+ }
268
+
269
+ h2:before {
270
+ content: counter(section) ". "; /* Display the counter before the h2 content */
271
+ }
272
+
273
+ h3 {
274
+ counter-increment: subsection; /* Increment the subsection counter for each h3 */
275
+ }
276
+
277
+ h3:before {
278
+ content: counter(section) "." counter(subsection) " "; /* Display the combined counters before the h3 content */
279
+ }
280
+
281
+ /* Utilities */
282
+ .screen-reader-text {
283
+ border: 0;
284
+ clip: rect(1px, 1px, 1px, 1px);
285
+ clip-path: inset(50%);
286
+ height: 1px;
287
+ margin: -1px;
288
+ overflow: hidden;
289
+ padding: 0;
290
+ position: absolute;
291
+ width: 1px;
292
+ word-wrap: normal !important;
293
+ }
294
+
295
+ .screen-reader-text:focus {
296
+ background-color: var(--color-primary);
297
+ clip: auto !important;
298
+ clip-path: none;
299
+ color: var(--color-white);
300
+ display: block;
301
+ font-size: var(--font-size-md);
302
+ font-weight: 700;
303
+ height: auto;
304
+ outline-offset: -2px;
305
+ padding: 1rem 1.5rem;
306
+ text-decoration: none;
307
+ width: fit-content;
308
+ z-index: 100000;
309
+ position: relative;
310
+ margin-top: 1rem;
311
+ margin-bottom: 1rem;
312
+ }
313
+
314
+ .overflow-hidden {
315
+ overflow: hidden;
316
+ }
317
+
318
+ /* ===========================================================================
319
+ Menu
320
+ =========================================================================== */
321
+
322
+ .site-header__inner {
323
+ display: flex;
324
+ flex-direction: column;
325
+ justify-content: flex-start;
326
+ align-items: flex-start;
327
+ gap: 1rem;
328
+ flex-wrap: wrap;
329
+ margin-left: auto;
330
+ margin-right: auto;
331
+ max-width: var(--max-width-lg);
332
+ padding: 1.5rem 1.5rem;
333
+ }
334
+
335
+ @media (min-width: 768px) {
336
+ .site-header__inner {
337
+ gap: 1.5rem;
338
+ }
339
+ }
340
+
341
+ .site-branding,
342
+ .site-branding * {
343
+ line-height: 0;
344
+ display: block;
345
+ }
346
+
347
+ .site-branding .site-logo {
348
+ display: flex;
349
+ align-items: center;
350
+ gap: .75rem;
351
+ text-decoration: none;
352
+ }
353
+
354
+ .site-logo svg {
355
+ width: 32px;
356
+ height: 32px;
357
+ }
358
+
359
+ .site-logo span {
360
+ font-size: 14px;
361
+ text-decoration: none;
362
+ color: var(--color-grey-800);
363
+ }
364
+
365
+ /* ===========================================================================
366
+ Content
367
+ =========================================================================== */
368
+
369
+ .example-container {
370
+ gap: var(--slide-gap);
371
+ margin-top: 1.5rem;
372
+ }
373
+
374
+ .example-item {
375
+ aspect-ratio: 3/4;
376
+ width: 240px;
377
+ max-width: 90vw;
378
+ background: var(--color-grey-100);
379
+ border-radius: 3px;
380
+ outline-offset: -2px;
381
+ display: flex;
382
+ align-items: center;
383
+ justify-content: center;
384
+ font-size: 3rem;
385
+ font-weight: 700;
386
+ color: #fff;
387
+ text-decoration: none;
388
+ }
389
+
390
+ .example-item:hover,
391
+ .example-item:focus {
392
+ color: #fff;
393
+ }
394
+
395
+ .example-item--1 {
396
+ background: hsla(0, 0%, 0%, 0.1);
397
+ }
398
+
399
+ .example-item--2 {
400
+ background: hsla(0, 0%, 0%, 0.125);
401
+ }
402
+
403
+ .example-item--3 {
404
+ background: hsla(0, 0%, 0%, 0.15);
405
+ }
406
+
407
+ .example-item--4 {
408
+ background: hsla(0, 0%, 0%, 0.175);
409
+ }
410
+
411
+ .example-item--5 {
412
+ background: hsla(0, 0%, 0%, 0.2);
413
+ }
414
+
415
+ .example-item--6 {
416
+ background: hsla(0, 0%, 0%, 0.225);
417
+ }
418
+
419
+ .example-item--7 {
420
+ background: hsla(0, 0%, 0%, 0.25);
421
+ }
422
+
423
+ .example-item--8 {
424
+ background: hsla(0, 0%, 0%, 0.275);
425
+ }
426
+
427
+ .example-item--9 {
428
+ background: hsla(0, 0%, 0%, 0.3);
429
+ }
430
+
431
+ .example-item--10 {
432
+ background: hsla(0, 0%, 0%, 0.325);
433
+ }
434
+
435
+ .example-item--11 {
436
+ background: hsla(0, 0%, 0%, 0.35);
437
+ }
438
+
439
+ .example-item--12 {
440
+ background: hsla(0, 0%, 0%, 0.375);
441
+ }
442
+
443
+ .example-item--13 {
444
+ background: hsla(0, 0%, 0%, 0.4);
445
+ }
446
+
447
+ .example-container-2-perfect-fit {
448
+ grid-template-columns: repeat(var(--slider-slides-count, 1), calc( ( var(--slider-container-width, 900px) / 3 ) - 2/3 * var(--slide-gap, 1rem)));
449
+ }
450
+ .example-container-2-perfect-fit .example-item {
451
+ aspect-ratio: 1/1;
452
+ width: 100%;
453
+ }
454
+
455
+ .example-container-2-varying-widths .example-item {
456
+ aspect-ratio: unset;
457
+ height: 300px;
458
+ }
459
+
460
+ .example-container-2-varying-widths .example-item--1 {
461
+ width: 120px;
462
+ }
463
+ .example-container-2-varying-widths .example-item--2 {
464
+ width: 200px;
465
+ }
466
+ .example-container-2-varying-widths .example-item--3 {
467
+ width: 90px;
468
+ }
469
+ .example-container-2-varying-widths .example-item--4 {
470
+ width: 4800px;
471
+ }
472
+ .example-container-2-varying-widths .example-item--5 {
473
+ width: 170px;
474
+ }
475
+ .example-container-2-varying-widths .example-item--6 {
476
+ width: 100px;
477
+ }
478
+ .example-container-2-varying-widths .example-item--8 {
479
+ width: 280px;
480
+ }
481
+
482
+ .example-container-3-scroll-snapping-mandatory {
483
+ scroll-snap-type: x mandatory;
484
+ }
485
+ .example-container-3-scroll-snapping-proximity {
486
+ scroll-snap-type: x proximity;
487
+ }
488
+
489
+ .overflow-slider__dots {
490
+ margin-top: 1.5rem;
491
+ }
492
+
493
+ .overflow-slider__arrows {
494
+ margin-top: 1.5rem;
495
+ }
496
+
497
+ .overflow-slider__scroll-indicator {
498
+ margin-top: 1rem;
499
+ }
500
+
501
+ .overflow-slider__arrows-button {
502
+ background: transparent;
503
+ padding: 0;
504
+ }
505
+ .overflow-slider__arrows-button:hover,
506
+ .overflow-slider__arrows-button:focus {
507
+ background: transparent !important;
508
+ }
509
+ .overflow-slider__arrows-button svg {
510
+ fill: var(--color-grey-800);
511
+ width: 1.625rem !important;
512
+ height: 1.625rem !important;
513
+ }
@@ -0,0 +1,113 @@
1
+ import {
2
+ OverflowSlider,
3
+ DragScrollingPlugin,
4
+ SkipLinksPlugin,
5
+ ArrowsPlugin,
6
+ ScrollIndicatorPlugin,
7
+ DotsPlugin
8
+ } from '../dist/overflow-slider.esm.js';
9
+
10
+ (function () {
11
+ const init = () => {
12
+
13
+ const example1CSS = new OverflowSlider(
14
+ document.querySelector( '.example-container-1-css' ),
15
+ );
16
+ console.log( '1-css', example1CSS );
17
+
18
+ const example1DragScrolling = new OverflowSlider(
19
+ document.querySelector( '.example-container-1-drag-scrolling' ),
20
+ {},
21
+ [
22
+ DragScrollingPlugin(),
23
+ SkipLinksPlugin(),
24
+ ]
25
+ );
26
+ console.log( '1-drag-scrolling', example1DragScrolling );
27
+
28
+ const example1Arrows = new OverflowSlider(
29
+ document.querySelector( '.example-container-1-arrows' ),
30
+ {},
31
+ [
32
+ DragScrollingPlugin(),
33
+ SkipLinksPlugin(),
34
+ ArrowsPlugin(),
35
+ ]
36
+ );
37
+ console.log( '1-arrows', example1Arrows );
38
+
39
+ const example1ScrollIndicator = new OverflowSlider(
40
+ document.querySelector( '.example-container-1-scroll-indicator' ),
41
+ {},
42
+ [
43
+ DragScrollingPlugin(),
44
+ SkipLinksPlugin(),
45
+ ScrollIndicatorPlugin(),
46
+ ]
47
+ );
48
+ console.log( '1-scroll-indicator', example1ScrollIndicator );
49
+
50
+ const example1Dots = new OverflowSlider(
51
+ document.querySelector( '.example-container-1-dots' ),
52
+ {},
53
+ [
54
+ DragScrollingPlugin(),
55
+ SkipLinksPlugin(),
56
+ DotsPlugin(),
57
+ ]
58
+ );
59
+ console.log( '1-dots', example1Dots );
60
+
61
+ const example2PerfectFit = new OverflowSlider(
62
+ document.querySelector( '.example-container-2-perfect-fit' ),
63
+ {},
64
+ [
65
+ DragScrollingPlugin(),
66
+ ScrollIndicatorPlugin(),
67
+ ]
68
+ );
69
+ console.log( '2-perfect-fit', example2PerfectFit );
70
+
71
+ const example2VaryingWidths = new OverflowSlider(
72
+ document.querySelector( '.example-container-2-varying-widths' ),
73
+ {},
74
+ [
75
+ DragScrollingPlugin(),
76
+ ScrollIndicatorPlugin(),
77
+ ]
78
+ );
79
+ console.log( '2-varying-widths', example2VaryingWidths );
80
+
81
+ const example2OnlyFewSlides = new OverflowSlider(
82
+ document.querySelector( '.example-container-2-only-few-slides' ),
83
+ {},
84
+ [
85
+ DragScrollingPlugin(),
86
+ ScrollIndicatorPlugin(),
87
+ ]
88
+ );
89
+ console.log( '2-only-few-slides', example2OnlyFewSlides );
90
+
91
+ const example3ScrollSnappingMandatory = new OverflowSlider(
92
+ document.querySelector( '.example-container-3-scroll-snapping-mandatory' ),
93
+ {},
94
+ [
95
+ DragScrollingPlugin(),
96
+ ScrollIndicatorPlugin(),
97
+ ]
98
+ );
99
+ console.log( '3-scroll-snapping-mandatory', example3ScrollSnappingMandatory );
100
+
101
+ const example3ScrollSnappingProximity = new OverflowSlider(
102
+ document.querySelector( '.example-container-3-scroll-snapping-proximity' ),
103
+ {},
104
+ [
105
+ DragScrollingPlugin(),
106
+ ScrollIndicatorPlugin(),
107
+ ]
108
+ );
109
+ console.log( '3-scroll-snapping-proximity', example3ScrollSnappingProximity );
110
+ };
111
+
112
+ init();
113
+ })();
@@ -0,0 +1 @@
1
+ .overflow-slider{display:grid;grid-auto-flow:column;grid-template-columns:max-content;max-width:-moz-max-content;max-width:max-content;overflow:auto;width:100%}.overflow-slider::-webkit-scrollbar{display:none}.overflow-slider>*{outline-offset:-2px;scroll-snap-align:start}:root{--overflow-slider-arrows-size:1.5rem;--overflow-slider-arrows-gap:.5rem;--overflow-slider-arrows-inactive-opacity:0.5}.overflow-slider__arrows{display:flex;gap:var(--overflow-slider-arrows-gap)}.overflow-slider__arrows-button{align-items:center;cursor:pointer;display:flex;outline-offset:-2px}.overflow-slider__arrows-button svg{height:var(--overflow-slider-arrows-size);width:var(--overflow-slider-arrows-size)}.overflow-slider__arrows-button[data-has-content=false]{opacity:var(--overflow-slider-arrows-inactive-opacity)}:root{--overflow-slider-dots-gap:0.5rem;--overflow-slider-dot-size:0.75rem;--overflow-slider-dot-inactive-color:rgba(0,0,0,.1);--overflow-slider-dot-active-color:rgba(0,0,0,.8)}.overflow-slider__dots{align-items:center;display:flex;justify-content:center}.overflow-slider__dots ul{display:flex;flex-wrap:wrap;gap:var(--overflow-slider-dots-gap);list-style:none;margin:0;padding:0}.overflow-slider__dots li{line-height:0;margin:0;padding:0}.overflow-slider__dot-item{background:var(--overflow-slider-dot-inactive-color);border-radius:50%;cursor:pointer;height:var(--overflow-slider-dot-size);margin:0;outline-offset:2px;padding:0;position:relative;width:var(--overflow-slider-dot-size)}.overflow-slider__dot-item:after{bottom:calc(var(--overflow-slider-dots-gap)*-1);content:"";display:block;left:calc(var(--overflow-slider-dots-gap)*-1);position:absolute;right:calc(var(--overflow-slider-dots-gap)*-1);top:calc(var(--overflow-slider-dots-gap)*-1)}.overflow-slider__dot-item:focus,.overflow-slider__dot-item:hover,.overflow-slider__dot-item[aria-pressed=true]{background:var(--overflow-slider-dot-active-color)}:root{--overflow-slider-scroll-indicator-button-height:4px;--overflow-slider-scroll-indicator-padding:1rem;--overflow-slider-scroll-indicator-button-color:rgba(0,0,0,.75);--overflow-slider-scroll-indicator-bar-color:rgba(0,0,0,.25)}.overflow-slider__scroll-indicator{cursor:pointer;outline:0;padding-block:var(--overflow-slider-scroll-indicator-padding);position:relative;width:100%}.overflow-slider__scroll-indicator[data-has-overflow=false]{display:none}.overflow-slider__scroll-indicator:focus-visible .overflow-slider__scroll-indicator-button{outline:2px solid;outline-offset:2px}.overflow-slider__scroll-indicator-bar{background:var(--overflow-slider-scroll-indicator-bar-color);border-radius:3px;height:2px;left:0;position:absolute;top:50%;transform:translateY(-50%);width:100%}.overflow-slider__scroll-indicator-button{background:var(--overflow-slider-scroll-indicator-button-color);border-radius:3px;cursor:grab;height:var(--overflow-slider-scroll-indicator-button-height);left:0;position:absolute;top:calc(50% - var(--overflow-slider-scroll-indicator-button-height)/2)}.overflow-slider__scroll-indicator-button:hover,.overflow-slider__scroll-indicator-button[data-is-grabbed=true]{--overflow-slider-scroll-indicator-button-height:6px}.overflow-slider__scroll-indicator-button:after{bottom:calc(var(--overflow-slider-scroll-indicator-padding)*-1);content:"";display:block;position:absolute;top:calc(var(--overflow-slider-scroll-indicator-padding)*-1);width:100%}