@evermade/overflow-slider 3.2.0 → 3.3.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 +290 -5
- package/dist/core/slider.esm.js +17 -4
- package/dist/core/slider.min.js +1 -1
- package/dist/core/utils.esm.js +2 -1
- package/dist/core/utils.min.js +1 -1
- package/dist/plugins/arrows/{arrows/index.esm.js → index.esm.js} +7 -7
- package/dist/plugins/arrows/index.min.js +1 -0
- package/{docs/dist/plugins/skip-links → dist/plugins}/skip-links/index.esm.js +1 -1
- package/dist/plugins/skip-links/index.min.js +1 -0
- package/docs/assets/demo.js +23 -8
- package/docs/dist/core/slider.esm.js +17 -4
- package/docs/dist/core/slider.min.js +1 -1
- package/docs/dist/core/utils.esm.js +2 -1
- package/docs/dist/core/utils.min.js +1 -1
- package/docs/dist/plugins/arrows/{arrows/index.esm.js → index.esm.js} +7 -7
- package/docs/dist/plugins/arrows/index.min.js +1 -0
- package/{dist/plugins/skip-links → docs/dist/plugins}/skip-links/index.esm.js +1 -1
- package/docs/dist/plugins/skip-links/index.min.js +1 -0
- package/docs/index-rtl.html +16 -0
- package/docs/index.html +16 -0
- package/package.json +17 -17
- package/rollup.config.js +13 -5
- package/src/core/slider.ts +22 -9
- package/src/core/types.ts +10 -3
- package/src/core/utils.ts +9 -5
- package/src/plugins/arrows/index.ts +7 -4
- package/src/plugins/dots/index.ts +1 -1
- package/src/plugins/drag-scrolling/index.ts +1 -1
- package/src/plugins/fade/index.ts +1 -1
- package/src/plugins/full-width/index.ts +1 -1
- package/src/plugins/scroll-indicator/index.ts +1 -1
- package/src/plugins/skip-links/index.ts +1 -1
- package/src/plugins/thumbnails/index.ts +1 -1
- package/dist/plugins/arrows/arrows/index.min.js +0 -1
- package/dist/plugins/skip-links/skip-links/index.min.js +0 -1
- package/docs/dist/plugins/arrows/arrows/index.min.js +0 -1
- package/docs/dist/plugins/skip-links/skip-links/index.min.js +0 -1
- /package/dist/plugins/dots/{dots/index.esm.js → index.esm.js} +0 -0
- /package/dist/plugins/dots/{dots/index.min.js → index.min.js} +0 -0
- /package/dist/plugins/drag-scrolling/{drag-scrolling/index.esm.js → index.esm.js} +0 -0
- /package/dist/plugins/drag-scrolling/{drag-scrolling/index.min.js → index.min.js} +0 -0
- /package/dist/plugins/fade/{fade/index.esm.js → index.esm.js} +0 -0
- /package/dist/plugins/fade/{fade/index.min.js → index.min.js} +0 -0
- /package/dist/plugins/full-width/{full-width/index.esm.js → index.esm.js} +0 -0
- /package/dist/plugins/full-width/{full-width/index.min.js → index.min.js} +0 -0
- /package/dist/plugins/scroll-indicator/{scroll-indicator/index.esm.js → index.esm.js} +0 -0
- /package/dist/plugins/scroll-indicator/{scroll-indicator/index.min.js → index.min.js} +0 -0
- /package/dist/plugins/thumbnails/{thumbnails/index.esm.js → index.esm.js} +0 -0
- /package/dist/plugins/thumbnails/{thumbnails/index.min.js → index.min.js} +0 -0
- /package/docs/dist/plugins/dots/{dots/index.esm.js → index.esm.js} +0 -0
- /package/docs/dist/plugins/dots/{dots/index.min.js → index.min.js} +0 -0
- /package/docs/dist/plugins/drag-scrolling/{drag-scrolling/index.esm.js → index.esm.js} +0 -0
- /package/docs/dist/plugins/drag-scrolling/{drag-scrolling/index.min.js → index.min.js} +0 -0
- /package/docs/dist/plugins/fade/{fade/index.esm.js → index.esm.js} +0 -0
- /package/docs/dist/plugins/fade/{fade/index.min.js → index.min.js} +0 -0
- /package/docs/dist/plugins/full-width/{full-width/index.esm.js → index.esm.js} +0 -0
- /package/docs/dist/plugins/full-width/{full-width/index.min.js → index.min.js} +0 -0
- /package/docs/dist/plugins/scroll-indicator/{scroll-indicator/index.esm.js → index.esm.js} +0 -0
- /package/docs/dist/plugins/scroll-indicator/{scroll-indicator/index.min.js → index.min.js} +0 -0
- /package/docs/dist/plugins/thumbnails/{thumbnails/index.esm.js → index.esm.js} +0 -0
- /package/docs/dist/plugins/thumbnails/{thumbnails/index.min.js → index.min.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"./details.min.js";import{generateId as e,objectsAreEqual as o,getOutermostChildrenEdgeMarginSum as n}from"./utils.min.js";function l(l,i,r){let a,s={};function c(e=!1){const n=a.details,l=t(a);a.details=l,e||o(n,l)?e&&a.emit("detailsChanged"):a.emit("detailsChanged")}function f(){a.slides=Array.from(a.container.querySelectorAll(a.options.slidesSelector))}function d(){a.container.style.setProperty("--slider-container-width",`${a.details.containerWidth}px`),a.container.style.setProperty("--slider-scrollable-width",`${a.details.scrollableAreaWidth}px`),a.container.style.setProperty("--slider-slides-count",`${a.details.slideCount}`)}function h(){a.container.setAttribute("data-has-overflow",a.details.hasOverflow?"true":"false"),a.options.rtl&&a.container.setAttribute("dir","rtl")}function u(t,e=null){const o=e||a.options.scrollBehavior,n=t.getBoundingClientRect(),l=a.container.getBoundingClientRect(),i=a.container.offsetWidth,r=a.container.scrollLeft,s=n.left-l.left+r,c=s+n.width;let f=null;f=Math.floor(s)<Math.floor(r)?s:Math.floor(c)>Math.floor(r)+Math.floor(i)?c-i:0===Math.floor(s)?0:s,null!==f&&setTimeout((t=>{a.emit("programmaticScrollStart"),a.container.scrollTo({left:t,behavior:o})}),50,f)}function g(){const t=a.container.getBoundingClientRect(),e=a.getScrollLeft(),o=a.slides;let n=0,l=!1;if(a.options.rtl){const l=a.getInclusiveScrollWidth()-e-a.getInclusiveClientWidth(),i=[];for(let e=o.length-1;e>=0;e--){const n=o[e].getBoundingClientRect(),r=Math.abs(n.left)-Math.abs(t.left)+l;i.push({slide:o[e],slideEnd:r})}let r=null,s=null;for(let t=0;t<i.length;t++){const e=Math.abs(i[t].slideEnd-l);(null===s||e<s)&&(s=e,r=i[t].slide)}n=r?o.indexOf(r):o.length-1}else for(let i=0;i<o.length;i++){const r=o[i].getBoundingClientRect().left-t.left+e+
|
|
1
|
+
import t from"./details.min.js";import{generateId as e,objectsAreEqual as o,getOutermostChildrenEdgeMarginSum as n}from"./utils.min.js";function l(l,i,r){let a,s={};function c(e=!1){const n=a.details,l=t(a);a.details=l,e||o(n,l)?e&&a.emit("detailsChanged"):a.emit("detailsChanged")}function f(){a.slides=Array.from(a.container.querySelectorAll(a.options.slidesSelector))}function d(){a.container.style.setProperty("--slider-container-width",`${a.details.containerWidth}px`),a.container.style.setProperty("--slider-scrollable-width",`${a.details.scrollableAreaWidth}px`),a.container.style.setProperty("--slider-slides-count",`${a.details.slideCount}`)}function h(){a.container.setAttribute("data-has-overflow",a.details.hasOverflow?"true":"false"),a.options.rtl&&a.container.setAttribute("dir","rtl")}function u(t,e=null){const o=e||a.options.scrollBehavior,n=t.getBoundingClientRect(),l=a.container.getBoundingClientRect(),i=a.container.offsetWidth,r=a.container.scrollLeft,s=n.left-l.left+r,c=s+n.width;let f=null;f=Math.floor(s)<Math.floor(r)?s:Math.floor(c)>Math.floor(r)+Math.floor(i)?c-i:0===Math.floor(s)?0:s,null!==f&&setTimeout((t=>{a.emit("programmaticScrollStart"),a.container.scrollTo({left:t,behavior:o})}),50,f)}function g(){const t=a.container.getBoundingClientRect(),e=a.getScrollLeft(),o=a.slides;let n=0,l=!1;if(a.options.rtl){const l=a.getInclusiveScrollWidth()-e-a.getInclusiveClientWidth(),i=[];for(let e=o.length-1;e>=0;e--){const n=o[e].getBoundingClientRect(),r=Math.abs(n.left)-Math.abs(t.left)+l;i.push({slide:o[e],slideEnd:r})}let r=null,s=null;for(let t=0;t<i.length;t++){const e=Math.abs(i[t].slideEnd-l);(null===s||e<s)&&(s=e,r=i[t].slide)}n=r?o.indexOf(r):o.length-1}else for(let i=0;i<o.length;i++){const r=o[i].getBoundingClientRect().left-t.left+e+v();if(Math.floor(r)>=Math.floor(e)){n=i;break}i===o.length-1&&(l=!0)}l&&(n=o.length-1);const i=a.activeSlideIdx;a.activeSlideIdx=n,i!==n&&a.emit("activeSlideChanged")}function m(t){const e=a.slides[t];e&&u(e)}function M(){return a.options.rtl?Math.abs(a.container.scrollLeft):a.container.scrollLeft}function v(){let t=0;if(a.slides.length>1){const e=a.slides[0].getBoundingClientRect(),o=a.slides[1].getBoundingClientRect();t=a.options.rtl?Math.abs(Math.floor(o.right-e.left)):Math.floor(o.left-e.right)}return t}function p(){let t=0;const e=a.container.getAttribute("data-full-width-offset");return e&&(t=parseInt(e)),Math.floor(t)}return a={emit:function(t){var e;s&&s[t]&&s[t].forEach((t=>{t(a)}));const o=null===(e=null==a?void 0:a.options)||void 0===e?void 0:e[t];"function"==typeof o&&o(a)},moveToDirection:function(t="prev"){const e=a.options.scrollStrategy,o=a.container.scrollLeft,n=a.container.getBoundingClientRect(),l=a.container.offsetWidth;let i=o;const r=a.options.rtl?"prev"===t?"next":"prev":t;if("prev"===r?i=Math.max(0,o-a.container.offsetWidth):"next"===r&&(i=Math.min(a.getInclusiveScrollWidth(),o+a.container.offsetWidth)),"fullSlide"===e){let t=null;if(t="prev"===r?Math.max(0,i-v()):Math.min(a.getInclusiveScrollWidth(),i+v()),"next"===r){let e=!1;for(let l of a.slides){const r=l.getBoundingClientRect(),a=r.left-n.left+o,s=a+r.width;if(Math.floor(a)<Math.floor(i)&&Math.floor(s)>Math.floor(i)){t=a,e=!0;break}}if(e||(t=Math.min(i,a.getInclusiveScrollWidth()-a.container.offsetWidth)),t)if(Math.floor(t)>Math.floor(o)){const e=Math.floor(a.getInclusiveScrollWidth())-Math.floor(l);i=Math.min(t,e)}else i=Math.min(a.getInclusiveScrollWidth(),o+l)}else{let e=!1;for(let i of a.slides){const r=i.getBoundingClientRect(),a=r.left-n.left+o,s=a+r.width;if(Math.floor(a)<Math.floor(o)&&Math.floor(s)>Math.floor(o)){t=s-l,e=!0;break}}e||(t=Math.max(0,o-l)),t&&Math.floor(t)<Math.floor(o)&&(i=t)}}const s=i-p();Math.floor(s)>=0&&(i=s),a.emit("programmaticScrollStart"),a.container.style.scrollBehavior=a.options.scrollBehavior,a.container.scrollLeft=i,setTimeout((()=>a.container.style.scrollBehavior=""),50)},moveToSlide:m,moveToSlideInDirection:function(t){const e=a.activeSlideIdx;"prev"===t?e>0&&m(e-1):"next"===t&&e<a.slides.length-1&&m(e+1)},snapToClosestSlide:function(t="prev"){const e=a.options.rtl?"prev"===t:"next"===t,o=[];for(let t=0;t<a.slides.length;t++){const e=a.slides[t],n=e.offsetWidth,l=a.options.rtl?Math.abs(e.offsetLeft+n-a.details.containerWidth):e.offsetLeft,i=l+n,r=l+n/2,s=Math.min(r,l+a.options.emulateScrollSnapMaxThreshold);o.push({start:l,middle:r,end:i,width:n,trigger:s,slide:e,offSetleft:e.offsetLeft,rect:e.getBoundingClientRect()})}let n=null;const l=M();if(e)for(let t=0;t<o.length;t++){const e=o[t];if(0===t&&Math.floor(l)<=Math.floor(e.trigger)){n=0;break}if(Math.floor(M())<=Math.floor(e.trigger)){n=e.start;break}}else for(let t=o.length-1;t>=0;t--){const e=o[t];if(t===o.length-1&&Math.floor(l)>=Math.floor(e.trigger)){n=e.start;break}if(Math.floor(M())>=Math.floor(e.trigger)){n=e.start;break}}if(null!==n){const t=n-p();Math.floor(t)>=0&&(n=t);const e=a.options.scrollBehavior||"smooth";a.container.scrollTo({left:a.options.rtl?-n:n,behavior:e})}},getInclusiveScrollWidth:function(){return a.container.scrollWidth+n(a.container)},getInclusiveClientWidth:function(){return a.container.clientWidth+n(a.container)},getScrollLeft:M,setScrollLeft:function(t){a.container.scrollLeft=a.options.rtl?-t:t},on:function(t,e){s[t]||(s[t]=[]),s[t].push(e)},options:i},function(){a.container=l;let t=l.getAttribute("id");null===t&&(t=e("overflow-slider"),l.setAttribute("id",t)),f(),c(!0),g(),a.on("contentsChanged",(()=>{f(),c(),g()})),a.on("containerSizeChanged",(()=>c()));let o=0;if(a.on("scroll",(()=>{o&&window.cancelAnimationFrame(o),o=window.requestAnimationFrame((()=>{c(),g()}))})),function(){new MutationObserver((()=>a.emit("contentsChanged"))).observe(a.container,{childList:!0});let t,e,o;new ResizeObserver((()=>a.emit("containerSizeChanged"))).observe(a.container);let n=a.container.scrollLeft,l=a.container.scrollLeft,i=a.container.scrollLeft,r=!1,s=!1,c=!1;a.container.addEventListener("scroll",(()=>{const e=a.container.scrollLeft;Math.floor(n)!==Math.floor(e)&&(r||(r=!0,a.emit("scrollStart")),n=e,clearTimeout(t),t=setTimeout((()=>{r=!1,a.emit("scrollEnd")}),50),a.emit("scroll")),s&&f()}));const f=()=>{const t=a.container.scrollLeft;Math.floor(l)===Math.floor(t)||c||(s||(a.emit("nativeScrollStart"),s=!0),a.emit("nativeScroll"),l=t,clearTimeout(e),e=setTimeout((()=>{s=!1,a.emit("nativeScrollEnd"),i=l}),50))};a.container.addEventListener("touchmove",f),a.container.addEventListener("mousewheel",f),a.container.addEventListener("wheel",f),a.on("programmaticScrollStart",(()=>{c=!0})),a.container.addEventListener("scroll",(()=>{const t=a.container.scrollLeft;Math.floor(i)!==Math.floor(t)&&!s&&c&&(i=t,clearTimeout(o),o=setTimeout((()=>{c=!1,a.emit("programmaticScrollEnd"),l=i}),50),a.emit("programmaticScroll"))})),a.on("programmaticScrollStart",(()=>{a.container.style.scrollSnapType="none"})),a.on("nativeScrollStart",(()=>{a.container.style.scrollSnapType=""}));let d=!1;a.container.addEventListener("mousedown",(()=>{d=!0})),a.container.addEventListener("touchstart",(()=>{d=!0}),{passive:!0}),a.container.addEventListener("focusin",(t=>{if(!d){let e=t.target;for(;e.parentElement!==a.container&&e.parentElement;)e=e.parentElement;u(e,"auto")}d=!1}))}(),h(),d(),r)for(const t of r)t(a);a.on("detailsChanged",(()=>{h(),d()})),a.emit("created"),a.container.setAttribute("data-ready","true")}(),a}export{l as default};
|
|
@@ -12,7 +12,8 @@ function objectsAreEqual(obj1, obj2) {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
for (let key of keys1) {
|
|
15
|
-
|
|
15
|
+
// Use `Object.prototype.hasOwnProperty.call` for better safety
|
|
16
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key) || obj1[key] !== obj2[key]) {
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e
|
|
1
|
+
function t(e,n=1){const r=`${e}-${n}`;return document.getElementById(r)?t(e,n+1):r}function e(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1;return!0}function n(t){if(0===t.children.length)return 0;const e=t.children[0],n=getComputedStyle(e),r=parseFloat(n.marginLeft),o=t.children[t.children.length-1],l=getComputedStyle(o);return r+parseFloat(l.marginRight)}export{t as generateId,n as getOutermostChildrenEdgeMarginSum,e as objectsAreEqual};
|
|
@@ -13,7 +13,7 @@ const DEFAULT_CLASS_NAMES = {
|
|
|
13
13
|
};
|
|
14
14
|
function ArrowsPlugin(args) {
|
|
15
15
|
return (slider) => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
17
17
|
const options = {
|
|
18
18
|
texts: Object.assign(Object.assign({}, DEFAULT_TEXTS), (args === null || args === void 0 ? void 0 : args.texts) || []),
|
|
19
19
|
icons: Object.assign(Object.assign({}, DEFAULT_ICONS), (args === null || args === void 0 ? void 0 : args.icons) || []),
|
|
@@ -21,6 +21,7 @@ function ArrowsPlugin(args) {
|
|
|
21
21
|
container: (_a = args === null || args === void 0 ? void 0 : args.container) !== null && _a !== void 0 ? _a : null,
|
|
22
22
|
containerPrev: (_b = args === null || args === void 0 ? void 0 : args.containerPrev) !== null && _b !== void 0 ? _b : null,
|
|
23
23
|
containerNext: (_c = args === null || args === void 0 ? void 0 : args.containerNext) !== null && _c !== void 0 ? _c : null,
|
|
24
|
+
movementType: (_d = args === null || args === void 0 ? void 0 : args.movementType) !== null && _d !== void 0 ? _d : 'view',
|
|
24
25
|
};
|
|
25
26
|
const nav = document.createElement('div');
|
|
26
27
|
nav.classList.add(options.classNames.navContainer);
|
|
@@ -28,24 +29,24 @@ function ArrowsPlugin(args) {
|
|
|
28
29
|
prev.setAttribute('class', options.classNames.prevButton);
|
|
29
30
|
prev.setAttribute('type', 'button');
|
|
30
31
|
prev.setAttribute('aria-label', options.texts.buttonPrevious);
|
|
31
|
-
prev.setAttribute('aria-controls', (
|
|
32
|
+
prev.setAttribute('aria-controls', (_e = slider.container.getAttribute('id')) !== null && _e !== void 0 ? _e : '');
|
|
32
33
|
prev.setAttribute('data-type', 'prev');
|
|
33
34
|
prev.innerHTML = slider.options.rtl ? options.icons.next : options.icons.prev;
|
|
34
35
|
prev.addEventListener('click', () => {
|
|
35
36
|
if (prev.getAttribute('data-has-content') === 'true') {
|
|
36
|
-
slider.moveToDirection('prev');
|
|
37
|
+
options.movementType === 'slide' ? slider.moveToSlideInDirection('prev') : slider.moveToDirection('prev');
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
const next = document.createElement('button');
|
|
40
41
|
next.setAttribute('class', options.classNames.nextButton);
|
|
41
42
|
next.setAttribute('type', 'button');
|
|
42
43
|
next.setAttribute('aria-label', options.texts.buttonNext);
|
|
43
|
-
next.setAttribute('aria-controls', (
|
|
44
|
+
next.setAttribute('aria-controls', (_f = slider.container.getAttribute('id')) !== null && _f !== void 0 ? _f : '');
|
|
44
45
|
next.setAttribute('data-type', 'next');
|
|
45
46
|
next.innerHTML = slider.options.rtl ? options.icons.prev : options.icons.next;
|
|
46
47
|
next.addEventListener('click', () => {
|
|
47
48
|
if (next.getAttribute('data-has-content') === 'true') {
|
|
48
|
-
slider.moveToDirection('next');
|
|
49
|
+
options.movementType === 'slide' ? slider.moveToSlideInDirection('next') : slider.moveToDirection('next');
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
// insert buttons to the nav
|
|
@@ -69,7 +70,6 @@ function ArrowsPlugin(args) {
|
|
|
69
70
|
else {
|
|
70
71
|
next.setAttribute('data-has-content', 'true');
|
|
71
72
|
}
|
|
72
|
-
console.log('next', scrollLeft + clientWidth, scrollWidth);
|
|
73
73
|
};
|
|
74
74
|
if (options.containerNext && options.containerPrev) {
|
|
75
75
|
options.containerPrev.appendChild(prev);
|
|
@@ -80,7 +80,7 @@ function ArrowsPlugin(args) {
|
|
|
80
80
|
options.container.appendChild(nav);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
(
|
|
83
|
+
(_g = slider.container.parentNode) === null || _g === void 0 ? void 0 : _g.insertBefore(nav, slider.container.nextSibling);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
update();
|
|
@@ -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,d;const v={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,movementType:null!==(l=null==o?void 0:o.movementType)&&void 0!==l?l:"view"},b=document.createElement("div");b.classList.add(v.classNames.navContainer);const p=document.createElement("button");p.setAttribute("class",v.classNames.prevButton),p.setAttribute("type","button"),p.setAttribute("aria-label",v.texts.buttonPrevious),p.setAttribute("aria-controls",null!==(c=i.container.getAttribute("id"))&&void 0!==c?c:""),p.setAttribute("data-type","prev"),p.innerHTML=i.options.rtl?v.icons.next:v.icons.prev,p.addEventListener("click",(()=>{"true"===p.getAttribute("data-has-content")&&("slide"===v.movementType?i.moveToSlideInDirection("prev"):i.moveToDirection("prev"))}));const h=document.createElement("button");h.setAttribute("class",v.classNames.nextButton),h.setAttribute("type","button"),h.setAttribute("aria-label",v.texts.buttonNext),h.setAttribute("aria-controls",null!==(u=i.container.getAttribute("id"))&&void 0!==u?u:""),h.setAttribute("data-type","next"),h.innerHTML=i.options.rtl?v.icons.prev:v.icons.next,h.addEventListener("click",(()=>{"true"===h.getAttribute("data-has-content")&&("slide"===v.movementType?i.moveToSlideInDirection("next"):i.moveToDirection("next"))})),b.appendChild(p),b.appendChild(h);const m=()=>{const t=i.getScrollLeft(),e=i.getInclusiveScrollWidth(),n=i.getInclusiveClientWidth();0===Math.floor(t)?p.setAttribute("data-has-content","false"):p.setAttribute("data-has-content","true");Math.abs(Math.floor(t+n)-Math.floor(e))<=1?h.setAttribute("data-has-content","false"):h.setAttribute("data-has-content","true")};v.containerNext&&v.containerPrev?(v.containerPrev.appendChild(p),v.containerNext.appendChild(h)):v.container?v.container.appendChild(b):null===(d=i.container.parentNode)||void 0===d||d.insertBefore(b,i.container.nextSibling),m(),i.on("scrollEnd",m),i.on("contentsChanged",m),i.on("containerSizeChanged",m)}}export{o 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};
|
package/docs/index-rtl.html
CHANGED
|
@@ -121,6 +121,22 @@
|
|
|
121
121
|
<a href="#12" class="example-item example-item--12">12</a>
|
|
122
122
|
<a href="#13" class="example-item example-item--13">13</a>
|
|
123
123
|
</div>
|
|
124
|
+
<p style="margin-top:1.5rem;">Arrows can move also one slide at a time with "movementType" set to "slide".</p>
|
|
125
|
+
<div class="overflow-slider example-container example-container-1-arrows-by-slide">
|
|
126
|
+
<a href="#1" class="example-item example-item--1">1</a>
|
|
127
|
+
<a href="#2" class="example-item example-item--2">2</a>
|
|
128
|
+
<a href="#3" class="example-item example-item--3">3</a>
|
|
129
|
+
<a href="#4" class="example-item example-item--4">4</a>
|
|
130
|
+
<a href="#5" class="example-item example-item--5">5</a>
|
|
131
|
+
<a href="#6" class="example-item example-item--6">6</a>
|
|
132
|
+
<a href="#7" class="example-item example-item--7">7</a>
|
|
133
|
+
<a href="#8" class="example-item example-item--8">8</a>
|
|
134
|
+
<a href="#9" class="example-item example-item--9">9</a>
|
|
135
|
+
<a href="#10" class="example-item example-item--10">10</a>
|
|
136
|
+
<a href="#11" class="example-item example-item--11">11</a>
|
|
137
|
+
<a href="#12" class="example-item example-item--12">12</a>
|
|
138
|
+
<a href="#13" class="example-item example-item--13">13</a>
|
|
139
|
+
</div>
|
|
124
140
|
</div>
|
|
125
141
|
|
|
126
142
|
<div class="entry__item">
|
package/docs/index.html
CHANGED
|
@@ -121,6 +121,22 @@
|
|
|
121
121
|
<a href="#12" class="example-item example-item--12">12</a>
|
|
122
122
|
<a href="#13" class="example-item example-item--13">13</a>
|
|
123
123
|
</div>
|
|
124
|
+
<p style="margin-top:1.5rem;">Arrows can move also one slide at a time with "movementType" set to "slide".</p>
|
|
125
|
+
<div class="overflow-slider example-container example-container-1-arrows-by-slide">
|
|
126
|
+
<a href="#1" class="example-item example-item--1">1</a>
|
|
127
|
+
<a href="#2" class="example-item example-item--2">2</a>
|
|
128
|
+
<a href="#3" class="example-item example-item--3">3</a>
|
|
129
|
+
<a href="#4" class="example-item example-item--4">4</a>
|
|
130
|
+
<a href="#5" class="example-item example-item--5">5</a>
|
|
131
|
+
<a href="#6" class="example-item example-item--6">6</a>
|
|
132
|
+
<a href="#7" class="example-item example-item--7">7</a>
|
|
133
|
+
<a href="#8" class="example-item example-item--8">8</a>
|
|
134
|
+
<a href="#9" class="example-item example-item--9">9</a>
|
|
135
|
+
<a href="#10" class="example-item example-item--10">10</a>
|
|
136
|
+
<a href="#11" class="example-item example-item--11">11</a>
|
|
137
|
+
<a href="#12" class="example-item example-item--12">12</a>
|
|
138
|
+
<a href="#13" class="example-item example-item--13">13</a>
|
|
139
|
+
</div>
|
|
124
140
|
</div>
|
|
125
141
|
|
|
126
142
|
<div class="entry__item">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evermade/overflow-slider",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Accessible slider tha works with overflow: auto.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,36 +12,36 @@
|
|
|
12
12
|
"require": "./dist/index.min.js"
|
|
13
13
|
},
|
|
14
14
|
"./plugins/drag-scrolling": {
|
|
15
|
-
"import": "./dist/plugins/drag-scrolling/
|
|
16
|
-
"require": "./dist/plugins/drag-scrolling/
|
|
15
|
+
"import": "./dist/plugins/drag-scrolling/index.esm.js",
|
|
16
|
+
"require": "./dist/plugins/drag-scrolling/index.min.js"
|
|
17
17
|
},
|
|
18
18
|
"./plugins/skip-links": {
|
|
19
|
-
"import": "./dist/plugins/skip-links/
|
|
20
|
-
"require": "./dist/plugins/skip-links/
|
|
19
|
+
"import": "./dist/plugins/skip-links/index.esm.js",
|
|
20
|
+
"require": "./dist/plugins/skip-links/index.min.js"
|
|
21
21
|
},
|
|
22
22
|
"./plugins/scroll-indicator": {
|
|
23
|
-
"import": "./dist/plugins/scroll-indicator/
|
|
24
|
-
"require": "./dist/plugins/scroll-indicator/
|
|
23
|
+
"import": "./dist/plugins/scroll-indicator/index.esm.js",
|
|
24
|
+
"require": "./dist/plugins/scroll-indicator/index.min.js"
|
|
25
25
|
},
|
|
26
26
|
"./plugins/arrows": {
|
|
27
|
-
"import": "./dist/plugins/arrows/
|
|
28
|
-
"require": "./dist/plugins/arrows/
|
|
27
|
+
"import": "./dist/plugins/arrows/index.esm.js",
|
|
28
|
+
"require": "./dist/plugins/arrows/index.min.js"
|
|
29
29
|
},
|
|
30
30
|
"./plugins/full-width": {
|
|
31
|
-
"import": "./dist/plugins/full-width/
|
|
32
|
-
"require": "./dist/plugins/full-width/
|
|
31
|
+
"import": "./dist/plugins/full-width/index.esm.js",
|
|
32
|
+
"require": "./dist/plugins/full-width/index.min.js"
|
|
33
33
|
},
|
|
34
34
|
"./plugins/dots": {
|
|
35
|
-
"import": "./dist/plugins/dots/
|
|
36
|
-
"require": "./dist/plugins/dots/
|
|
35
|
+
"import": "./dist/plugins/dots/index.esm.js",
|
|
36
|
+
"require": "./dist/plugins/dots/index.min.js"
|
|
37
37
|
},
|
|
38
38
|
"./plugins/thumbnails": {
|
|
39
|
-
"import": "./dist/plugins/thumbnails/
|
|
40
|
-
"require": "./dist/plugins/thumbnails/
|
|
39
|
+
"import": "./dist/plugins/thumbnails/index.esm.js",
|
|
40
|
+
"require": "./dist/plugins/thumbnails/index.min.js"
|
|
41
41
|
},
|
|
42
42
|
"./plugins/fade": {
|
|
43
|
-
"import": "./dist/plugins/fade/
|
|
44
|
-
"require": "./dist/plugins/fade/
|
|
43
|
+
"import": "./dist/plugins/fade/index.esm.js",
|
|
44
|
+
"require": "./dist/plugins/fade/index.min.js"
|
|
45
45
|
},
|
|
46
46
|
"./style.css": "./dist/overflow-slider.css"
|
|
47
47
|
},
|
package/rollup.config.js
CHANGED
|
@@ -35,9 +35,9 @@ const plugins = [
|
|
|
35
35
|
const pluginEntries = {
|
|
36
36
|
index: 'src/index.ts', // Adding the core file
|
|
37
37
|
...glob.sync('src/plugins/**/*.ts').reduce((entries, path) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const name = path.replace(/^src\/plugins\//, '').replace(/\.ts$/, '');
|
|
39
|
+
entries[name] = path;
|
|
40
|
+
return entries;
|
|
41
41
|
}, {}),
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -53,7 +53,11 @@ export default [
|
|
|
53
53
|
...baseOutput,
|
|
54
54
|
dir: 'dist',
|
|
55
55
|
format: 'es',
|
|
56
|
-
entryFileNames:
|
|
56
|
+
entryFileNames: (chunkInfo) => {
|
|
57
|
+
return chunkInfo.facadeModuleId.includes('/src/plugins/')
|
|
58
|
+
? 'index.esm.js'
|
|
59
|
+
: '[name].esm.js';
|
|
60
|
+
},
|
|
57
61
|
},
|
|
58
62
|
plugins,
|
|
59
63
|
},
|
|
@@ -63,7 +67,11 @@ export default [
|
|
|
63
67
|
...baseOutput,
|
|
64
68
|
dir: 'dist',
|
|
65
69
|
format: 'es',
|
|
66
|
-
entryFileNames:
|
|
70
|
+
entryFileNames: (chunkInfo) => {
|
|
71
|
+
return chunkInfo.facadeModuleId.includes('/src/plugins/')
|
|
72
|
+
? 'index.min.js'
|
|
73
|
+
: '[name].min.js';
|
|
74
|
+
},
|
|
67
75
|
plugins: [terser()],
|
|
68
76
|
},
|
|
69
77
|
plugins,
|
package/src/core/slider.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Slider, SliderOptions, SliderPlugin } from './types';
|
|
1
|
+
import { Slider, SliderOptions, SliderPlugin, SliderCallback } from './types';
|
|
2
2
|
import details from './details';
|
|
3
3
|
import { generateId, objectsAreEqual, getOutermostChildrenEdgeMarginSum } from './utils';
|
|
4
4
|
|
|
5
5
|
export default function Slider( container: HTMLElement, options : SliderOptions, plugins? : SliderPlugin[] ) {
|
|
6
6
|
let slider: Slider;
|
|
7
|
-
let subs: { [key: string]:
|
|
7
|
+
let subs: { [key: string]: SliderCallback[] } = {};
|
|
8
8
|
|
|
9
9
|
function init() {
|
|
10
10
|
slider.container = container;
|
|
@@ -91,7 +91,7 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
91
91
|
let isUserScrolling = false;
|
|
92
92
|
let isProgrammaticScrolling = false;
|
|
93
93
|
|
|
94
|
-
//
|
|
94
|
+
// all types of scroll
|
|
95
95
|
slider.container.addEventListener('scroll', () => {
|
|
96
96
|
const newScrollLeft = slider.container.scrollLeft;
|
|
97
97
|
if ( Math.floor( scrollLeft ) !== Math.floor( newScrollLeft ) ) {
|
|
@@ -292,8 +292,6 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
292
292
|
const oldActiveSlideIdx = slider.activeSlideIdx;
|
|
293
293
|
slider.activeSlideIdx = activeSlideIdx;
|
|
294
294
|
|
|
295
|
-
// console.log('activeSlideIdx', activeSlideIdx);
|
|
296
|
-
|
|
297
295
|
if (oldActiveSlideIdx !== activeSlideIdx) {
|
|
298
296
|
slider.emit('activeSlideChanged');
|
|
299
297
|
}
|
|
@@ -307,6 +305,19 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
307
305
|
}
|
|
308
306
|
};
|
|
309
307
|
|
|
308
|
+
function moveToSlideInDirection( direction: 'prev' | 'next' ) {
|
|
309
|
+
const activeSlideIdx = slider.activeSlideIdx;
|
|
310
|
+
if (direction === 'prev') {
|
|
311
|
+
if (activeSlideIdx > 0) {
|
|
312
|
+
moveToSlide(activeSlideIdx - 1);
|
|
313
|
+
}
|
|
314
|
+
} else if (direction === 'next') {
|
|
315
|
+
if (activeSlideIdx < slider.slides.length - 1) {
|
|
316
|
+
moveToSlide(activeSlideIdx + 1);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
310
321
|
function getInclusiveScrollWidth() : number {
|
|
311
322
|
return slider.container.scrollWidth + getOutermostChildrenEdgeMarginSum(slider.container);
|
|
312
323
|
};
|
|
@@ -447,7 +458,6 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
447
458
|
rect: slide.getBoundingClientRect(),
|
|
448
459
|
});
|
|
449
460
|
}
|
|
450
|
-
console.log('slideReference', slideReference);
|
|
451
461
|
let snapTarget = null;
|
|
452
462
|
const scrollPosition = getScrollLeft();
|
|
453
463
|
if (isMovingForward) {
|
|
@@ -490,7 +500,7 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
490
500
|
}
|
|
491
501
|
};
|
|
492
502
|
|
|
493
|
-
function on(name: string, cb:
|
|
503
|
+
function on(name: string, cb: SliderCallback) {
|
|
494
504
|
if (!subs[name]) {
|
|
495
505
|
subs[name] = [];
|
|
496
506
|
}
|
|
@@ -500,12 +510,14 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
500
510
|
function emit(name: string) {
|
|
501
511
|
if (subs && subs[name]) {
|
|
502
512
|
subs[name].forEach(cb => {
|
|
503
|
-
|
|
513
|
+
cb(slider);
|
|
504
514
|
});
|
|
505
515
|
}
|
|
516
|
+
|
|
506
517
|
const optionCallBack = slider?.options?.[name];
|
|
518
|
+
// Type guard to check if the option callback is a function
|
|
507
519
|
if (typeof optionCallBack === 'function') {
|
|
508
|
-
|
|
520
|
+
(optionCallBack as SliderCallback)(slider); // Type assertion here
|
|
509
521
|
}
|
|
510
522
|
};
|
|
511
523
|
|
|
@@ -513,6 +525,7 @@ export default function Slider( container: HTMLElement, options : SliderOptions,
|
|
|
513
525
|
emit,
|
|
514
526
|
moveToDirection,
|
|
515
527
|
moveToSlide,
|
|
528
|
+
moveToSlideInDirection,
|
|
516
529
|
snapToClosestSlide,
|
|
517
530
|
getInclusiveScrollWidth,
|
|
518
531
|
getInclusiveClientWidth,
|
package/src/core/types.ts
CHANGED
|
@@ -5,6 +5,9 @@ export type Slider<O = {}, C = {}, H extends string = string> = {
|
|
|
5
5
|
moveToDirection: (
|
|
6
6
|
direction: 'prev' | 'next'
|
|
7
7
|
) => void
|
|
8
|
+
moveToSlideInDirection: (
|
|
9
|
+
direction: 'prev' | 'next'
|
|
10
|
+
) => void
|
|
8
11
|
snapToClosestSlide: (
|
|
9
12
|
direction: 'prev' | 'next'
|
|
10
13
|
) => void
|
|
@@ -17,13 +20,17 @@ export type Slider<O = {}, C = {}, H extends string = string> = {
|
|
|
17
20
|
setScrollLeft: (value: number) => void
|
|
18
21
|
on: (
|
|
19
22
|
name: H | SliderHooks,
|
|
20
|
-
cb:
|
|
23
|
+
cb: SliderCallback
|
|
21
24
|
) => void
|
|
22
25
|
options: SliderOptions,
|
|
23
26
|
details: SliderDetails,
|
|
24
27
|
activeSlideIdx: number,
|
|
25
28
|
} & C;
|
|
26
29
|
|
|
30
|
+
export type SliderCallback<O = {}, C = {}, H extends string = string> = (
|
|
31
|
+
props: Slider<O, C, H>
|
|
32
|
+
) => void;
|
|
33
|
+
|
|
27
34
|
export type SliderOptions = {
|
|
28
35
|
scrollBehavior: string;
|
|
29
36
|
scrollStrategy: string;
|
|
@@ -31,7 +38,7 @@ export type SliderOptions = {
|
|
|
31
38
|
emulateScrollSnap: boolean;
|
|
32
39
|
emulateScrollSnapMaxThreshold: number;
|
|
33
40
|
rtl: boolean;
|
|
34
|
-
[key: string]:
|
|
41
|
+
[key: string]: unknown;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
export type SliderDetails = {
|
|
@@ -65,7 +72,7 @@ export type HOOK_CONTENTS_CHANGED = 'contentsChanged';
|
|
|
65
72
|
export type HOOK_CONTAINER_SIZE_CHANGED = 'containerSizeChanged';
|
|
66
73
|
export type HOOK_ACTIVE_SLIDE_CHANGED = 'activeSlideChanged';
|
|
67
74
|
|
|
68
|
-
//
|
|
75
|
+
// all types of scroll
|
|
69
76
|
export type HOOK_SCROLL_START = 'scrollStart';
|
|
70
77
|
export type HOOK_SCROLL = 'scroll';
|
|
71
78
|
export type HOOK_SCROLL_END = 'scrollEnd';
|
package/src/core/utils.ts
CHANGED
|
@@ -7,17 +7,21 @@ function generateId( prefix : string, i = 1 ): string {
|
|
|
7
7
|
return id;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function objectsAreEqual(
|
|
10
|
+
function objectsAreEqual(obj1: Record<string, unknown>, obj2: Record<string, unknown>): boolean {
|
|
11
11
|
const keys1 = Object.keys(obj1);
|
|
12
12
|
const keys2 = Object.keys(obj2);
|
|
13
|
+
|
|
13
14
|
if (keys1.length !== keys2.length) {
|
|
14
|
-
|
|
15
|
+
return false;
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
for (let key of keys1) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
// Use `Object.prototype.hasOwnProperty.call` for better safety
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key) || obj1[key] !== obj2[key]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
20
23
|
}
|
|
24
|
+
|
|
21
25
|
return true;
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -16,6 +16,8 @@ const DEFAULT_CLASS_NAMES = {
|
|
|
16
16
|
nextButton: 'overflow-slider__arrows-button overflow-slider__arrows-button--next',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
export type ArrowsMovementTypes = 'view' | 'slide';
|
|
20
|
+
|
|
19
21
|
export type ArrowsOptions = {
|
|
20
22
|
texts: {
|
|
21
23
|
buttonPrevious: string;
|
|
@@ -33,9 +35,10 @@ export type ArrowsOptions = {
|
|
|
33
35
|
container: HTMLElement | null,
|
|
34
36
|
containerPrev: HTMLElement | null,
|
|
35
37
|
containerNext: HTMLElement | null,
|
|
38
|
+
movementType: ArrowsMovementTypes,
|
|
36
39
|
};
|
|
37
40
|
|
|
38
|
-
export default function ArrowsPlugin( args: { [key: string]:
|
|
41
|
+
export default function ArrowsPlugin( args: { [key: string]: unknown } ) {
|
|
39
42
|
return ( slider: Slider ) => {
|
|
40
43
|
|
|
41
44
|
const options = <ArrowsOptions>{
|
|
@@ -54,6 +57,7 @@ export default function ArrowsPlugin( args: { [key: string]: any } ) {
|
|
|
54
57
|
container: args?.container ?? null,
|
|
55
58
|
containerPrev: args?.containerPrev ?? null,
|
|
56
59
|
containerNext: args?.containerNext ?? null,
|
|
60
|
+
movementType: args?.movementType ?? 'view',
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
const nav = document.createElement( 'div' );
|
|
@@ -68,7 +72,7 @@ export default function ArrowsPlugin( args: { [key: string]: any } ) {
|
|
|
68
72
|
prev.innerHTML = slider.options.rtl ? options.icons.next : options.icons.prev;
|
|
69
73
|
prev.addEventListener( 'click', () => {
|
|
70
74
|
if ( prev.getAttribute('data-has-content') === 'true' ) {
|
|
71
|
-
slider.moveToDirection( 'prev' );
|
|
75
|
+
options.movementType === 'slide' ? slider.moveToSlideInDirection( 'prev' ) : slider.moveToDirection( 'prev' );
|
|
72
76
|
}
|
|
73
77
|
} );
|
|
74
78
|
|
|
@@ -81,7 +85,7 @@ export default function ArrowsPlugin( args: { [key: string]: any } ) {
|
|
|
81
85
|
next.innerHTML = slider.options.rtl ? options.icons.prev : options.icons.next;
|
|
82
86
|
next.addEventListener( 'click', () => {
|
|
83
87
|
if ( next.getAttribute('data-has-content') === 'true' ) {
|
|
84
|
-
slider.moveToDirection( 'next' );
|
|
88
|
+
options.movementType === 'slide' ? slider.moveToSlideInDirection( 'next' ) : slider.moveToDirection( 'next' );
|
|
85
89
|
}
|
|
86
90
|
} );
|
|
87
91
|
|
|
@@ -105,7 +109,6 @@ export default function ArrowsPlugin( args: { [key: string]: any } ) {
|
|
|
105
109
|
} else {
|
|
106
110
|
next.setAttribute( 'data-has-content', 'true' );
|
|
107
111
|
}
|
|
108
|
-
console.log( 'next', scrollLeft + clientWidth, scrollWidth );
|
|
109
112
|
};
|
|
110
113
|
|
|
111
114
|
if ( options.containerNext && options.containerPrev ) {
|
|
@@ -20,7 +20,7 @@ const DEFAULT_CLASS_NAMES = {
|
|
|
20
20
|
dotsItem: 'overflow-slider__dot-item',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export default function DotsPlugin( args: { [key: string]:
|
|
23
|
+
export default function DotsPlugin( args: { [key: string]: unknown } ) {
|
|
24
24
|
return ( slider: Slider ) => {
|
|
25
25
|
const options = <DotsOptions>{
|
|
26
26
|
texts: {
|
|
@@ -6,7 +6,7 @@ export type DragScrollingOptions = {
|
|
|
6
6
|
draggedDistanceThatPreventsClick: number,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export default function DragScrollingPlugin( args: { [key: string]:
|
|
9
|
+
export default function DragScrollingPlugin( args: { [key: string]: unknown } ) {
|
|
10
10
|
const options = <DragScrollingOptions>{
|
|
11
11
|
draggedDistanceThatPreventsClick: args?.draggedDistanceThatPreventsClick ?? DEFAULT_DRAGGED_DISTANCE_THAT_PREVENTS_CLICK,
|
|
12
12
|
};
|
|
@@ -11,7 +11,7 @@ export type FadeOptions = {
|
|
|
11
11
|
containerEnd: HTMLElement | null,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export default function FadePlugin( args: { [key: string]:
|
|
14
|
+
export default function FadePlugin( args: { [key: string]: unknown } ) {
|
|
15
15
|
return ( slider: Slider ) => {
|
|
16
16
|
|
|
17
17
|
const options = <FadeOptions>{
|
|
@@ -8,7 +8,7 @@ export type FullWidthOptions = {
|
|
|
8
8
|
addMarginAfter: boolean,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export default function FullWidthPlugin( args: { [key: string]:
|
|
11
|
+
export default function FullWidthPlugin( args: { [key: string]: unknown } ) {
|
|
12
12
|
return ( slider: Slider ) => {
|
|
13
13
|
|
|
14
14
|
const options = <FullWidthOptions>{
|
|
@@ -15,7 +15,7 @@ export type ScrollIndicatorOptions = {
|
|
|
15
15
|
container: HTMLElement | null,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export default function ScrollIndicatorPlugin(args: { [key: string]:
|
|
18
|
+
export default function ScrollIndicatorPlugin(args: { [key: string]: unknown }) {
|
|
19
19
|
return (slider: Slider) => {
|
|
20
20
|
|
|
21
21
|
const options = <ScrollIndicatorOptions>{
|
|
@@ -22,7 +22,7 @@ export type SkipLinkOptions = {
|
|
|
22
22
|
containerAfter: HTMLElement | null,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export default function SkipLinksPlugin( args: { [key: string]:
|
|
25
|
+
export default function SkipLinksPlugin( args: { [key: string]: unknown } ) {
|
|
26
26
|
return ( slider: Slider ) => {
|
|
27
27
|
const options = <SkipLinkOptions>{
|
|
28
28
|
texts: {
|
|
@@ -4,7 +4,7 @@ export type ThumbnailsOptions = {
|
|
|
4
4
|
mainSlider: Slider,
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export default function FullWidthPlugin( args: { [key: string]:
|
|
7
|
+
export default function FullWidthPlugin( args: { [key: string]: unknown } ) {
|
|
8
8
|
return ( slider: Slider ) => {
|
|
9
9
|
|
|
10
10
|
const options = <ThumbnailsOptions>{
|
|
@@ -1 +0,0 @@
|
|
|
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 s=>{var i,r,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!==(i=null==o?void 0:o.container)&&void 0!==i?i:null,containerPrev:null!==(r=null==o?void 0:o.containerPrev)&&void 0!==r?r: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=s.container.getAttribute("id"))&&void 0!==l?l:""),b.setAttribute("data-type","prev"),b.innerHTML=s.options.rtl?d.icons.next:d.icons.prev,b.addEventListener("click",(()=>{"true"===b.getAttribute("data-has-content")&&s.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=s.container.getAttribute("id"))&&void 0!==c?c:""),p.setAttribute("data-type","next"),p.innerHTML=s.options.rtl?d.icons.prev:d.icons.next,p.addEventListener("click",(()=>{"true"===p.getAttribute("data-has-content")&&s.moveToDirection("next")})),v.appendChild(b),v.appendChild(p);const h=()=>{const t=s.getScrollLeft(),e=s.getInclusiveScrollWidth(),n=s.getInclusiveClientWidth();0===Math.floor(t)?b.setAttribute("data-has-content","false"):b.setAttribute("data-has-content","true");Math.abs(Math.floor(t+n)-Math.floor(e))<=1?p.setAttribute("data-has-content","false"):p.setAttribute("data-has-content","true"),console.log("next",t+n,e)};d.containerNext&&d.containerPrev?(d.containerPrev.appendChild(b),d.containerNext.appendChild(p)):d.container?d.container.appendChild(v):null===(u=s.container.parentNode)||void 0===u||u.insertBefore(v,s.container.nextSibling),h(),s.on("scrollEnd",h),s.on("contentsChanged",h),s.on("containerSizeChanged",h)}}export{o as default};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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 s=>{var i,r,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!==(i=null==o?void 0:o.container)&&void 0!==i?i:null,containerPrev:null!==(r=null==o?void 0:o.containerPrev)&&void 0!==r?r: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=s.container.getAttribute("id"))&&void 0!==l?l:""),b.setAttribute("data-type","prev"),b.innerHTML=s.options.rtl?d.icons.next:d.icons.prev,b.addEventListener("click",(()=>{"true"===b.getAttribute("data-has-content")&&s.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=s.container.getAttribute("id"))&&void 0!==c?c:""),p.setAttribute("data-type","next"),p.innerHTML=s.options.rtl?d.icons.prev:d.icons.next,p.addEventListener("click",(()=>{"true"===p.getAttribute("data-has-content")&&s.moveToDirection("next")})),v.appendChild(b),v.appendChild(p);const h=()=>{const t=s.getScrollLeft(),e=s.getInclusiveScrollWidth(),n=s.getInclusiveClientWidth();0===Math.floor(t)?b.setAttribute("data-has-content","false"):b.setAttribute("data-has-content","true");Math.abs(Math.floor(t+n)-Math.floor(e))<=1?p.setAttribute("data-has-content","false"):p.setAttribute("data-has-content","true"),console.log("next",t+n,e)};d.containerNext&&d.containerPrev?(d.containerPrev.appendChild(b),d.containerNext.appendChild(p)):d.container?d.container.appendChild(v):null===(u=s.container.parentNode)||void 0===u||u.insertBefore(v,s.container.nextSibling),h(),s.on("scrollEnd",h),s.on("contentsChanged",h),s.on("containerSizeChanged",h)}}export{o as default};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|