@evermade/overflow-slider 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -8
- package/dist/core/details.esm.js +35 -0
- package/dist/core/details.min.js +1 -0
- package/dist/core/overflow-slider.esm.js +26 -0
- package/dist/core/overflow-slider.min.js +1 -0
- package/dist/core/slider.esm.js +260 -0
- package/dist/core/slider.min.js +1 -0
- package/dist/core/utils.esm.js +22 -0
- package/dist/core/utils.min.js +1 -0
- package/dist/index.esm.js +1 -694
- package/dist/index.min.js +1 -2
- package/dist/overflow-slider.css +1 -1
- package/dist/plugins/arrows/arrows/index.esm.js +82 -0
- package/dist/plugins/arrows/arrows/index.min.js +1 -0
- package/dist/plugins/dots/dots/index.esm.js +99 -0
- package/dist/plugins/dots/dots/index.min.js +1 -0
- package/dist/plugins/drag-scrolling/drag-scrolling/index.esm.js +70 -0
- package/dist/plugins/drag-scrolling/drag-scrolling/index.min.js +1 -0
- package/dist/plugins/full-width/full-width/index.esm.js +31 -0
- package/dist/plugins/full-width/full-width/index.min.js +1 -0
- package/dist/plugins/scroll-indicator/scroll-indicator/index.esm.js +133 -0
- package/dist/plugins/scroll-indicator/scroll-indicator/index.min.js +1 -0
- package/dist/plugins/skip-links/skip-links/index.esm.js +42 -0
- package/dist/plugins/skip-links/skip-links/index.min.js +1 -0
- package/dist/plugins/thumbnails/thumbnails/index.esm.js +41 -0
- package/dist/plugins/thumbnails/thumbnails/index.min.js +1 -0
- package/docs/assets/demo.css +151 -5
- package/docs/assets/demo.js +107 -10
- package/docs/dist/core/details.esm.js +35 -0
- package/docs/dist/core/details.min.js +1 -0
- package/docs/dist/core/overflow-slider.esm.js +26 -0
- package/docs/dist/core/overflow-slider.min.js +1 -0
- package/docs/dist/core/slider.esm.js +260 -0
- package/docs/dist/core/slider.min.js +1 -0
- package/docs/dist/core/utils.esm.js +22 -0
- package/docs/dist/core/utils.min.js +1 -0
- package/docs/dist/index.esm.js +1 -0
- package/docs/dist/index.min.js +1 -0
- package/docs/dist/overflow-slider.css +1 -1
- package/docs/dist/plugins/arrows/arrows/index.esm.js +82 -0
- package/docs/dist/plugins/arrows/arrows/index.min.js +1 -0
- package/docs/dist/plugins/dots/dots/index.esm.js +99 -0
- package/docs/dist/plugins/dots/dots/index.min.js +1 -0
- package/docs/dist/plugins/drag-scrolling/drag-scrolling/index.esm.js +70 -0
- package/docs/dist/plugins/drag-scrolling/drag-scrolling/index.min.js +1 -0
- package/docs/dist/plugins/full-width/full-width/index.esm.js +31 -0
- package/docs/dist/plugins/full-width/full-width/index.min.js +1 -0
- package/docs/dist/plugins/scroll-indicator/scroll-indicator/index.esm.js +133 -0
- package/docs/dist/plugins/scroll-indicator/scroll-indicator/index.min.js +1 -0
- package/docs/dist/plugins/skip-links/skip-links/index.esm.js +42 -0
- package/docs/dist/plugins/skip-links/skip-links/index.min.js +1 -0
- package/docs/dist/plugins/thumbnails/thumbnails/index.esm.js +41 -0
- package/docs/dist/plugins/thumbnails/thumbnails/index.min.js +1 -0
- package/docs/index.html +136 -2
- package/package.json +35 -6
- package/rollup.config.js +58 -32
- package/src/core/details.ts +1 -1
- package/src/{overflow-slider.ts → core/overflow-slider.ts} +3 -2
- package/src/core/slider.ts +62 -16
- package/src/core/types.ts +9 -1
- package/src/index.ts +1 -12
- package/src/overflow-slider.scss +10 -183
- package/src/plugins/{arrows.ts → arrows/index.ts} +13 -4
- package/src/plugins/arrows/styles.scss +29 -0
- package/src/plugins/{dots.ts → dots/index.ts} +1 -1
- package/src/plugins/dots/styles.scss +56 -0
- package/src/plugins/{drag-scrolling.ts → drag-scrolling/index.ts} +39 -35
- package/src/plugins/drag-scrolling/styles.scss +12 -0
- package/src/plugins/full-width/index.ts +43 -0
- package/src/plugins/{scroll-indicator.ts → scroll-indicator/index.ts} +36 -20
- package/src/plugins/scroll-indicator/styles.scss +59 -0
- package/src/plugins/{skip-links.ts → skip-links/index.ts} +2 -2
- package/src/plugins/skip-links/styles.scss +35 -0
- package/src/plugins/thumbnails/index.ts +53 -0
- package/tsconfig.json +14 -2
- package/dist/index.esm.min.js +0 -2
- package/dist/index.js +0 -709
- package/docs/dist/overflow-slider.esm.js +0 -694
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OverflowSlider } from './core/overflow-slider.esm.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as OverflowSlider}from"./core/overflow-slider.min.js";
|
|
@@ -1 +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%}
|
|
1
|
+
.overflow-slider{-ms-overflow-style:none;display:grid;grid-auto-flow:column;grid-template-columns:max-content;max-width:-moz-max-content;max-width:max-content;overflow:auto;scrollbar-width:none;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)}[data-has-drag-scrolling][data-has-overflow=true]{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}: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,82 @@
|
|
|
1
|
+
const DEFAULT_TEXTS = {
|
|
2
|
+
buttonPrevious: 'Previous items',
|
|
3
|
+
buttonNext: 'Next items',
|
|
4
|
+
};
|
|
5
|
+
const DEFAULT_ICONS = {
|
|
6
|
+
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>',
|
|
7
|
+
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>',
|
|
8
|
+
};
|
|
9
|
+
const DEFAULT_CLASS_NAMES = {
|
|
10
|
+
navContainer: 'overflow-slider__arrows',
|
|
11
|
+
prevButton: 'overflow-slider__arrows-button overflow-slider__arrows-button--prev',
|
|
12
|
+
nextButton: 'overflow-slider__arrows-button overflow-slider__arrows-button--next',
|
|
13
|
+
};
|
|
14
|
+
function ArrowsPlugin(args) {
|
|
15
|
+
return (slider) => {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17
|
+
const options = {
|
|
18
|
+
texts: Object.assign(Object.assign({}, DEFAULT_TEXTS), (args === null || args === void 0 ? void 0 : args.texts) || []),
|
|
19
|
+
icons: Object.assign(Object.assign({}, DEFAULT_ICONS), (args === null || args === void 0 ? void 0 : args.icons) || []),
|
|
20
|
+
classNames: Object.assign(Object.assign({}, DEFAULT_CLASS_NAMES), (args === null || args === void 0 ? void 0 : args.classNames) || []),
|
|
21
|
+
container: (_a = args === null || args === void 0 ? void 0 : args.container) !== null && _a !== void 0 ? _a : null,
|
|
22
|
+
containerPrev: (_b = args === null || args === void 0 ? void 0 : args.containerPrev) !== null && _b !== void 0 ? _b : null,
|
|
23
|
+
containerNext: (_c = args === null || args === void 0 ? void 0 : args.containerNext) !== null && _c !== void 0 ? _c : null,
|
|
24
|
+
};
|
|
25
|
+
const nav = document.createElement('div');
|
|
26
|
+
nav.classList.add(options.classNames.navContainer);
|
|
27
|
+
const prev = document.createElement('button');
|
|
28
|
+
prev.setAttribute('class', options.classNames.prevButton);
|
|
29
|
+
prev.setAttribute('type', 'button');
|
|
30
|
+
prev.setAttribute('aria-label', options.texts.buttonPrevious);
|
|
31
|
+
prev.setAttribute('aria-controls', (_d = slider.container.getAttribute('id')) !== null && _d !== void 0 ? _d : '');
|
|
32
|
+
prev.setAttribute('data-type', 'prev');
|
|
33
|
+
prev.innerHTML = options.icons.prev;
|
|
34
|
+
prev.addEventListener('click', () => slider.moveToDirection('prev'));
|
|
35
|
+
const next = document.createElement('button');
|
|
36
|
+
next.setAttribute('class', options.classNames.nextButton);
|
|
37
|
+
next.setAttribute('type', 'button');
|
|
38
|
+
next.setAttribute('aria-label', options.texts.buttonNext);
|
|
39
|
+
next.setAttribute('aria-controls', (_e = slider.container.getAttribute('id')) !== null && _e !== void 0 ? _e : '');
|
|
40
|
+
next.setAttribute('data-type', 'next');
|
|
41
|
+
next.innerHTML = options.icons.next;
|
|
42
|
+
next.addEventListener('click', () => slider.moveToDirection('next'));
|
|
43
|
+
// insert buttons to the nav
|
|
44
|
+
nav.appendChild(prev);
|
|
45
|
+
nav.appendChild(next);
|
|
46
|
+
const update = () => {
|
|
47
|
+
const scrollLeft = slider.container.scrollLeft;
|
|
48
|
+
const scrollWidth = slider.container.scrollWidth;
|
|
49
|
+
const clientWidth = slider.container.clientWidth;
|
|
50
|
+
if (scrollLeft === 0) {
|
|
51
|
+
prev.setAttribute('data-has-content', 'false');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
prev.setAttribute('data-has-content', 'true');
|
|
55
|
+
}
|
|
56
|
+
if (scrollLeft + clientWidth >= scrollWidth) {
|
|
57
|
+
next.setAttribute('data-has-content', 'false');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
next.setAttribute('data-has-content', 'true');
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
if (options.containerNext && options.containerPrev) {
|
|
64
|
+
options.containerPrev.appendChild(prev);
|
|
65
|
+
options.containerNext.appendChild(next);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (options.container) {
|
|
69
|
+
options.container.appendChild(nav);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
(_f = slider.container.parentNode) === null || _f === void 0 ? void 0 : _f.insertBefore(nav, slider.container.nextSibling);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
update();
|
|
76
|
+
slider.on('scroll', update);
|
|
77
|
+
slider.on('contentsChanged', update);
|
|
78
|
+
slider.on('containerSizeChanged', update);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { ArrowsPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t={buttonPrevious:"Previous items",buttonNext:"Next items"},e={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>'},n={navContainer:"overflow-slider__arrows",prevButton:"overflow-slider__arrows-button overflow-slider__arrows-button--prev",nextButton:"overflow-slider__arrows-button overflow-slider__arrows-button--next"};function o(o){return i=>{var r,s,a,l,c,u;const d={texts:Object.assign(Object.assign({},t),(null==o?void 0:o.texts)||[]),icons:Object.assign(Object.assign({},e),(null==o?void 0:o.icons)||[]),classNames:Object.assign(Object.assign({},n),(null==o?void 0:o.classNames)||[]),container:null!==(r=null==o?void 0:o.container)&&void 0!==r?r:null,containerPrev:null!==(s=null==o?void 0:o.containerPrev)&&void 0!==s?s:null,containerNext:null!==(a=null==o?void 0:o.containerNext)&&void 0!==a?a:null},v=document.createElement("div");v.classList.add(d.classNames.navContainer);const b=document.createElement("button");b.setAttribute("class",d.classNames.prevButton),b.setAttribute("type","button"),b.setAttribute("aria-label",d.texts.buttonPrevious),b.setAttribute("aria-controls",null!==(l=i.container.getAttribute("id"))&&void 0!==l?l:""),b.setAttribute("data-type","prev"),b.innerHTML=d.icons.prev,b.addEventListener("click",(()=>i.moveToDirection("prev")));const p=document.createElement("button");p.setAttribute("class",d.classNames.nextButton),p.setAttribute("type","button"),p.setAttribute("aria-label",d.texts.buttonNext),p.setAttribute("aria-controls",null!==(c=i.container.getAttribute("id"))&&void 0!==c?c:""),p.setAttribute("data-type","next"),p.innerHTML=d.icons.next,p.addEventListener("click",(()=>i.moveToDirection("next"))),v.appendChild(b),v.appendChild(p);const x=()=>{const t=i.container.scrollLeft,e=i.container.scrollWidth,n=i.container.clientWidth;0===t?b.setAttribute("data-has-content","false"):b.setAttribute("data-has-content","true"),t+n>=e?p.setAttribute("data-has-content","false"):p.setAttribute("data-has-content","true")};d.containerNext&&d.containerPrev?(d.containerPrev.appendChild(b),d.containerNext.appendChild(p)):d.container?d.container.appendChild(v):null===(u=i.container.parentNode)||void 0===u||u.insertBefore(v,i.container.nextSibling),x(),i.on("scroll",x),i.on("contentsChanged",x),i.on("containerSizeChanged",x)}}export{o as default};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const DEFAULT_TEXTS = {
|
|
2
|
+
dotDescription: 'Page %d of %d',
|
|
3
|
+
};
|
|
4
|
+
const DEFAULT_CLASS_NAMES = {
|
|
5
|
+
dotsContainer: 'overflow-slider__dots',
|
|
6
|
+
dotsItem: 'overflow-slider__dot-item',
|
|
7
|
+
};
|
|
8
|
+
function DotsPlugin(args) {
|
|
9
|
+
return (slider) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const options = {
|
|
12
|
+
texts: Object.assign(Object.assign({}, DEFAULT_TEXTS), (args === null || args === void 0 ? void 0 : args.texts) || []),
|
|
13
|
+
classNames: Object.assign(Object.assign({}, DEFAULT_CLASS_NAMES), (args === null || args === void 0 ? void 0 : args.classNames) || []),
|
|
14
|
+
container: (_a = args === null || args === void 0 ? void 0 : args.container) !== null && _a !== void 0 ? _a : null,
|
|
15
|
+
};
|
|
16
|
+
const dots = document.createElement('div');
|
|
17
|
+
dots.classList.add(options.classNames.dotsContainer);
|
|
18
|
+
let pageFocused = null;
|
|
19
|
+
const buildDots = () => {
|
|
20
|
+
dots.setAttribute('data-has-content', slider.details.hasOverflow.toString());
|
|
21
|
+
dots.innerHTML = '';
|
|
22
|
+
const dotsList = document.createElement('ul');
|
|
23
|
+
const pages = slider.details.amountOfPages;
|
|
24
|
+
const currentPage = slider.details.currentPage;
|
|
25
|
+
if (pages <= 1) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (let i = 0; i < pages; i++) {
|
|
29
|
+
const dotListItem = document.createElement('li');
|
|
30
|
+
const dot = document.createElement('button');
|
|
31
|
+
dot.setAttribute('type', 'button');
|
|
32
|
+
dot.setAttribute('class', options.classNames.dotsItem);
|
|
33
|
+
dot.setAttribute('aria-label', options.texts.dotDescription.replace('%d', (i + 1).toString()).replace('%d', pages.toString()));
|
|
34
|
+
dot.setAttribute('aria-pressed', (i === currentPage).toString());
|
|
35
|
+
dot.setAttribute('data-page', (i + 1).toString());
|
|
36
|
+
dotListItem.appendChild(dot);
|
|
37
|
+
dotsList.appendChild(dotListItem);
|
|
38
|
+
dot.addEventListener('click', () => activateDot(i + 1));
|
|
39
|
+
dot.addEventListener('focus', () => pageFocused = i + 1);
|
|
40
|
+
dot.addEventListener('keydown', (e) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const currentPageItem = dots.querySelector(`[aria-pressed="true"]`);
|
|
43
|
+
if (!currentPageItem) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const currentPage = parseInt((_a = currentPageItem.getAttribute('data-page')) !== null && _a !== void 0 ? _a : '1');
|
|
47
|
+
if (e.key === 'ArrowLeft') {
|
|
48
|
+
const previousPage = currentPage - 1;
|
|
49
|
+
if (previousPage > 0) {
|
|
50
|
+
const matchingDot = dots.querySelector(`[data-page="${previousPage}"]`);
|
|
51
|
+
if (matchingDot) {
|
|
52
|
+
matchingDot.focus();
|
|
53
|
+
}
|
|
54
|
+
activateDot(previousPage);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (e.key === 'ArrowRight') {
|
|
58
|
+
const nextPage = currentPage + 1;
|
|
59
|
+
if (nextPage <= pages) {
|
|
60
|
+
const matchingDot = dots.querySelector(`[data-page="${nextPage}"]`);
|
|
61
|
+
if (matchingDot) {
|
|
62
|
+
matchingDot.focus();
|
|
63
|
+
}
|
|
64
|
+
activateDot(nextPage);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
dots.appendChild(dotsList);
|
|
70
|
+
// return focus to same page after rebuild
|
|
71
|
+
if (pageFocused) {
|
|
72
|
+
const matchingDot = dots.querySelector(`[data-page="${pageFocused}"]`);
|
|
73
|
+
if (matchingDot) {
|
|
74
|
+
matchingDot.focus();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const activateDot = (page) => {
|
|
79
|
+
const scrollTargetPosition = slider.details.containerWidth * (page - 1);
|
|
80
|
+
slider.container.style.scrollBehavior = slider.options.scrollBehavior;
|
|
81
|
+
slider.container.style.scrollSnapType = 'none';
|
|
82
|
+
slider.container.scrollLeft = scrollTargetPosition;
|
|
83
|
+
slider.container.style.scrollBehavior = '';
|
|
84
|
+
slider.container.style.scrollSnapType = '';
|
|
85
|
+
};
|
|
86
|
+
buildDots();
|
|
87
|
+
if (options.container) {
|
|
88
|
+
options.container.appendChild(dots);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
(_b = slider.container.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(dots, slider.container.nextSibling);
|
|
92
|
+
}
|
|
93
|
+
slider.on('detailsChanged', () => {
|
|
94
|
+
buildDots();
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { DotsPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t={dotDescription:"Page %d of %d"},e={dotsContainer:"overflow-slider__dots",dotsItem:"overflow-slider__dot-item"};function n(n){return o=>{var a,s;const r={texts:Object.assign(Object.assign({},t),(null==n?void 0:n.texts)||[]),classNames:Object.assign(Object.assign({},e),(null==n?void 0:n.classNames)||[]),container:null!==(a=null==n?void 0:n.container)&&void 0!==a?a:null},i=document.createElement("div");i.classList.add(r.classNames.dotsContainer);let l=null;const c=()=>{i.setAttribute("data-has-content",o.details.hasOverflow.toString()),i.innerHTML="";const t=document.createElement("ul"),e=o.details.amountOfPages,n=o.details.currentPage;if(!(e<=1)){for(let o=0;o<e;o++){const a=document.createElement("li"),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("class",r.classNames.dotsItem),s.setAttribute("aria-label",r.texts.dotDescription.replace("%d",(o+1).toString()).replace("%d",e.toString())),s.setAttribute("aria-pressed",(o===n).toString()),s.setAttribute("data-page",(o+1).toString()),a.appendChild(s),t.appendChild(a),s.addEventListener("click",(()=>d(o+1))),s.addEventListener("focus",(()=>l=o+1)),s.addEventListener("keydown",(t=>{var n;const o=i.querySelector('[aria-pressed="true"]');if(!o)return;const a=parseInt(null!==(n=o.getAttribute("data-page"))&&void 0!==n?n:"1");if("ArrowLeft"===t.key){const t=a-1;if(t>0){const e=i.querySelector(`[data-page="${t}"]`);e&&e.focus(),d(t)}}if("ArrowRight"===t.key){const t=a+1;if(t<=e){const e=i.querySelector(`[data-page="${t}"]`);e&&e.focus(),d(t)}}}))}if(i.appendChild(t),l){const t=i.querySelector(`[data-page="${l}"]`);t&&t.focus()}}},d=t=>{const e=o.details.containerWidth*(t-1);o.container.style.scrollBehavior=o.options.scrollBehavior,o.container.style.scrollSnapType="none",o.container.scrollLeft=e,o.container.style.scrollBehavior="",o.container.style.scrollSnapType=""};c(),r.container?r.container.appendChild(i):null===(s=o.container.parentNode)||void 0===s||s.insertBefore(i,o.container.nextSibling),o.on("detailsChanged",(()=>{c()}))}}export{n as default};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const DEFAULT_DRAGGED_DISTANCE_THAT_PREVENTS_CLICK = 20;
|
|
2
|
+
function DragScrollingPlugin(args) {
|
|
3
|
+
var _a;
|
|
4
|
+
const options = {
|
|
5
|
+
draggedDistanceThatPreventsClick: (_a = args === null || args === void 0 ? void 0 : args.draggedDistanceThatPreventsClick) !== null && _a !== void 0 ? _a : DEFAULT_DRAGGED_DISTANCE_THAT_PREVENTS_CLICK,
|
|
6
|
+
};
|
|
7
|
+
return (slider) => {
|
|
8
|
+
let isMouseDown = false;
|
|
9
|
+
let startX = 0;
|
|
10
|
+
let scrollLeft = 0;
|
|
11
|
+
// add data attribute to container
|
|
12
|
+
slider.container.setAttribute('data-has-drag-scrolling', 'true');
|
|
13
|
+
const mouseDown = (e) => {
|
|
14
|
+
if (!slider.details.hasOverflow) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!slider.container.contains(e.target)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
isMouseDown = true;
|
|
21
|
+
startX = e.pageX - slider.container.offsetLeft;
|
|
22
|
+
scrollLeft = slider.container.scrollLeft;
|
|
23
|
+
// change cursor to grabbing
|
|
24
|
+
slider.container.style.cursor = 'grabbing';
|
|
25
|
+
slider.container.style.scrollSnapType = 'none';
|
|
26
|
+
slider.container.style.scrollBehavior = 'auto';
|
|
27
|
+
// prevent focus going to the slides
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
};
|
|
31
|
+
const mouseMove = (e) => {
|
|
32
|
+
if (!slider.details.hasOverflow) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!isMouseDown) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
const x = e.pageX - slider.container.offsetLeft;
|
|
40
|
+
const walk = (x - startX);
|
|
41
|
+
slider.container.scrollLeft = scrollLeft - walk;
|
|
42
|
+
const absWalk = Math.abs(walk);
|
|
43
|
+
const slides = slider.container.querySelectorAll(slider.options.slidesSelector);
|
|
44
|
+
const pointerEvents = absWalk > options.draggedDistanceThatPreventsClick ? 'none' : '';
|
|
45
|
+
slides.forEach((slide) => {
|
|
46
|
+
slide.style.pointerEvents = pointerEvents;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const mouseUp = () => {
|
|
50
|
+
if (!slider.details.hasOverflow) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
isMouseDown = false;
|
|
54
|
+
slider.container.style.cursor = '';
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
slider.container.style.scrollSnapType = '';
|
|
57
|
+
slider.container.style.scrollBehavior = '';
|
|
58
|
+
const slides = slider.container.querySelectorAll(slider.options.slidesSelector);
|
|
59
|
+
slides.forEach((slide) => {
|
|
60
|
+
slide.style.pointerEvents = '';
|
|
61
|
+
});
|
|
62
|
+
}, 50);
|
|
63
|
+
};
|
|
64
|
+
window.addEventListener('mousedown', mouseDown);
|
|
65
|
+
window.addEventListener('mousemove', mouseMove);
|
|
66
|
+
window.addEventListener('mouseup', mouseUp);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { DragScrollingPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){var t;const n=null!==(t=null==e?void 0:e.draggedDistanceThatPreventsClick)&&void 0!==t?t:20;return e=>{let t=!1,o=0,r=0;e.container.setAttribute("data-has-drag-scrolling","true");window.addEventListener("mousedown",(n=>{e.details.hasOverflow&&e.container.contains(n.target)&&(t=!0,o=n.pageX-e.container.offsetLeft,r=e.container.scrollLeft,e.container.style.cursor="grabbing",e.container.style.scrollSnapType="none",e.container.style.scrollBehavior="auto",n.preventDefault(),n.stopPropagation())})),window.addEventListener("mousemove",(a=>{if(!e.details.hasOverflow)return;if(!t)return;a.preventDefault();const s=a.pageX-e.container.offsetLeft-o;e.container.scrollLeft=r-s;const l=Math.abs(s),i=e.container.querySelectorAll(e.options.slidesSelector),c=l>n?"none":"";i.forEach((e=>{e.style.pointerEvents=c}))})),window.addEventListener("mouseup",(()=>{e.details.hasOverflow&&(t=!1,e.container.style.cursor="",setTimeout((()=>{e.container.style.scrollSnapType="",e.container.style.scrollBehavior="";e.container.querySelectorAll(e.options.slidesSelector).forEach((e=>{e.style.pointerEvents=""}))}),50))}))}}export{e as default};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const DEFAULT_TARGET_WIDTH = (slider) => { var _a, _b; return (_b = (_a = slider.container.parentElement) === null || _a === void 0 ? void 0 : _a.offsetWidth) !== null && _b !== void 0 ? _b : window.innerWidth; };
|
|
2
|
+
function FullWidthPlugin(args) {
|
|
3
|
+
return (slider) => {
|
|
4
|
+
var _a, _b, _c;
|
|
5
|
+
const options = {
|
|
6
|
+
targetWidth: (_a = args === null || args === void 0 ? void 0 : args.targetWidth) !== null && _a !== void 0 ? _a : DEFAULT_TARGET_WIDTH,
|
|
7
|
+
addMarginBefore: (_b = args === null || args === void 0 ? void 0 : args.addMarginBefore) !== null && _b !== void 0 ? _b : true,
|
|
8
|
+
addMarginAfter: (_c = args === null || args === void 0 ? void 0 : args.addMarginAfter) !== null && _c !== void 0 ? _c : true,
|
|
9
|
+
};
|
|
10
|
+
const update = () => {
|
|
11
|
+
const slides = slider.container.querySelectorAll(slider.options.slidesSelector);
|
|
12
|
+
if (!slides.length) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const firstSlide = slides[0];
|
|
16
|
+
const lastSlide = slides[slides.length - 1];
|
|
17
|
+
const marginAmount = Math.floor((window.innerWidth - options.targetWidth(slider)) / 2);
|
|
18
|
+
if (options.addMarginBefore) {
|
|
19
|
+
firstSlide.style.marginLeft = `${marginAmount}px`;
|
|
20
|
+
}
|
|
21
|
+
if (options.addMarginAfter) {
|
|
22
|
+
lastSlide.style.marginRight = `${marginAmount}px`;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
update();
|
|
26
|
+
slider.on('contentsChanged', update);
|
|
27
|
+
slider.on('containerSizeChanged', update);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { FullWidthPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=n=>{var t,e;return null!==(e=null===(t=n.container.parentElement)||void 0===t?void 0:t.offsetWidth)&&void 0!==e?e:window.innerWidth};function t(t){return e=>{var i,r,d;const o={targetWidth:null!==(i=null==t?void 0:t.targetWidth)&&void 0!==i?i:n,addMarginBefore:null===(r=null==t?void 0:t.addMarginBefore)||void 0===r||r,addMarginAfter:null===(d=null==t?void 0:t.addMarginAfter)||void 0===d||d},a=()=>{const n=e.container.querySelectorAll(e.options.slidesSelector);if(!n.length)return;const t=n[0],i=n[n.length-1],r=Math.floor((window.innerWidth-o.targetWidth(e))/2);o.addMarginBefore&&(t.style.marginLeft=`${r}px`),o.addMarginAfter&&(i.style.marginRight=`${r}px`)};a(),e.on("contentsChanged",a),e.on("containerSizeChanged",a)}}export{t as default};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const DEFAULT_CLASS_NAMES = {
|
|
2
|
+
scrollIndicator: 'overflow-slider__scroll-indicator',
|
|
3
|
+
scrollIndicatorBar: 'overflow-slider__scroll-indicator-bar',
|
|
4
|
+
scrollIndicatorButton: 'overflow-slider__scroll-indicator-button',
|
|
5
|
+
};
|
|
6
|
+
function ScrollIndicatorPlugin(args) {
|
|
7
|
+
return (slider) => {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const options = {
|
|
10
|
+
classNames: Object.assign(Object.assign({}, DEFAULT_CLASS_NAMES), (args === null || args === void 0 ? void 0 : args.classNames) || []),
|
|
11
|
+
container: (_a = args === null || args === void 0 ? void 0 : args.container) !== null && _a !== void 0 ? _a : null,
|
|
12
|
+
};
|
|
13
|
+
const scrollbarContainer = document.createElement('div');
|
|
14
|
+
scrollbarContainer.setAttribute('class', options.classNames.scrollIndicator);
|
|
15
|
+
scrollbarContainer.setAttribute('tabindex', '0');
|
|
16
|
+
scrollbarContainer.setAttribute('role', 'scrollbar');
|
|
17
|
+
scrollbarContainer.setAttribute('aria-controls', (_b = slider.container.getAttribute('id')) !== null && _b !== void 0 ? _b : '');
|
|
18
|
+
scrollbarContainer.setAttribute('aria-orientation', 'horizontal');
|
|
19
|
+
scrollbarContainer.setAttribute('aria-valuemax', '100');
|
|
20
|
+
scrollbarContainer.setAttribute('aria-valuemin', '0');
|
|
21
|
+
scrollbarContainer.setAttribute('aria-valuenow', '0');
|
|
22
|
+
const scrollbar = document.createElement('div');
|
|
23
|
+
scrollbar.setAttribute('class', options.classNames.scrollIndicatorBar);
|
|
24
|
+
const scrollbarButton = document.createElement('div');
|
|
25
|
+
scrollbarButton.setAttribute('class', options.classNames.scrollIndicatorButton);
|
|
26
|
+
scrollbarButton.setAttribute('data-is-grabbed', 'false');
|
|
27
|
+
scrollbar.appendChild(scrollbarButton);
|
|
28
|
+
scrollbarContainer.appendChild(scrollbar);
|
|
29
|
+
const setDataAttributes = () => {
|
|
30
|
+
scrollbarContainer.setAttribute('data-has-overflow', slider.details.hasOverflow.toString());
|
|
31
|
+
};
|
|
32
|
+
setDataAttributes();
|
|
33
|
+
const getScrollbarButtonLeftOffset = () => {
|
|
34
|
+
const contentRatio = scrollbarButton.offsetWidth / slider.details.containerWidth;
|
|
35
|
+
return slider.container.scrollLeft * contentRatio;
|
|
36
|
+
};
|
|
37
|
+
// scrollbarbutton width and position is calculated based on the scroll position and available width
|
|
38
|
+
let requestId = 0;
|
|
39
|
+
const update = () => {
|
|
40
|
+
if (requestId) {
|
|
41
|
+
window.cancelAnimationFrame(requestId);
|
|
42
|
+
}
|
|
43
|
+
requestId = window.requestAnimationFrame(() => {
|
|
44
|
+
const scrollbarButtonWidth = (slider.details.containerWidth / slider.details.scrollableAreaWidth) * 100;
|
|
45
|
+
const scrollLeftInPortion = getScrollbarButtonLeftOffset();
|
|
46
|
+
scrollbarButton.style.width = `${scrollbarButtonWidth}%`;
|
|
47
|
+
scrollbarButton.style.transform = `translateX(${scrollLeftInPortion}px)`;
|
|
48
|
+
// aria-valuenow
|
|
49
|
+
const scrollLeft = slider.container.scrollLeft;
|
|
50
|
+
const scrollWidth = slider.container.scrollWidth;
|
|
51
|
+
const containerWidth = slider.container.offsetWidth;
|
|
52
|
+
const scrollPercentage = (scrollLeft / (scrollWidth - containerWidth)) * 100;
|
|
53
|
+
scrollbarContainer.setAttribute('aria-valuenow', Math.round(Number.isNaN(scrollPercentage) ? 0 : scrollPercentage).toString());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
// insert to DOM
|
|
57
|
+
if (options.container) {
|
|
58
|
+
options.container.appendChild(scrollbarContainer);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
(_c = slider.container.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(scrollbarContainer, slider.container.nextSibling);
|
|
62
|
+
}
|
|
63
|
+
// update the scrollbar when the slider is scrolled
|
|
64
|
+
update();
|
|
65
|
+
slider.on('scroll', update);
|
|
66
|
+
slider.on('contentsChanged', update);
|
|
67
|
+
slider.on('containerSizeChanged', update);
|
|
68
|
+
slider.on('detailsChanged', setDataAttributes);
|
|
69
|
+
// handle arrow keys while focused
|
|
70
|
+
scrollbarContainer.addEventListener('keydown', (e) => {
|
|
71
|
+
if (e.key === 'ArrowLeft') {
|
|
72
|
+
slider.moveToDirection('prev');
|
|
73
|
+
}
|
|
74
|
+
else if (e.key === 'ArrowRight') {
|
|
75
|
+
slider.moveToDirection('next');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// handle click to before or after the scrollbar button
|
|
79
|
+
scrollbarContainer.addEventListener('click', (e) => {
|
|
80
|
+
const scrollbarButtonWidth = scrollbarButton.offsetWidth;
|
|
81
|
+
const scrollbarButtonLeft = getScrollbarButtonLeftOffset();
|
|
82
|
+
const scrollbarButtonRight = scrollbarButtonLeft + scrollbarButtonWidth;
|
|
83
|
+
const clickX = e.pageX - scrollbarContainer.offsetLeft;
|
|
84
|
+
if (clickX < scrollbarButtonLeft) {
|
|
85
|
+
slider.moveToDirection('prev');
|
|
86
|
+
}
|
|
87
|
+
else if (clickX > scrollbarButtonRight) {
|
|
88
|
+
slider.moveToDirection('next');
|
|
89
|
+
}
|
|
90
|
+
});
|
|
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
|
+
const onInteractionDown = (e) => {
|
|
96
|
+
isInteractionDown = true;
|
|
97
|
+
const pageX = e.pageX || e.touches[0].pageX;
|
|
98
|
+
startX = pageX - scrollbarContainer.offsetLeft;
|
|
99
|
+
scrollLeft = slider.container.scrollLeft;
|
|
100
|
+
// change cursor to grabbing
|
|
101
|
+
scrollbarButton.style.cursor = 'grabbing';
|
|
102
|
+
slider.container.style.scrollSnapType = 'none';
|
|
103
|
+
scrollbarButton.setAttribute('data-is-grabbed', 'true');
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
};
|
|
107
|
+
const onInteractionMove = (e) => {
|
|
108
|
+
if (!isInteractionDown) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
const pageX = e.pageX || e.touches[0].pageX;
|
|
113
|
+
const x = pageX - scrollbarContainer.offsetLeft;
|
|
114
|
+
const scrollingFactor = slider.details.scrollableAreaWidth / scrollbarContainer.offsetWidth;
|
|
115
|
+
const walk = (x - startX) * scrollingFactor;
|
|
116
|
+
slider.container.scrollLeft = scrollLeft + walk;
|
|
117
|
+
};
|
|
118
|
+
const onInteractionUp = () => {
|
|
119
|
+
isInteractionDown = false;
|
|
120
|
+
scrollbarButton.style.cursor = '';
|
|
121
|
+
slider.container.style.scrollSnapType = '';
|
|
122
|
+
scrollbarButton.setAttribute('data-is-grabbed', 'false');
|
|
123
|
+
};
|
|
124
|
+
scrollbarButton.addEventListener('mousedown', onInteractionDown);
|
|
125
|
+
scrollbarButton.addEventListener('touchstart', onInteractionDown);
|
|
126
|
+
window.addEventListener('mousemove', onInteractionMove);
|
|
127
|
+
window.addEventListener('touchmove', onInteractionMove, { passive: false });
|
|
128
|
+
window.addEventListener('mouseup', onInteractionUp);
|
|
129
|
+
window.addEventListener('touchend', onInteractionUp);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { ScrollIndicatorPlugin as default };
|
|
@@ -0,0 +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 p=t=>{b=!0;const e=t.pageX||t.touches[0].pageX;m=e-s.offsetLeft,h=n.container.scrollLeft,c.style.cursor="grabbing",n.container.style.scrollSnapType="none",c.setAttribute("data-is-grabbed","true"),t.preventDefault(),t.stopPropagation()},w=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="",n.container.style.scrollSnapType="",c.setAttribute("data-is-grabbed","false")};c.addEventListener("mousedown",p),c.addEventListener("touchstart",p),window.addEventListener("mousemove",w),window.addEventListener("touchmove",w,{passive:!1}),window.addEventListener("mouseup",A),window.addEventListener("touchend",A)}}export{e as default};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { generateId } from '../../../core/utils.esm.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TEXTS = {
|
|
4
|
+
skipList: 'Skip list'
|
|
5
|
+
};
|
|
6
|
+
const DEFAULT_CLASS_NAMES = {
|
|
7
|
+
skipLink: 'screen-reader-text',
|
|
8
|
+
skipLinkTarget: 'overflow-slider__skip-link-target',
|
|
9
|
+
};
|
|
10
|
+
function SkipLinksPlugin(args) {
|
|
11
|
+
return (slider) => {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f;
|
|
13
|
+
const options = {
|
|
14
|
+
texts: Object.assign(Object.assign({}, DEFAULT_TEXTS), (args === null || args === void 0 ? void 0 : args.texts) || []),
|
|
15
|
+
classNames: Object.assign(Object.assign({}, DEFAULT_CLASS_NAMES), (args === null || args === void 0 ? void 0 : args.classNames) || []),
|
|
16
|
+
containerBefore: (_a = args === null || args === void 0 ? void 0 : args.containerAfter) !== null && _a !== void 0 ? _a : null,
|
|
17
|
+
containerAfter: (_b = args === null || args === void 0 ? void 0 : args.containerAfter) !== null && _b !== void 0 ? _b : null,
|
|
18
|
+
};
|
|
19
|
+
const skipId = generateId('overflow-slider-skip');
|
|
20
|
+
const skipLinkEl = document.createElement('a');
|
|
21
|
+
skipLinkEl.setAttribute('href', `#${skipId}`);
|
|
22
|
+
skipLinkEl.textContent = options.texts.skipList;
|
|
23
|
+
skipLinkEl.classList.add(options.classNames.skipLink);
|
|
24
|
+
const skipTargetEl = document.createElement('div');
|
|
25
|
+
skipTargetEl.setAttribute('id', skipId);
|
|
26
|
+
skipTargetEl.setAttribute('tabindex', '-1');
|
|
27
|
+
if (options.containerBefore) {
|
|
28
|
+
(_c = options.containerBefore.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(skipLinkEl, options.containerBefore);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
(_d = slider.container.parentNode) === null || _d === void 0 ? void 0 : _d.insertBefore(skipLinkEl, slider.container);
|
|
32
|
+
}
|
|
33
|
+
if (options.containerAfter) {
|
|
34
|
+
(_e = options.containerAfter.parentNode) === null || _e === void 0 ? void 0 : _e.insertBefore(skipTargetEl, options.containerAfter.nextSibling);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
(_f = slider.container.parentNode) === null || _f === void 0 ? void 0 : _f.insertBefore(skipTargetEl, slider.container.nextSibling);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { SkipLinksPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generateId as e}from"../../../core/utils.min.js";const t={skipList:"Skip list"},n={skipLink:"screen-reader-text",skipLinkTarget:"overflow-slider__skip-link-target"};function i(i){return r=>{var o,s,a,l,c,d;const u={texts:Object.assign(Object.assign({},t),(null==i?void 0:i.texts)||[]),classNames:Object.assign(Object.assign({},n),(null==i?void 0:i.classNames)||[]),containerBefore:null!==(o=null==i?void 0:i.containerAfter)&&void 0!==o?o:null,containerAfter:null!==(s=null==i?void 0:i.containerAfter)&&void 0!==s?s:null},f=e("overflow-slider-skip"),p=document.createElement("a");p.setAttribute("href",`#${f}`),p.textContent=u.texts.skipList,p.classList.add(u.classNames.skipLink);const v=document.createElement("div");v.setAttribute("id",f),v.setAttribute("tabindex","-1"),u.containerBefore?null===(a=u.containerBefore.parentNode)||void 0===a||a.insertBefore(p,u.containerBefore):null===(l=r.container.parentNode)||void 0===l||l.insertBefore(p,r.container),u.containerAfter?null===(c=u.containerAfter.parentNode)||void 0===c||c.insertBefore(v,u.containerAfter.nextSibling):null===(d=r.container.parentNode)||void 0===d||d.insertBefore(v,r.container.nextSibling)}}export{i as default};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function FullWidthPlugin(args) {
|
|
2
|
+
return (slider) => {
|
|
3
|
+
const options = {
|
|
4
|
+
mainSlider: args.mainSlider,
|
|
5
|
+
};
|
|
6
|
+
const mainSlider = options.mainSlider;
|
|
7
|
+
const setActiveThumbnail = (slide = null) => {
|
|
8
|
+
if (slide === null && slider.slides.length > 0) {
|
|
9
|
+
slide = slider.slides[0];
|
|
10
|
+
}
|
|
11
|
+
if (slide === null) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// add aria-current to the clicked slide
|
|
15
|
+
slider.slides.forEach((s) => {
|
|
16
|
+
s.setAttribute('aria-current', 'false');
|
|
17
|
+
});
|
|
18
|
+
slide.setAttribute('aria-current', 'true');
|
|
19
|
+
};
|
|
20
|
+
const addClickListeners = () => {
|
|
21
|
+
slider.slides.forEach((slide, index) => {
|
|
22
|
+
slide.addEventListener('click', () => {
|
|
23
|
+
mainSlider.moveToSlide(index);
|
|
24
|
+
setActiveThumbnail(slide);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
setActiveThumbnail();
|
|
29
|
+
addClickListeners();
|
|
30
|
+
mainSlider.on('activeSlideChanged', () => {
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
const activeSlideIdx = mainSlider.activeSlideIdx;
|
|
33
|
+
const activeThumbnail = slider.slides[activeSlideIdx];
|
|
34
|
+
setActiveThumbnail(activeThumbnail);
|
|
35
|
+
slider.moveToSlide(activeSlideIdx);
|
|
36
|
+
}, 50);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { FullWidthPlugin as default };
|
|
@@ -0,0 +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("activeSlideChanged",(()=>{setTimeout((()=>{const e=t.activeSlideIdx,n=i.slides[e];l(n),i.moveToSlide(e)}),50)}))}}export{e as default};
|