@evermade/overflow-slider 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -8
- package/dist/core/details.esm.js +5 -5
- package/dist/core/details.min.js +1 -1
- package/dist/core/overflow-slider.esm.js +1 -0
- package/dist/core/overflow-slider.min.js +1 -1
- package/dist/core/slider.esm.js +113 -44
- package/dist/core/slider.min.js +1 -1
- package/dist/core/utils.esm.js +15 -1
- package/dist/core/utils.min.js +1 -1
- package/dist/overflow-slider.css +1 -1
- package/dist/plugins/arrows/arrows/index.esm.js +20 -10
- package/dist/plugins/arrows/arrows/index.min.js +1 -1
- package/dist/plugins/dots/dots/index.esm.js +0 -4
- package/dist/plugins/drag-scrolling/drag-scrolling/index.esm.js +1 -1
- package/dist/plugins/drag-scrolling/drag-scrolling/index.min.js +1 -1
- package/dist/plugins/fade/fade/index.esm.js +7 -7
- package/dist/plugins/fade/fade/index.min.js +1 -1
- package/dist/plugins/full-width/full-width/index.esm.js +7 -2
- package/dist/plugins/full-width/full-width/index.min.js +1 -1
- package/dist/plugins/scroll-indicator/scroll-indicator/index.esm.js +22 -22
- package/dist/plugins/scroll-indicator/scroll-indicator/index.min.js +1 -1
- package/dist/plugins/thumbnails/thumbnails/index.esm.js +7 -4
- package/dist/plugins/thumbnails/thumbnails/index.min.js +1 -1
- package/docs/assets/demo.css +11 -1
- package/docs/assets/demo.js +38 -12
- package/docs/dist/core/details.esm.js +5 -5
- package/docs/dist/core/details.min.js +1 -1
- package/docs/dist/core/overflow-slider.esm.js +1 -0
- package/docs/dist/core/overflow-slider.min.js +1 -1
- package/docs/dist/core/slider.esm.js +113 -44
- package/docs/dist/core/slider.min.js +1 -1
- package/docs/dist/core/utils.esm.js +15 -1
- package/docs/dist/core/utils.min.js +1 -1
- package/docs/dist/overflow-slider.css +1 -1
- package/docs/dist/plugins/arrows/arrows/index.esm.js +20 -10
- package/docs/dist/plugins/arrows/arrows/index.min.js +1 -1
- package/docs/dist/plugins/dots/dots/index.esm.js +0 -4
- package/docs/dist/plugins/drag-scrolling/drag-scrolling/index.esm.js +1 -1
- package/docs/dist/plugins/drag-scrolling/drag-scrolling/index.min.js +1 -1
- package/docs/dist/plugins/fade/fade/index.esm.js +7 -7
- package/docs/dist/plugins/fade/fade/index.min.js +1 -1
- package/docs/dist/plugins/full-width/full-width/index.esm.js +7 -2
- package/docs/dist/plugins/full-width/full-width/index.min.js +1 -1
- package/docs/dist/plugins/scroll-indicator/scroll-indicator/index.esm.js +22 -22
- package/docs/dist/plugins/scroll-indicator/scroll-indicator/index.min.js +1 -1
- package/docs/dist/plugins/thumbnails/thumbnails/index.esm.js +7 -4
- package/docs/dist/plugins/thumbnails/thumbnails/index.min.js +1 -1
- package/docs/index-rtl.html +396 -0
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/core/details.ts +5 -5
- package/src/core/overflow-slider.ts +1 -0
- package/src/core/slider.ts +125 -47
- package/src/core/types.ts +5 -0
- package/src/core/utils.ts +19 -1
- package/src/plugins/arrows/index.ts +20 -10
- package/src/plugins/dots/index.ts +0 -4
- package/src/plugins/drag-scrolling/index.ts +1 -1
- package/src/plugins/fade/index.ts +7 -8
- package/src/plugins/fade/styles.scss +10 -0
- package/src/plugins/full-width/index.ts +8 -2
- package/src/plugins/scroll-indicator/index.ts +62 -64
- package/src/plugins/thumbnails/index.ts +7 -5
|
@@ -30,36 +30,46 @@ function ArrowsPlugin(args) {
|
|
|
30
30
|
prev.setAttribute('aria-label', options.texts.buttonPrevious);
|
|
31
31
|
prev.setAttribute('aria-controls', (_d = slider.container.getAttribute('id')) !== null && _d !== void 0 ? _d : '');
|
|
32
32
|
prev.setAttribute('data-type', 'prev');
|
|
33
|
-
prev.innerHTML = options.icons.prev;
|
|
34
|
-
prev.addEventListener('click', () =>
|
|
33
|
+
prev.innerHTML = slider.options.rtl ? options.icons.next : options.icons.prev;
|
|
34
|
+
prev.addEventListener('click', () => {
|
|
35
|
+
if (prev.getAttribute('data-has-content') === 'true') {
|
|
36
|
+
slider.moveToDirection('prev');
|
|
37
|
+
}
|
|
38
|
+
});
|
|
35
39
|
const next = document.createElement('button');
|
|
36
40
|
next.setAttribute('class', options.classNames.nextButton);
|
|
37
41
|
next.setAttribute('type', 'button');
|
|
38
42
|
next.setAttribute('aria-label', options.texts.buttonNext);
|
|
39
43
|
next.setAttribute('aria-controls', (_e = slider.container.getAttribute('id')) !== null && _e !== void 0 ? _e : '');
|
|
40
44
|
next.setAttribute('data-type', 'next');
|
|
41
|
-
next.innerHTML = options.icons.next;
|
|
42
|
-
next.addEventListener('click', () =>
|
|
45
|
+
next.innerHTML = slider.options.rtl ? options.icons.prev : options.icons.next;
|
|
46
|
+
next.addEventListener('click', () => {
|
|
47
|
+
if (next.getAttribute('data-has-content') === 'true') {
|
|
48
|
+
slider.moveToDirection('next');
|
|
49
|
+
}
|
|
50
|
+
});
|
|
43
51
|
// insert buttons to the nav
|
|
44
52
|
nav.appendChild(prev);
|
|
45
53
|
nav.appendChild(next);
|
|
46
54
|
const update = () => {
|
|
47
|
-
const scrollLeft = slider.
|
|
48
|
-
const scrollWidth = slider.
|
|
49
|
-
const clientWidth = slider.
|
|
55
|
+
const scrollLeft = slider.getScrollLeft();
|
|
56
|
+
const scrollWidth = slider.getInclusiveScrollWidth();
|
|
57
|
+
const clientWidth = slider.getInclusiveClientWidth();
|
|
50
58
|
const buffer = 1;
|
|
51
|
-
if (scrollLeft === 0) {
|
|
59
|
+
if (Math.floor(scrollLeft) === 0) {
|
|
52
60
|
prev.setAttribute('data-has-content', 'false');
|
|
53
61
|
}
|
|
54
62
|
else {
|
|
55
63
|
prev.setAttribute('data-has-content', 'true');
|
|
56
64
|
}
|
|
57
|
-
|
|
65
|
+
const maxWidthDifference = Math.abs(Math.floor(scrollLeft + clientWidth) - Math.floor(scrollWidth));
|
|
66
|
+
if (maxWidthDifference <= buffer) {
|
|
58
67
|
next.setAttribute('data-has-content', 'false');
|
|
59
68
|
}
|
|
60
69
|
else {
|
|
61
70
|
next.setAttribute('data-has-content', 'true');
|
|
62
71
|
}
|
|
72
|
+
console.log('next', scrollLeft + clientWidth, scrollWidth);
|
|
63
73
|
};
|
|
64
74
|
if (options.containerNext && options.containerPrev) {
|
|
65
75
|
options.containerPrev.appendChild(prev);
|
|
@@ -74,7 +84,7 @@ function ArrowsPlugin(args) {
|
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
86
|
update();
|
|
77
|
-
slider.on('
|
|
87
|
+
slider.on('scrollEnd', update);
|
|
78
88
|
slider.on('contentsChanged', update);
|
|
79
89
|
slider.on('containerSizeChanged', update);
|
|
80
90
|
};
|
|
@@ -1 +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
|
|
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};
|
|
@@ -76,10 +76,6 @@ function DotsPlugin(args) {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
const activateDot = (item) => {
|
|
79
|
-
// const scrollTargetPosition = slider.details.containerWidth * ( page - 1 );
|
|
80
|
-
// slider.container.style.scrollBehavior = slider.options.scrollBehavior;
|
|
81
|
-
// slider.container.scrollLeft = scrollTargetPosition;
|
|
82
|
-
// slider.container.style.scrollBehavior = '';
|
|
83
79
|
slider.moveToSlide(item - 1);
|
|
84
80
|
};
|
|
85
81
|
buildDots();
|
|
@@ -49,7 +49,7 @@ function DragScrollingPlugin(args) {
|
|
|
49
49
|
const walk = (x - startX);
|
|
50
50
|
const newScrollLeft = scrollLeft - walk;
|
|
51
51
|
mayNeedToSnap = true;
|
|
52
|
-
if (slider.container.scrollLeft !== newScrollLeft) {
|
|
52
|
+
if (Math.floor(slider.container.scrollLeft) !== Math.floor(newScrollLeft)) {
|
|
53
53
|
isMovingForward = slider.container.scrollLeft < newScrollLeft;
|
|
54
54
|
}
|
|
55
55
|
slider.container.scrollLeft = newScrollLeft;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){var t;const o=null!==(t=null==e?void 0:e.draggedDistanceThatPreventsClick)&&void 0!==t?t:20;return e=>{let t=!1,n=0,r=0,a=!1,
|
|
1
|
+
function e(e){var t;const o=null!==(t=null==e?void 0:e.draggedDistanceThatPreventsClick)&&void 0!==t?t:20;return e=>{let t=!1,n=0,r=0,a=!1,l=!1,s=!1;e.container.setAttribute("data-has-drag-scrolling","true");if(window.addEventListener("mousedown",(o=>{l=!1,e.details.hasOverflow&&e.container.contains(o.target)&&(t=!0,n=o.pageX-e.container.offsetLeft,r=e.container.scrollLeft,e.container.style.cursor="grabbing",e.container.style.scrollBehavior="auto",o.preventDefault(),o.stopPropagation())})),window.addEventListener("mousemove",(i=>{if(!e.details.hasOverflow)return void(l=!1);if(!t)return void(l=!1);i.preventDefault(),l||(l=!0,e.emit("programmaticScrollStart"));const c=i.pageX-e.container.offsetLeft-n,d=r-c;s=!0,Math.floor(e.container.scrollLeft)!==Math.floor(d)&&(a=e.container.scrollLeft<d),e.container.scrollLeft=d;const f=Math.abs(c),u=e.container.querySelectorAll(e.options.slidesSelector),v=f>o?"none":"";u.forEach((e=>{e.style.pointerEvents=v}))})),window.addEventListener("mouseup",(()=>{e.details.hasOverflow?(t=!1,e.container.style.cursor="",setTimeout((()=>{l=!1,e.container.style.scrollBehavior="";e.container.querySelectorAll(e.options.slidesSelector).forEach((e=>{e.style.pointerEvents=""}))}),50)):l=!1})),e.options.emulateScrollSnap){const o=()=>{s&&!t&&(s=!1,e.snapToClosestSlide(a?"next":"prev"))};e.on("programmaticScrollEnd",o),window.addEventListener("mouseup",o)}}}export{e as default};
|
|
@@ -32,23 +32,23 @@ function FadePlugin(args) {
|
|
|
32
32
|
options.container.appendChild(fadeItemEnd);
|
|
33
33
|
}
|
|
34
34
|
const hasFadeAtStart = () => {
|
|
35
|
-
return slider.
|
|
35
|
+
return slider.getScrollLeft() > fadeItemStart.offsetWidth;
|
|
36
36
|
};
|
|
37
37
|
const fadeAtStartOpacity = () => {
|
|
38
|
-
const position = slider.
|
|
39
|
-
if (position <= fadeItemStart.offsetWidth) {
|
|
38
|
+
const position = slider.getScrollLeft();
|
|
39
|
+
if (Math.floor(position) <= Math.floor(fadeItemStart.offsetWidth)) {
|
|
40
40
|
return position / Math.max(fadeItemStart.offsetWidth, 1);
|
|
41
41
|
}
|
|
42
42
|
return 1;
|
|
43
43
|
};
|
|
44
44
|
const hasFadeAtEnd = () => {
|
|
45
|
-
return slider.
|
|
45
|
+
return Math.floor(slider.getScrollLeft()) < Math.floor(slider.getInclusiveScrollWidth() - slider.getInclusiveClientWidth() - fadeItemEnd.offsetWidth);
|
|
46
46
|
};
|
|
47
47
|
const fadeAtEndOpacity = () => {
|
|
48
|
-
const position = slider.
|
|
49
|
-
const maxPosition = slider.
|
|
48
|
+
const position = slider.getScrollLeft();
|
|
49
|
+
const maxPosition = slider.getInclusiveScrollWidth() - slider.getInclusiveClientWidth();
|
|
50
50
|
const maxFadePosition = maxPosition - fadeItemEnd.offsetWidth;
|
|
51
|
-
if (position >= maxFadePosition) {
|
|
51
|
+
if (Math.floor(position) >= Math.floor(maxFadePosition)) {
|
|
52
52
|
return ((maxFadePosition - position) / Math.max(fadeItemEnd.offsetWidth, 1)) + 1;
|
|
53
53
|
}
|
|
54
54
|
return 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){return e=>{var n,a,
|
|
1
|
+
function t(t){return e=>{var n,a,o;const i={classNames:{fadeItem:"overflow-slider-fade",fadeItemStart:"overflow-slider-fade--start",fadeItemEnd:"overflow-slider-fade--end"},container:null!==(n=null==t?void 0:t.container)&&void 0!==n?n:null,containerStart:null!==(a=null==t?void 0:t.containerStart)&&void 0!==a?a:null,containerEnd:null!==(o=null==t?void 0:t.containerEnd)&&void 0!==o?o:null},l=document.createElement("div");l.classList.add(i.classNames.fadeItem,i.classNames.fadeItemStart),l.setAttribute("aria-hidden","true"),l.setAttribute("tabindex","-1");const r=document.createElement("div");r.classList.add(i.classNames.fadeItem,i.classNames.fadeItemEnd),r.setAttribute("aria-hidden","true"),r.setAttribute("tabindex","-1"),i.containerStart?i.containerStart.appendChild(l):i.container&&i.container.appendChild(l),i.containerEnd?i.containerEnd.appendChild(r):i.container&&i.container.appendChild(r);const d=()=>{l.setAttribute("data-has-fade",(e.getScrollLeft()>l.offsetWidth).toString()),l.style.opacity=(()=>{const t=e.getScrollLeft();return Math.floor(t)<=Math.floor(l.offsetWidth)?t/Math.max(l.offsetWidth,1):1})().toString(),r.setAttribute("data-has-fade",(Math.floor(e.getScrollLeft())<Math.floor(e.getInclusiveScrollWidth()-e.getInclusiveClientWidth()-r.offsetWidth)).toString()),r.style.opacity=(()=>{const t=e.getScrollLeft(),n=e.getInclusiveScrollWidth()-e.getInclusiveClientWidth()-r.offsetWidth;return Math.floor(t)>=Math.floor(n)?(n-t)/Math.max(r.offsetWidth,1)+1:1})().toString()};d(),e.on("created",d),e.on("contentsChanged",d),e.on("containerSizeChanged",d),e.on("scrollEnd",d),e.on("scrollStart",d);let s=0;e.on("scroll",(()=>{s&&window.cancelAnimationFrame(s),s=window.requestAnimationFrame((()=>{d()}))}))}}export{t as default};
|
|
@@ -16,16 +16,21 @@ function FullWidthPlugin(args) {
|
|
|
16
16
|
const lastSlide = slides[slides.length - 1];
|
|
17
17
|
const marginAmount = Math.floor((window.innerWidth - options.targetWidth(slider)) / 2);
|
|
18
18
|
if (options.addMarginBefore) {
|
|
19
|
-
firstSlide.style.
|
|
19
|
+
firstSlide.style.marginInlineStart = `${marginAmount}px`;
|
|
20
20
|
}
|
|
21
21
|
if (options.addMarginAfter) {
|
|
22
|
-
lastSlide.style.
|
|
22
|
+
lastSlide.style.marginInlineEnd = `${marginAmount}px`;
|
|
23
23
|
}
|
|
24
24
|
slider.container.setAttribute('data-full-width-offset', marginAmount.toString());
|
|
25
|
+
setCSS();
|
|
26
|
+
};
|
|
27
|
+
const setCSS = () => {
|
|
28
|
+
slider.container.style.setProperty('--slider-container-target-width', `${options.targetWidth(slider)}px`);
|
|
25
29
|
};
|
|
26
30
|
update();
|
|
27
31
|
slider.on('contentsChanged', update);
|
|
28
32
|
slider.on('containerSizeChanged', update);
|
|
33
|
+
window.addEventListener('resize', setCSS);
|
|
29
34
|
};
|
|
30
35
|
}
|
|
31
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>{var n,e;return null!==(e=null===(n=t.container.parentElement)||void 0===n?void 0:n.offsetWidth)&&void 0!==e?e:window.innerWidth};function n(n){return e=>{var i,r,
|
|
1
|
+
const t=t=>{var n,e;return null!==(e=null===(n=t.container.parentElement)||void 0===n?void 0:n.offsetWidth)&&void 0!==e?e:window.innerWidth};function n(n){return e=>{var i,r,d;const o={targetWidth:null!==(i=null==n?void 0:n.targetWidth)&&void 0!==i?i:t,addMarginBefore:null===(r=null==n?void 0:n.addMarginBefore)||void 0===r||r,addMarginAfter:null===(d=null==n?void 0:n.addMarginAfter)||void 0===d||d},a=()=>{const t=e.container.querySelectorAll(e.options.slidesSelector);if(!t.length)return;const n=t[0],i=t[t.length-1],r=Math.floor((window.innerWidth-o.targetWidth(e))/2);o.addMarginBefore&&(n.style.marginInlineStart=`${r}px`),o.addMarginAfter&&(i.style.marginInlineEnd=`${r}px`),e.container.setAttribute("data-full-width-offset",r.toString()),l()},l=()=>{e.container.style.setProperty("--slider-container-target-width",`${o.targetWidth(e)}px`)};a(),e.on("contentsChanged",a),e.on("containerSizeChanged",a),window.addEventListener("resize",l)}}export{n as default};
|
|
@@ -32,41 +32,40 @@ function ScrollIndicatorPlugin(args) {
|
|
|
32
32
|
setDataAttributes();
|
|
33
33
|
const getScrollbarButtonLeftOffset = () => {
|
|
34
34
|
const contentRatio = scrollbarButton.offsetWidth / slider.details.containerWidth;
|
|
35
|
-
|
|
35
|
+
const scrollAmount = slider.getScrollLeft() * contentRatio;
|
|
36
|
+
if (slider.options.rtl) {
|
|
37
|
+
return scrollbar.offsetWidth - scrollbarButton.offsetWidth - scrollAmount;
|
|
38
|
+
}
|
|
39
|
+
return scrollAmount;
|
|
36
40
|
};
|
|
37
|
-
// scrollbarbutton width and position is calculated based on the scroll position and available width
|
|
38
41
|
let requestId = 0;
|
|
39
42
|
const update = () => {
|
|
40
43
|
if (requestId) {
|
|
41
44
|
window.cancelAnimationFrame(requestId);
|
|
42
45
|
}
|
|
43
46
|
requestId = window.requestAnimationFrame(() => {
|
|
44
|
-
const scrollbarButtonWidth = (slider.details.containerWidth / slider.
|
|
47
|
+
const scrollbarButtonWidth = (slider.details.containerWidth / slider.container.scrollWidth) * 100;
|
|
45
48
|
const scrollLeftInPortion = getScrollbarButtonLeftOffset();
|
|
46
49
|
scrollbarButton.style.width = `${scrollbarButtonWidth}%`;
|
|
47
50
|
scrollbarButton.style.transform = `translateX(${scrollLeftInPortion}px)`;
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const scrollWidth = slider.container.scrollWidth;
|
|
51
|
+
const scrollLeft = slider.getScrollLeft();
|
|
52
|
+
const scrollWidth = slider.getInclusiveScrollWidth();
|
|
51
53
|
const containerWidth = slider.container.offsetWidth;
|
|
52
54
|
const scrollPercentage = (scrollLeft / (scrollWidth - containerWidth)) * 100;
|
|
53
55
|
scrollbarContainer.setAttribute('aria-valuenow', Math.round(Number.isNaN(scrollPercentage) ? 0 : scrollPercentage).toString());
|
|
54
56
|
});
|
|
55
57
|
};
|
|
56
|
-
// insert to DOM
|
|
57
58
|
if (options.container) {
|
|
58
59
|
options.container.appendChild(scrollbarContainer);
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
62
|
(_c = slider.container.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(scrollbarContainer, slider.container.nextSibling);
|
|
62
63
|
}
|
|
63
|
-
// update the scrollbar when the slider is scrolled
|
|
64
64
|
update();
|
|
65
65
|
slider.on('scroll', update);
|
|
66
66
|
slider.on('contentsChanged', update);
|
|
67
67
|
slider.on('containerSizeChanged', update);
|
|
68
68
|
slider.on('detailsChanged', setDataAttributes);
|
|
69
|
-
// handle arrow keys while focused
|
|
70
69
|
scrollbarContainer.addEventListener('keydown', (e) => {
|
|
71
70
|
if (e.key === 'ArrowLeft') {
|
|
72
71
|
slider.moveToDirection('prev');
|
|
@@ -75,29 +74,29 @@ function ScrollIndicatorPlugin(args) {
|
|
|
75
74
|
slider.moveToDirection('next');
|
|
76
75
|
}
|
|
77
76
|
});
|
|
78
|
-
|
|
77
|
+
let isInteractionDown = false;
|
|
78
|
+
let startX = 0;
|
|
79
|
+
let scrollLeft = slider.getScrollLeft();
|
|
79
80
|
scrollbarContainer.addEventListener('click', (e) => {
|
|
81
|
+
if (e.target == scrollbarButton) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
80
84
|
const scrollbarButtonWidth = scrollbarButton.offsetWidth;
|
|
81
85
|
const scrollbarButtonLeft = getScrollbarButtonLeftOffset();
|
|
82
86
|
const scrollbarButtonRight = scrollbarButtonLeft + scrollbarButtonWidth;
|
|
83
|
-
const clickX = e.pageX - scrollbarContainer.offsetLeft;
|
|
84
|
-
if (clickX < scrollbarButtonLeft) {
|
|
85
|
-
slider.moveToDirection('prev');
|
|
87
|
+
const clickX = e.pageX - Math.abs(scrollbarContainer.offsetLeft);
|
|
88
|
+
if (Math.floor(clickX) < Math.floor(scrollbarButtonLeft)) {
|
|
89
|
+
slider.moveToDirection(slider.options.rtl ? 'next' : 'prev');
|
|
86
90
|
}
|
|
87
|
-
else if (clickX > scrollbarButtonRight) {
|
|
88
|
-
slider.moveToDirection('next');
|
|
91
|
+
else if (Math.floor(clickX) > Math.floor(scrollbarButtonRight)) {
|
|
92
|
+
slider.moveToDirection(slider.options.rtl ? 'prev' : 'next');
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
|
-
// make scrollbar button draggable via mouse/touch and update the scroll position
|
|
92
|
-
let isInteractionDown = false;
|
|
93
|
-
let startX = 0;
|
|
94
|
-
let scrollLeft = 0;
|
|
95
95
|
const onInteractionDown = (e) => {
|
|
96
96
|
isInteractionDown = true;
|
|
97
97
|
const pageX = e.pageX || e.touches[0].pageX;
|
|
98
98
|
startX = pageX - scrollbarContainer.offsetLeft;
|
|
99
|
-
scrollLeft = slider.
|
|
100
|
-
// change cursor to grabbing
|
|
99
|
+
scrollLeft = slider.getScrollLeft();
|
|
101
100
|
scrollbarButton.style.cursor = 'grabbing';
|
|
102
101
|
scrollbarButton.setAttribute('data-is-grabbed', 'true');
|
|
103
102
|
e.preventDefault();
|
|
@@ -112,7 +111,8 @@ function ScrollIndicatorPlugin(args) {
|
|
|
112
111
|
const x = pageX - scrollbarContainer.offsetLeft;
|
|
113
112
|
const scrollingFactor = slider.details.scrollableAreaWidth / scrollbarContainer.offsetWidth;
|
|
114
113
|
const walk = (x - startX) * scrollingFactor;
|
|
115
|
-
slider.
|
|
114
|
+
const distance = slider.options.rtl ? scrollLeft - walk : scrollLeft + walk;
|
|
115
|
+
slider.setScrollLeft(distance);
|
|
116
116
|
};
|
|
117
117
|
const onInteractionUp = () => {
|
|
118
118
|
isInteractionDown = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={scrollIndicator:"overflow-slider__scroll-indicator",scrollIndicatorBar:"overflow-slider__scroll-indicator-bar",scrollIndicatorButton:"overflow-slider__scroll-indicator-button"};function e(e){return
|
|
1
|
+
const t={scrollIndicator:"overflow-slider__scroll-indicator",scrollIndicatorBar:"overflow-slider__scroll-indicator-bar",scrollIndicatorButton:"overflow-slider__scroll-indicator-button"};function e(e){return o=>{var r,n,i;const a={classNames:Object.assign(Object.assign({},t),(null==e?void 0:e.classNames)||[]),container:null!==(r=null==e?void 0:e.container)&&void 0!==r?r:null},s=document.createElement("div");s.setAttribute("class",a.classNames.scrollIndicator),s.setAttribute("tabindex","0"),s.setAttribute("role","scrollbar"),s.setAttribute("aria-controls",null!==(n=o.container.getAttribute("id"))&&void 0!==n?n:""),s.setAttribute("aria-orientation","horizontal"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuenow","0");const l=document.createElement("div");l.setAttribute("class",a.classNames.scrollIndicatorBar);const c=document.createElement("div");c.setAttribute("class",a.classNames.scrollIndicatorButton),c.setAttribute("data-is-grabbed","false"),l.appendChild(c),s.appendChild(l);const d=()=>{s.setAttribute("data-has-overflow",o.details.hasOverflow.toString())};d();const u=()=>{const t=c.offsetWidth/o.details.containerWidth,e=o.getScrollLeft()*t;return o.options.rtl?l.offsetWidth-c.offsetWidth-e:e};let f=0;const v=()=>{f&&window.cancelAnimationFrame(f),f=window.requestAnimationFrame((()=>{const t=o.details.containerWidth/o.container.scrollWidth*100,e=u();c.style.width=`${t}%`,c.style.transform=`translateX(${e}px)`;const r=o.getScrollLeft()/(o.getInclusiveScrollWidth()-o.container.offsetWidth)*100;s.setAttribute("aria-valuenow",Math.round(Number.isNaN(r)?0:r).toString())}))};a.container?a.container.appendChild(s):null===(i=o.container.parentNode)||void 0===i||i.insertBefore(s,o.container.nextSibling),v(),o.on("scroll",v),o.on("contentsChanged",v),o.on("containerSizeChanged",v),o.on("detailsChanged",d),s.addEventListener("keydown",(t=>{"ArrowLeft"===t.key?o.moveToDirection("prev"):"ArrowRight"===t.key&&o.moveToDirection("next")}));let b=!1,h=0,m=o.getScrollLeft();s.addEventListener("click",(t=>{if(t.target==c)return;const e=c.offsetWidth,r=u(),n=r+e,i=t.pageX-Math.abs(s.offsetLeft);Math.floor(i)<Math.floor(r)?o.moveToDirection(o.options.rtl?"next":"prev"):Math.floor(i)>Math.floor(n)&&o.moveToDirection(o.options.rtl?"prev":"next")}));const g=t=>{b=!0;const e=t.pageX||t.touches[0].pageX;h=e-s.offsetLeft,m=o.getScrollLeft(),c.style.cursor="grabbing",c.setAttribute("data-is-grabbed","true"),t.preventDefault(),t.stopPropagation()},p=t=>{if(!b)return;t.preventDefault();const e=(t.pageX||t.touches[0].pageX)-s.offsetLeft,r=o.details.scrollableAreaWidth/s.offsetWidth,n=(e-h)*r,i=o.options.rtl?m-n:m+n;o.setScrollLeft(i)},w=()=>{b=!1,c.style.cursor="",c.setAttribute("data-is-grabbed","false")};c.addEventListener("mousedown",g),c.addEventListener("touchstart",g),window.addEventListener("mousemove",p),window.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("mouseup",w),window.addEventListener("touchend",w)}}export{e as default};
|
|
@@ -27,13 +27,16 @@ function FullWidthPlugin(args) {
|
|
|
27
27
|
};
|
|
28
28
|
setActiveThumbnail();
|
|
29
29
|
addClickListeners();
|
|
30
|
-
// @todo debounce on scroll
|
|
31
30
|
mainSlider.on('scrollEnd', () => {
|
|
32
31
|
setTimeout(() => {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
32
|
+
const mainActiveSlideIdx = mainSlider.activeSlideIdx;
|
|
33
|
+
const thumbActiveSlideIdx = slider.activeSlideIdx;
|
|
34
|
+
if (thumbActiveSlideIdx === mainActiveSlideIdx) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const activeThumbnail = slider.slides[mainActiveSlideIdx];
|
|
35
38
|
setActiveThumbnail(activeThumbnail);
|
|
36
|
-
slider.moveToSlide(
|
|
39
|
+
slider.moveToSlide(mainActiveSlideIdx);
|
|
37
40
|
}, 50);
|
|
38
41
|
});
|
|
39
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return i=>{const
|
|
1
|
+
function e(e){return i=>{const t={mainSlider:e.mainSlider}.mainSlider,l=(e=null)=>{null===e&&i.slides.length>0&&(e=i.slides[0]),null!==e&&(i.slides.forEach((e=>{e.setAttribute("aria-current","false")})),e.setAttribute("aria-current","true"))};l(),i.slides.forEach(((e,i)=>{e.addEventListener("click",(()=>{t.moveToSlide(i),l(e)}))})),t.on("scrollEnd",(()=>{setTimeout((()=>{const e=t.activeSlideIdx;if(i.activeSlideIdx===e)return;const r=i.slides[e];l(r),i.moveToSlide(e)}),50)}))}}export{e as default};
|
package/docs/assets/demo.css
CHANGED
|
@@ -579,10 +579,20 @@ h3:before {
|
|
|
579
579
|
left: 0;
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
+
[dir="rtl"] .example-4-filters-previous {
|
|
583
|
+
right: 0;
|
|
584
|
+
left: auto;
|
|
585
|
+
}
|
|
586
|
+
|
|
582
587
|
.example-4-filters-next {
|
|
583
588
|
right: 0;
|
|
584
589
|
}
|
|
585
590
|
|
|
591
|
+
[dir="rtl"] .example-4-filters-next {
|
|
592
|
+
left: 0;
|
|
593
|
+
right: auto;
|
|
594
|
+
}
|
|
595
|
+
|
|
586
596
|
.example-4-filters-previous:has([data-has-content="false"]),
|
|
587
597
|
.example-4-filters-next:has([data-has-content="false"]) {
|
|
588
598
|
opacity: 0;
|
|
@@ -630,7 +640,7 @@ h3:before {
|
|
|
630
640
|
|
|
631
641
|
.example-container-4-full-width {
|
|
632
642
|
width: 100vw;
|
|
633
|
-
margin-
|
|
643
|
+
margin-inline-start: calc(-50vw + 50%);
|
|
634
644
|
}
|
|
635
645
|
|
|
636
646
|
/* ===========================================================================
|
package/docs/assets/demo.js
CHANGED
|
@@ -30,7 +30,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
30
30
|
|
|
31
31
|
const example1DragScrolling = new OverflowSlider(
|
|
32
32
|
document.querySelector( '.example-container-1-drag-scrolling-clickable' ),
|
|
33
|
-
{
|
|
33
|
+
{
|
|
34
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
35
|
+
},
|
|
34
36
|
[
|
|
35
37
|
DragScrollingPlugin(),
|
|
36
38
|
SkipLinksPlugin(),
|
|
@@ -40,7 +42,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
40
42
|
|
|
41
43
|
const example1DragScrollingNotClickable = new OverflowSlider(
|
|
42
44
|
document.querySelector( '.example-container-1-drag-scrolling-not-clickable' ),
|
|
43
|
-
{
|
|
45
|
+
{
|
|
46
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
47
|
+
},
|
|
44
48
|
[
|
|
45
49
|
DragScrollingPlugin(),
|
|
46
50
|
SkipLinksPlugin(),
|
|
@@ -51,6 +55,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
51
55
|
document.querySelector( '.example-container-1-drag-scrolling-scroll-snap' ),
|
|
52
56
|
{
|
|
53
57
|
emulateScrollSnap: true,
|
|
58
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
54
59
|
},
|
|
55
60
|
[
|
|
56
61
|
DragScrollingPlugin(),
|
|
@@ -60,7 +65,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
60
65
|
|
|
61
66
|
const example1Arrows = new OverflowSlider(
|
|
62
67
|
document.querySelector( '.example-container-1-arrows' ),
|
|
63
|
-
{
|
|
68
|
+
{
|
|
69
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
70
|
+
},
|
|
64
71
|
[
|
|
65
72
|
DragScrollingPlugin(),
|
|
66
73
|
SkipLinksPlugin(),
|
|
@@ -71,7 +78,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
71
78
|
|
|
72
79
|
const example1ScrollIndicator = new OverflowSlider(
|
|
73
80
|
document.querySelector( '.example-container-1-scroll-indicator' ),
|
|
74
|
-
{
|
|
81
|
+
{
|
|
82
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
83
|
+
},
|
|
75
84
|
[
|
|
76
85
|
DragScrollingPlugin(),
|
|
77
86
|
SkipLinksPlugin(),
|
|
@@ -84,6 +93,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
84
93
|
document.querySelector( '.example-container-1-dots' ),
|
|
85
94
|
{
|
|
86
95
|
emulateScrollSnap: true,
|
|
96
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
87
97
|
},
|
|
88
98
|
[
|
|
89
99
|
DragScrollingPlugin(),
|
|
@@ -97,6 +107,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
97
107
|
document.querySelector( '.example-container-1-fade' ),
|
|
98
108
|
{
|
|
99
109
|
emulateScrollSnap: true,
|
|
110
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
100
111
|
},
|
|
101
112
|
[
|
|
102
113
|
DragScrollingPlugin(),
|
|
@@ -109,7 +120,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
109
120
|
|
|
110
121
|
const example2PerfectFit = new OverflowSlider(
|
|
111
122
|
document.querySelector( '.example-container-2-perfect-fit' ),
|
|
112
|
-
{
|
|
123
|
+
{
|
|
124
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
125
|
+
},
|
|
113
126
|
[
|
|
114
127
|
DragScrollingPlugin(),
|
|
115
128
|
ScrollIndicatorPlugin(),
|
|
@@ -119,7 +132,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
119
132
|
|
|
120
133
|
const example2VaryingWidths = new OverflowSlider(
|
|
121
134
|
document.querySelector( '.example-container-2-varying-widths' ),
|
|
122
|
-
{
|
|
135
|
+
{
|
|
136
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
137
|
+
},
|
|
123
138
|
[
|
|
124
139
|
DragScrollingPlugin(),
|
|
125
140
|
ScrollIndicatorPlugin(),
|
|
@@ -129,7 +144,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
129
144
|
|
|
130
145
|
const example2OnlyFewSlides = new OverflowSlider(
|
|
131
146
|
document.querySelector( '.example-container-2-only-few-slides' ),
|
|
132
|
-
{
|
|
147
|
+
{
|
|
148
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
149
|
+
},
|
|
133
150
|
[
|
|
134
151
|
DragScrollingPlugin(),
|
|
135
152
|
ScrollIndicatorPlugin(),
|
|
@@ -141,6 +158,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
141
158
|
document.querySelector( '.example-container-3-scroll-snapping-mandatory' ),
|
|
142
159
|
{
|
|
143
160
|
emulateScrollSnap: true,
|
|
161
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
144
162
|
},
|
|
145
163
|
[
|
|
146
164
|
DragScrollingPlugin(),
|
|
@@ -153,6 +171,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
153
171
|
document.querySelector( '.example-container-3-scroll-snapping-proximity' ),
|
|
154
172
|
{
|
|
155
173
|
emulateScrollSnap: true,
|
|
174
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
156
175
|
},
|
|
157
176
|
[
|
|
158
177
|
DragScrollingPlugin(),
|
|
@@ -163,7 +182,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
163
182
|
|
|
164
183
|
const example3EntranceAnimation = new OverflowSlider(
|
|
165
184
|
document.querySelector( '.example-container-3-entrance-animation' ),
|
|
166
|
-
{
|
|
185
|
+
{
|
|
186
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
187
|
+
},
|
|
167
188
|
[
|
|
168
189
|
DragScrollingPlugin(),
|
|
169
190
|
ScrollIndicatorPlugin(),
|
|
@@ -173,7 +194,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
173
194
|
|
|
174
195
|
const example4Filters = new OverflowSlider(
|
|
175
196
|
document.querySelector( '.example-container-4-filters' ),
|
|
176
|
-
{
|
|
197
|
+
{
|
|
198
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
199
|
+
},
|
|
177
200
|
[
|
|
178
201
|
DragScrollingPlugin(),
|
|
179
202
|
ArrowsPlugin({
|
|
@@ -188,6 +211,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
188
211
|
document.querySelector( '.example-container-4-grid-or-slider' ),
|
|
189
212
|
{
|
|
190
213
|
emulateScrollSnap: true,
|
|
214
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
191
215
|
},
|
|
192
216
|
[
|
|
193
217
|
DragScrollingPlugin(),
|
|
@@ -198,7 +222,9 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
198
222
|
|
|
199
223
|
const example4FullWidth = new OverflowSlider(
|
|
200
224
|
document.querySelector( '.example-container-4-full-width' ),
|
|
201
|
-
{
|
|
225
|
+
{
|
|
226
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
227
|
+
},
|
|
202
228
|
[
|
|
203
229
|
DragScrollingPlugin(),
|
|
204
230
|
FullWidthPlugin(
|
|
@@ -218,6 +244,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
218
244
|
document.querySelector( '.example-container-4-synced-main' ),
|
|
219
245
|
{
|
|
220
246
|
emulateScrollSnap: true,
|
|
247
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
221
248
|
},
|
|
222
249
|
[
|
|
223
250
|
DragScrollingPlugin(),
|
|
@@ -229,6 +256,7 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
229
256
|
document.querySelector( '.example-container-4-synced-thumbnails' ),
|
|
230
257
|
{
|
|
231
258
|
emulateScrollSnap: true,
|
|
259
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
232
260
|
},
|
|
233
261
|
[
|
|
234
262
|
DragScrollingPlugin(),
|
|
@@ -239,8 +267,6 @@ import FadePlugin from '../dist/plugins/fade/fade/index.esm.js';
|
|
|
239
267
|
);
|
|
240
268
|
console.log( '4-synced-thumbnails', example4SyncedThumbnails );
|
|
241
269
|
|
|
242
|
-
|
|
243
|
-
|
|
244
270
|
};
|
|
245
271
|
|
|
246
272
|
init();
|
|
@@ -7,17 +7,17 @@ function details(slider) {
|
|
|
7
7
|
let scrollableAreaWidth = 0;
|
|
8
8
|
let amountOfPages = 0;
|
|
9
9
|
let currentPage = 1;
|
|
10
|
-
if (slider.
|
|
10
|
+
if (Math.floor(slider.getInclusiveScrollWidth()) > Math.floor(slider.getInclusiveClientWidth())) {
|
|
11
11
|
hasOverflow = true;
|
|
12
12
|
}
|
|
13
13
|
slideCount = (_a = slider.slides.length) !== null && _a !== void 0 ? _a : 0;
|
|
14
14
|
containerWidth = slider.container.offsetWidth;
|
|
15
|
-
scrollableAreaWidth = slider.
|
|
15
|
+
scrollableAreaWidth = slider.getInclusiveScrollWidth();
|
|
16
16
|
amountOfPages = Math.ceil(scrollableAreaWidth / containerWidth);
|
|
17
|
-
if (slider.
|
|
18
|
-
currentPage = Math.floor(slider.
|
|
17
|
+
if (Math.floor(slider.getScrollLeft()) >= 0) {
|
|
18
|
+
currentPage = Math.floor(slider.getScrollLeft() / containerWidth);
|
|
19
19
|
// consider as last page if the scrollLeft + containerWidth is equal to scrollWidth
|
|
20
|
-
if (slider.
|
|
20
|
+
if (Math.floor(slider.getScrollLeft() + containerWidth) === Math.floor(scrollableAreaWidth)) {
|
|
21
21
|
currentPage = amountOfPages - 1;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){var
|
|
1
|
+
function t(t){var l;let e,o=!1,r=0,a=0,i=0,n=0,f=1;return Math.floor(t.getInclusiveScrollWidth())>Math.floor(t.getInclusiveClientWidth())&&(o=!0),r=null!==(l=t.slides.length)&&void 0!==l?l:0,a=t.container.offsetWidth,i=t.getInclusiveScrollWidth(),n=Math.ceil(i/a),Math.floor(t.getScrollLeft())>=0&&(f=Math.floor(t.getScrollLeft()/a),Math.floor(t.getScrollLeft()+a)===Math.floor(i)&&(f=n-1)),e={hasOverflow:o,slideCount:r,containerWidth:a,scrollableAreaWidth:i,amountOfPages:n,currentPage:f},e}export{t as default};
|
|
@@ -12,6 +12,7 @@ function OverflowSlider(container, options, plugins) {
|
|
|
12
12
|
slidesSelector: ":scope > *",
|
|
13
13
|
emulateScrollSnap: false,
|
|
14
14
|
emulateScrollSnapMaxThreshold: 64,
|
|
15
|
+
rtl: false,
|
|
15
16
|
};
|
|
16
17
|
const sliderOptions = Object.assign(Object.assign({}, defaults), options);
|
|
17
18
|
// disable smooth scrolling if user prefers reduced motion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./slider.min.js";function o(o,r,t){try{if(!(o instanceof Element))throw new Error("Container must be HTML element, found "+typeof o);const l={scrollBehavior:"smooth",scrollStrategy:"fullSlide",slidesSelector:":scope > *",emulateScrollSnap:!1,emulateScrollSnapMaxThreshold:64},s=Object.assign(Object.assign({},l),r);return window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(s.scrollBehavior="auto"),e(o,s,t)}catch(e){console.error(e)}}export{o as default};
|
|
1
|
+
import e from"./slider.min.js";function o(o,r,t){try{if(!(o instanceof Element))throw new Error("Container must be HTML element, found "+typeof o);const l={scrollBehavior:"smooth",scrollStrategy:"fullSlide",slidesSelector:":scope > *",emulateScrollSnap:!1,emulateScrollSnapMaxThreshold:64,rtl:!1},s=Object.assign(Object.assign({},l),r);return window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(s.scrollBehavior="auto"),e(o,s,t)}catch(e){console.error(e)}}export{o as default};
|