@evermade/overflow-slider 3.3.1 → 4.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/.nvmrc +1 -1
- package/README.md +115 -29
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +609 -1
- package/dist/index.esm.js.map +1 -0
- package/dist/index.min.js +2 -1
- package/dist/index.min.js.map +1 -0
- package/dist/mixins.scss +14 -0
- package/dist/overflow-slider.css +1 -1
- package/dist/plugins/arrows/index.d.ts +26 -0
- package/dist/plugins/arrows/index.min.js +1 -1
- package/dist/plugins/autoplay/index.d.ts +41 -0
- package/dist/plugins/autoplay/index.esm.js +233 -0
- package/dist/plugins/autoplay/index.min.js +1 -0
- package/dist/plugins/core/index.d.ts +75 -0
- package/dist/plugins/core/index.d2.ts +23 -0
- package/dist/plugins/dots/index.d.ts +16 -0
- package/dist/plugins/dots/index.min.js +1 -1
- package/dist/plugins/drag-scrolling/index.d.ts +9 -0
- package/dist/plugins/drag-scrolling/index.esm.js +2 -2
- package/dist/plugins/drag-scrolling/index.min.js +1 -1
- package/dist/plugins/fade/index.d.ts +16 -0
- package/dist/plugins/fade/index.min.js +1 -1
- package/dist/plugins/full-width/index.d.ts +11 -0
- package/dist/plugins/full-width/index.esm.js +14 -3
- package/dist/plugins/full-width/index.min.js +1 -1
- package/dist/plugins/infinite-scroll/index.d.ts +25 -0
- package/dist/plugins/infinite-scroll/index.esm.js +75 -0
- package/dist/plugins/infinite-scroll/index.min.js +1 -0
- package/dist/plugins/scroll-indicator/index.d.ts +14 -0
- package/dist/plugins/scroll-indicator/index.esm.js +3 -1
- package/dist/plugins/scroll-indicator/index.min.js +1 -1
- package/dist/plugins/skip-links/index.d.ts +17 -0
- package/dist/plugins/skip-links/index.esm.js +7 -1
- package/dist/plugins/skip-links/index.min.js +1 -1
- package/dist/plugins/thumbnails/index.d.ts +9 -0
- package/dist/plugins/thumbnails/index.min.js +1 -1
- package/dist/{core/utils.min.js → utils-Sxwcz8zp.js} +1 -1
- package/dist/{core/utils.esm.js → utils-ayDxlweP.js} +1 -1
- package/docs/assets/demo.css +115 -0
- package/docs/assets/demo.js +68 -0
- package/docs/dist/index.d.ts +1 -0
- package/docs/dist/index.esm.js +609 -1
- package/docs/dist/index.esm.js.map +1 -0
- package/docs/dist/index.min.js +2 -1
- package/docs/dist/index.min.js.map +1 -0
- package/docs/dist/mixins.scss +14 -0
- package/docs/dist/overflow-slider.css +1 -1
- package/docs/dist/plugins/arrows/index.d.ts +26 -0
- package/docs/dist/plugins/arrows/index.min.js +1 -1
- package/docs/dist/plugins/autoplay/index.d.ts +41 -0
- package/docs/dist/plugins/autoplay/index.esm.js +233 -0
- package/docs/dist/plugins/autoplay/index.min.js +1 -0
- package/docs/dist/plugins/core/index.d.ts +23 -0
- package/docs/dist/plugins/core/index.d2.ts +75 -0
- package/docs/dist/plugins/dots/index.d.ts +16 -0
- package/docs/dist/plugins/dots/index.min.js +1 -1
- package/docs/dist/plugins/drag-scrolling/index.d.ts +9 -0
- package/docs/dist/plugins/drag-scrolling/index.esm.js +2 -2
- package/docs/dist/plugins/drag-scrolling/index.min.js +1 -1
- package/docs/dist/plugins/fade/index.d.ts +16 -0
- package/docs/dist/plugins/fade/index.min.js +1 -1
- package/docs/dist/plugins/full-width/index.d.ts +11 -0
- package/docs/dist/plugins/full-width/index.esm.js +14 -3
- package/docs/dist/plugins/full-width/index.min.js +1 -1
- package/docs/dist/plugins/infinite-scroll/index.d.ts +25 -0
- package/docs/dist/plugins/infinite-scroll/index.esm.js +75 -0
- package/docs/dist/plugins/infinite-scroll/index.min.js +1 -0
- package/docs/dist/plugins/scroll-indicator/index.d.ts +14 -0
- package/docs/dist/plugins/scroll-indicator/index.esm.js +3 -1
- package/docs/dist/plugins/scroll-indicator/index.min.js +1 -1
- package/docs/dist/plugins/skip-links/index.d.ts +17 -0
- package/docs/dist/plugins/skip-links/index.esm.js +7 -1
- package/docs/dist/plugins/skip-links/index.min.js +1 -1
- package/docs/dist/plugins/thumbnails/index.d.ts +9 -0
- package/docs/dist/plugins/thumbnails/index.min.js +1 -1
- package/docs/dist/{core/utils.min.js → utils-Sxwcz8zp.js} +1 -1
- package/docs/dist/{core/utils.esm.js → utils-ayDxlweP.js} +1 -1
- package/docs/index-rtl.html +78 -2
- package/docs/index.html +77 -1
- package/package.json +50 -27
- package/rollup.config.js +90 -66
- package/src/core/details.ts +4 -0
- package/src/core/overflow-slider.ts +4 -2
- package/src/core/slider.ts +91 -64
- package/src/core/types.ts +29 -1
- package/src/mixins.scss +14 -0
- package/src/overflow-slider.scss +12 -10
- package/src/plugins/arrows/index.ts +2 -2
- package/src/plugins/autoplay/index.ts +276 -0
- package/src/plugins/autoplay/styles.scss +11 -0
- package/src/plugins/dots/index.ts +2 -2
- package/src/plugins/drag-scrolling/index.ts +4 -4
- package/src/plugins/fade/index.ts +2 -2
- package/src/plugins/full-width/index.ts +17 -5
- package/src/plugins/infinite-scroll/index.ts +109 -0
- package/src/plugins/scroll-indicator/index.ts +5 -3
- package/src/plugins/skip-links/index.ts +2 -2
- package/src/plugins/thumbnails/index.ts +2 -2
- package/tsconfig.json +4 -2
- package/changelog.md +0 -5
- package/dist/core/details.esm.js +0 -35
- package/dist/core/details.min.js +0 -1
- package/dist/core/overflow-slider.esm.js +0 -29
- package/dist/core/overflow-slider.min.js +0 -1
- package/dist/core/slider.esm.js +0 -499
- package/dist/core/slider.min.js +0 -1
- package/docs/dist/core/details.esm.js +0 -35
- package/docs/dist/core/details.min.js +0 -1
- package/docs/dist/core/overflow-slider.esm.js +0 -29
- package/docs/dist/core/overflow-slider.min.js +0 -1
- package/docs/dist/core/slider.esm.js +0 -499
- package/docs/dist/core/slider.min.js +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
type Slider<O = {}, C = {}, H extends string = string> = {
|
|
2
|
+
container: HTMLElement;
|
|
3
|
+
slides: HTMLElement[];
|
|
4
|
+
emit: (name: H | SliderHooks) => void;
|
|
5
|
+
moveToDirection: (direction: 'prev' | 'next') => void;
|
|
6
|
+
moveToSlideInDirection: (direction: 'prev' | 'next') => void;
|
|
7
|
+
snapToClosestSlide: (direction: 'prev' | 'next') => void;
|
|
8
|
+
moveToSlide: (index: number) => void;
|
|
9
|
+
canMoveToSlide: (index: number) => boolean;
|
|
10
|
+
getInclusiveScrollWidth: () => number;
|
|
11
|
+
getInclusiveClientWidth: () => number;
|
|
12
|
+
getScrollLeft: () => number;
|
|
13
|
+
setScrollLeft: (value: number) => void;
|
|
14
|
+
setActiveSlideIdx: () => void;
|
|
15
|
+
on: (name: H | SliderHooks, cb: SliderCallback) => void;
|
|
16
|
+
options: SliderOptions;
|
|
17
|
+
details: SliderDetails;
|
|
18
|
+
activeSlideIdx: number;
|
|
19
|
+
} & C;
|
|
20
|
+
type SliderCallback<O = {}, C = {}, H extends string = string> = (props: Slider<O, C, H>) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Recursively makes all properties of T optional.
|
|
23
|
+
* @see https://www.typescriptlang.org/docs/handbook/utility-types.html#mapped-types
|
|
24
|
+
*/
|
|
25
|
+
type DeepPartial<T> = {
|
|
26
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
27
|
+
};
|
|
28
|
+
type SliderOptions = {
|
|
29
|
+
scrollBehavior: string;
|
|
30
|
+
scrollStrategy: string;
|
|
31
|
+
slidesSelector: string;
|
|
32
|
+
emulateScrollSnap: boolean;
|
|
33
|
+
emulateScrollSnapMaxThreshold?: number;
|
|
34
|
+
cssVariableContainer: HTMLElement;
|
|
35
|
+
rtl: boolean;
|
|
36
|
+
targetWidth?: (slider: Slider) => number;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
type SliderOptionArgs = {
|
|
40
|
+
scrollBehavior?: 'smooth' | 'auto';
|
|
41
|
+
scrollStrategy?: 'fullSlide' | 'partialSlide';
|
|
42
|
+
slidesSelector?: string;
|
|
43
|
+
emulateScrollSnap?: boolean;
|
|
44
|
+
emulateScrollSnapMaxThreshold?: number;
|
|
45
|
+
cssVariableContainer?: HTMLElement;
|
|
46
|
+
rtl?: boolean;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
type SliderDetails = {
|
|
50
|
+
hasOverflow: boolean;
|
|
51
|
+
slideCount: number;
|
|
52
|
+
containerWidth: number;
|
|
53
|
+
containerHeight: number;
|
|
54
|
+
scrollableAreaWidth: number;
|
|
55
|
+
amountOfPages: number;
|
|
56
|
+
currentPage: number;
|
|
57
|
+
};
|
|
58
|
+
type SliderHooks = HOOK_CREATED | HOOK_CONTENTS_CHANGED | HOOK_DETAILS_CHANGED | HOOK_CONTAINER_SIZE_CHANGED | HOOK_ACTIVE_SLIDE_CHANGED | HOOK_SCROLL_START | HOOK_SCROLL | HOOK_SCROLL_END | HOOK_NATIVE_SCROLL_START | HOOK_NATIVE_SCROLL | HOOK_NATIVE_SCROLL_END | HOOK_PROGRAMMATIC_SCROLL_START | HOOK_PROGRAMMATIC_SCROLL | HOOK_PROGRAMMATIC_SCROLL_END;
|
|
59
|
+
type HOOK_CREATED = 'created';
|
|
60
|
+
type HOOK_DETAILS_CHANGED = 'detailsChanged';
|
|
61
|
+
type HOOK_CONTENTS_CHANGED = 'contentsChanged';
|
|
62
|
+
type HOOK_CONTAINER_SIZE_CHANGED = 'containerSizeChanged';
|
|
63
|
+
type HOOK_ACTIVE_SLIDE_CHANGED = 'activeSlideChanged';
|
|
64
|
+
type HOOK_SCROLL_START = 'scrollStart';
|
|
65
|
+
type HOOK_SCROLL = 'scroll';
|
|
66
|
+
type HOOK_SCROLL_END = 'scrollEnd';
|
|
67
|
+
type HOOK_NATIVE_SCROLL_START = 'nativeScrollStart';
|
|
68
|
+
type HOOK_NATIVE_SCROLL = 'nativeScroll';
|
|
69
|
+
type HOOK_NATIVE_SCROLL_END = 'nativeScrollEnd';
|
|
70
|
+
type HOOK_PROGRAMMATIC_SCROLL_START = 'programmaticScrollStart';
|
|
71
|
+
type HOOK_PROGRAMMATIC_SCROLL = 'programmaticScroll';
|
|
72
|
+
type HOOK_PROGRAMMATIC_SCROLL_END = 'programmaticScrollEnd';
|
|
73
|
+
type SliderPlugin = (slider: Slider) => void;
|
|
74
|
+
|
|
75
|
+
export type { DeepPartial, HOOK_ACTIVE_SLIDE_CHANGED, HOOK_CONTAINER_SIZE_CHANGED, HOOK_CONTENTS_CHANGED, HOOK_CREATED, HOOK_DETAILS_CHANGED, HOOK_NATIVE_SCROLL, HOOK_NATIVE_SCROLL_END, HOOK_NATIVE_SCROLL_START, HOOK_PROGRAMMATIC_SCROLL, HOOK_PROGRAMMATIC_SCROLL_END, HOOK_PROGRAMMATIC_SCROLL_START, HOOK_SCROLL, HOOK_SCROLL_END, HOOK_SCROLL_START, Slider, SliderCallback, SliderDetails, SliderHooks, SliderOptionArgs, SliderOptions, SliderPlugin };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SliderOptionArgs, SliderPlugin, SliderCallback, SliderOptions, SliderDetails } from './index.js';
|
|
2
|
+
|
|
3
|
+
declare function OverflowSlider(container: HTMLElement, options?: SliderOptionArgs, plugins?: SliderPlugin[]): {
|
|
4
|
+
container: HTMLElement;
|
|
5
|
+
slides: HTMLElement[];
|
|
6
|
+
emit: (name: string) => void;
|
|
7
|
+
moveToDirection: (direction: "prev" | "next") => void;
|
|
8
|
+
moveToSlideInDirection: (direction: "prev" | "next") => void;
|
|
9
|
+
snapToClosestSlide: (direction: "prev" | "next") => void;
|
|
10
|
+
moveToSlide: (index: number) => void;
|
|
11
|
+
canMoveToSlide: (index: number) => boolean;
|
|
12
|
+
getInclusiveScrollWidth: () => number;
|
|
13
|
+
getInclusiveClientWidth: () => number;
|
|
14
|
+
getScrollLeft: () => number;
|
|
15
|
+
setScrollLeft: (value: number) => void;
|
|
16
|
+
setActiveSlideIdx: () => void;
|
|
17
|
+
on: (name: string, cb: SliderCallback) => void;
|
|
18
|
+
options: SliderOptions;
|
|
19
|
+
details: SliderDetails;
|
|
20
|
+
activeSlideIdx: number;
|
|
21
|
+
} | undefined;
|
|
22
|
+
|
|
23
|
+
export { OverflowSlider as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type DotsOptions = {
|
|
4
|
+
texts: {
|
|
5
|
+
dotDescription: string;
|
|
6
|
+
};
|
|
7
|
+
classNames: {
|
|
8
|
+
dotsContainer: string;
|
|
9
|
+
dotsItem: string;
|
|
10
|
+
};
|
|
11
|
+
container: HTMLElement | null;
|
|
12
|
+
};
|
|
13
|
+
declare function DotsPlugin(args?: DeepPartial<DotsOptions>): (slider: Slider) => void;
|
|
14
|
+
|
|
15
|
+
export { DotsPlugin as default };
|
|
16
|
+
export type { DotsOptions };
|
|
@@ -1 +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 i,s;const a={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!==(i=null==n?void 0:n.container)&&void 0!==i?i:null},r=document.createElement("div");r.classList.add(a.classNames.dotsContainer);let d=null;const l=()=>{r.setAttribute("data-has-content",o.details.hasOverflow.toString()),r.innerHTML="";const t=document.createElement("ul"),e=o.details.slideCount,n=o.activeSlideIdx;if(!(e<=1)){for(let o=0;o<e;o++){const i=document.createElement("li"),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("class",a.classNames.dotsItem),s.setAttribute("aria-label",a.texts.dotDescription.replace("%d",(o+1).toString()).replace("%d",e.toString())),s.setAttribute("aria-pressed",(o===n).toString()),s.setAttribute("data-item",(o+1).toString()),i.appendChild(s),t.appendChild(i),s.addEventListener("click",(
|
|
1
|
+
const t={dotDescription:"Page %d of %d"},e={dotsContainer:"overflow-slider__dots",dotsItem:"overflow-slider__dot-item"};function n(n){return o=>{var i,s;const a={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!==(i=null==n?void 0:n.container)&&void 0!==i?i:null},r=document.createElement("div");r.classList.add(a.classNames.dotsContainer);let d=null;const l=()=>{r.setAttribute("data-has-content",o.details.hasOverflow.toString()),r.innerHTML="";const t=document.createElement("ul"),e=o.details.slideCount,n=o.activeSlideIdx;if(!(e<=1)){for(let o=0;o<e;o++){const i=document.createElement("li"),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("class",a.classNames.dotsItem),s.setAttribute("aria-label",a.texts.dotDescription.replace("%d",(o+1).toString()).replace("%d",e.toString())),s.setAttribute("aria-pressed",(o===n).toString()),s.setAttribute("data-item",(o+1).toString()),i.appendChild(s),t.appendChild(i),s.addEventListener("click",()=>c(o+1)),s.addEventListener("focus",()=>d=o+1),s.addEventListener("keydown",t=>{var n;const o=r.querySelector('[aria-pressed="true"]');if(!o)return;const i=parseInt(null!==(n=o.getAttribute("data-item"))&&void 0!==n?n:"1");if("ArrowLeft"===t.key){const t=i-1;if(t>0){const e=r.querySelector(`[data-item="${t}"]`);e&&e.focus(),c(t)}}if("ArrowRight"===t.key){const t=i+1;if(t<=e){const e=r.querySelector(`[data-item="${t}"]`);e&&e.focus(),c(t)}}})}if(r.appendChild(t),d){const t=r.querySelector(`[data-item="${d}"]`);t&&t.focus()}}},c=t=>{o.moveToSlide(t-1)};l(),a.container?a.container.appendChild(r):null===(s=o.container.parentNode)||void 0===s||s.insertBefore(r,o.container.nextSibling),o.on("scrollEnd",l),o.on("contentsChanged",l),o.on("containerSizeChanged",l)}}export{n as default};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type DragScrollingOptions = {
|
|
4
|
+
draggedDistanceThatPreventsClick: number;
|
|
5
|
+
};
|
|
6
|
+
declare function DragScrollingPlugin(args?: DeepPartial<DragScrollingOptions>): (slider: Slider) => void;
|
|
7
|
+
|
|
8
|
+
export { DragScrollingPlugin as default };
|
|
9
|
+
export type { DragScrollingOptions };
|
|
@@ -22,7 +22,7 @@ function DragScrollingPlugin(args) {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
isMouseDown = true;
|
|
25
|
-
startX = e.pageX - slider.container.
|
|
25
|
+
startX = e.pageX - slider.container.getBoundingClientRect().left;
|
|
26
26
|
scrollLeft = slider.container.scrollLeft;
|
|
27
27
|
// change cursor to grabbing
|
|
28
28
|
slider.container.style.cursor = 'grabbing';
|
|
@@ -45,7 +45,7 @@ function DragScrollingPlugin(args) {
|
|
|
45
45
|
programmaticScrollStarted = true;
|
|
46
46
|
slider.emit('programmaticScrollStart');
|
|
47
47
|
}
|
|
48
|
-
const x = e.pageX - slider.container.
|
|
48
|
+
const x = e.pageX - slider.container.getBoundingClientRect().left;
|
|
49
49
|
const walk = (x - startX);
|
|
50
50
|
const newScrollLeft = scrollLeft - walk;
|
|
51
51
|
mayNeedToSnap = true;
|
|
@@ -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,l=!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,i=!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.getBoundingClientRect().left,r=e.container.scrollLeft,e.container.style.cursor="grabbing",e.container.style.scrollBehavior="auto",o.preventDefault(),o.stopPropagation())}),window.addEventListener("mousemove",s=>{if(!e.details.hasOverflow)return void(l=!1);if(!t)return void(l=!1);s.preventDefault(),l||(l=!0,e.emit("programmaticScrollStart"));const c=s.pageX-e.container.getBoundingClientRect().left-n,d=r-c;i=!0,Math.floor(e.container.scrollLeft)!==Math.floor(d)&&(a=e.container.scrollLeft<d),e.container.scrollLeft=d;const u=Math.abs(c),v=e.container.querySelectorAll(e.options.slidesSelector),f=u>o?"none":"";v.forEach(e=>{e.style.pointerEvents=f})}),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=()=>{i&&!t&&(i=!1,e.snapToClosestSlide(a?"next":"prev"))};e.on("programmaticScrollEnd",o),window.addEventListener("mouseup",o)}}}export{e as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type FadeOptions = {
|
|
4
|
+
classNames: {
|
|
5
|
+
fadeItem: string;
|
|
6
|
+
fadeItemStart: string;
|
|
7
|
+
fadeItemEnd: string;
|
|
8
|
+
};
|
|
9
|
+
container: HTMLElement | null;
|
|
10
|
+
containerStart: HTMLElement | null;
|
|
11
|
+
containerEnd: HTMLElement | null;
|
|
12
|
+
};
|
|
13
|
+
declare function FadePlugin(args?: DeepPartial<FadeOptions>): (slider: Slider) => void;
|
|
14
|
+
|
|
15
|
+
export { FadePlugin as default };
|
|
16
|
+
export type { FadeOptions };
|
|
@@ -1 +1 @@
|
|
|
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",(
|
|
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};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type FullWidthOptions = {
|
|
4
|
+
targetWidth: (slider: Slider) => number;
|
|
5
|
+
addMarginBefore: boolean;
|
|
6
|
+
addMarginAfter: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function FullWidthPlugin(args?: DeepPartial<FullWidthOptions>): (slider: Slider) => void;
|
|
9
|
+
|
|
10
|
+
export { FullWidthPlugin as default };
|
|
11
|
+
export type { FullWidthOptions };
|
|
@@ -3,7 +3,7 @@ function FullWidthPlugin(args) {
|
|
|
3
3
|
return (slider) => {
|
|
4
4
|
var _a, _b, _c;
|
|
5
5
|
const options = {
|
|
6
|
-
targetWidth: (_a = args === null || args === void 0 ? void 0 : args.targetWidth) !== null && _a !== void 0 ? _a :
|
|
6
|
+
targetWidth: (_a = args === null || args === void 0 ? void 0 : args.targetWidth) !== null && _a !== void 0 ? _a : null,
|
|
7
7
|
addMarginBefore: (_b = args === null || args === void 0 ? void 0 : args.addMarginBefore) !== null && _b !== void 0 ? _b : true,
|
|
8
8
|
addMarginAfter: (_c = args === null || args === void 0 ? void 0 : args.addMarginAfter) !== null && _c !== void 0 ? _c : true,
|
|
9
9
|
};
|
|
@@ -14,7 +14,7 @@ function FullWidthPlugin(args) {
|
|
|
14
14
|
}
|
|
15
15
|
const firstSlide = slides[0];
|
|
16
16
|
const lastSlide = slides[slides.length - 1];
|
|
17
|
-
const marginAmount = Math.floor((window.innerWidth -
|
|
17
|
+
const marginAmount = Math.floor((window.innerWidth - getTargetWidth()) / 2);
|
|
18
18
|
if (options.addMarginBefore) {
|
|
19
19
|
firstSlide.style.marginInlineStart = `${marginAmount}px`;
|
|
20
20
|
}
|
|
@@ -24,8 +24,19 @@ function FullWidthPlugin(args) {
|
|
|
24
24
|
slider.container.setAttribute('data-full-width-offset', marginAmount.toString());
|
|
25
25
|
setCSS();
|
|
26
26
|
};
|
|
27
|
+
const getTargetWidth = () => {
|
|
28
|
+
if (typeof options.targetWidth === 'function') {
|
|
29
|
+
return options.targetWidth(slider);
|
|
30
|
+
}
|
|
31
|
+
if (typeof slider.options.targetWidth === 'function') {
|
|
32
|
+
return slider.options.targetWidth(slider);
|
|
33
|
+
}
|
|
34
|
+
return DEFAULT_TARGET_WIDTH(slider);
|
|
35
|
+
};
|
|
27
36
|
const setCSS = () => {
|
|
28
|
-
slider.
|
|
37
|
+
if (typeof slider.options.targetWidth === 'function') {
|
|
38
|
+
slider.options.cssVariableContainer.style.setProperty('--slider-container-target-width', `${getTargetWidth()}px`);
|
|
39
|
+
}
|
|
29
40
|
};
|
|
30
41
|
update();
|
|
31
42
|
slider.on('contentsChanged', update);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function t(t){return n=>{var e,i,o;const r={targetWidth:null!==(e=null==t?void 0:t.targetWidth)&&void 0!==e?e:null,addMarginBefore:null===(i=null==t?void 0:t.addMarginBefore)||void 0===i||i,addMarginAfter:null===(o=null==t?void 0:t.addMarginAfter)||void 0===o||o},d=()=>{const t=n.container.querySelectorAll(n.options.slidesSelector);if(!t.length)return;const e=t[0],i=t[t.length-1],o=Math.floor((window.innerWidth-a())/2);r.addMarginBefore&&(e.style.marginInlineStart=`${o}px`),r.addMarginAfter&&(i.style.marginInlineEnd=`${o}px`),n.container.setAttribute("data-full-width-offset",o.toString()),l()},a=()=>"function"==typeof r.targetWidth?r.targetWidth(n):"function"==typeof n.options.targetWidth?n.options.targetWidth(n):(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})(n),l=()=>{"function"==typeof n.options.targetWidth&&n.options.cssVariableContainer.style.setProperty("--slider-container-target-width",`${a()}px`)};d(),n.on("contentsChanged",d),n.on("containerSizeChanged",d),window.addEventListener("resize",d)}}export{t as default};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SliderPlugin } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Infinite‐scroll plugin
|
|
5
|
+
*
|
|
6
|
+
* Experimental work-in-progress not available for public use yet.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} InfiniteScrollOptions
|
|
11
|
+
* @property {number} [lookAheadCount=1] Number of slides to look ahead when deciding to reparent.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Creates an infinite scroll plugin for a slider that re-parents multiple slides
|
|
15
|
+
* before hitting the container edge, to avoid blank space and keep the same
|
|
16
|
+
* active slide visible.
|
|
17
|
+
*
|
|
18
|
+
* @param {InfiniteScrollOptions} [options] Plugin configuration.
|
|
19
|
+
* @returns {SliderPlugin} The configured slider plugin.
|
|
20
|
+
*/
|
|
21
|
+
declare function InfiniteScrollPlugin(options?: {
|
|
22
|
+
lookAheadCount?: number;
|
|
23
|
+
}): SliderPlugin;
|
|
24
|
+
|
|
25
|
+
export { InfiniteScrollPlugin as default };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} InfiniteScrollOptions
|
|
3
|
+
* @property {number} [lookAheadCount=1] Number of slides to look ahead when deciding to reparent.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates an infinite scroll plugin for a slider that re-parents multiple slides
|
|
7
|
+
* before hitting the container edge, to avoid blank space and keep the same
|
|
8
|
+
* active slide visible.
|
|
9
|
+
*
|
|
10
|
+
* @param {InfiniteScrollOptions} [options] Plugin configuration.
|
|
11
|
+
* @returns {SliderPlugin} The configured slider plugin.
|
|
12
|
+
*/
|
|
13
|
+
function InfiniteScrollPlugin(options = {}) {
|
|
14
|
+
const { lookAheadCount = 1 } = options;
|
|
15
|
+
return (slider) => {
|
|
16
|
+
const { container, options: sliderOpts } = slider;
|
|
17
|
+
/**
|
|
18
|
+
* Sum widths of the first or last N slides for lookahead.
|
|
19
|
+
*
|
|
20
|
+
* @param {HTMLElement[]} slides List of slide elements.
|
|
21
|
+
* @param {boolean} fromEnd If true, sum last N; otherwise, first N.
|
|
22
|
+
* @returns {number} Total pixel width of N slides.
|
|
23
|
+
*/
|
|
24
|
+
function getLookAheadWidth(slides, fromEnd) {
|
|
25
|
+
const slice = fromEnd
|
|
26
|
+
? slides.slice(-lookAheadCount)
|
|
27
|
+
: slides.slice(0, lookAheadCount);
|
|
28
|
+
return slice.reduce((total, slide) => total + slide.offsetWidth, 0);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Handler for slider.scrollEnd event that re-parents slides
|
|
32
|
+
* and retains the active slide element by recalculating its
|
|
33
|
+
* new index after DOM shifts.
|
|
34
|
+
*/
|
|
35
|
+
function onScroll() {
|
|
36
|
+
const activeSlideIdx = slider.activeSlideIdx;
|
|
37
|
+
const scrollLeft = slider.getScrollLeft();
|
|
38
|
+
const viewportWidth = slider.getInclusiveClientWidth();
|
|
39
|
+
const totalWidth = slider.getInclusiveScrollWidth();
|
|
40
|
+
// Grab current slide elements
|
|
41
|
+
let slides = Array.from(container.querySelectorAll(sliderOpts.slidesSelector));
|
|
42
|
+
if (slides.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
// Store reference to currently active slide element
|
|
45
|
+
const activeSlideEl = slides[activeSlideIdx];
|
|
46
|
+
const aheadRight = getLookAheadWidth(slides, false);
|
|
47
|
+
const aheadLeft = getLookAheadWidth(slides, true);
|
|
48
|
+
// 🐆 Tip: Batch DOM reads/writes inside requestAnimationFrame to avoid thrashing.
|
|
49
|
+
if (scrollLeft + viewportWidth >= totalWidth - aheadRight) {
|
|
50
|
+
for (let i = 0; i < lookAheadCount && slides.length; i++) {
|
|
51
|
+
container.append(slides.shift());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (scrollLeft <= aheadLeft) {
|
|
55
|
+
for (let i = 0; i < lookAheadCount && slides.length; i++) {
|
|
56
|
+
container.prepend(slides.pop());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
slider.setActiveSlideIdx();
|
|
60
|
+
// Re-query slides after DOM mutation
|
|
61
|
+
slides = Array.from(container.querySelectorAll(sliderOpts.slidesSelector));
|
|
62
|
+
const newIndex = slides.indexOf(activeSlideEl);
|
|
63
|
+
slides[newIndex];
|
|
64
|
+
if (newIndex >= 0 && slider.canMoveToSlide(newIndex)) {
|
|
65
|
+
slider.moveToSlide(newIndex);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
slider.snapToClosestSlide('next');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
slider.on('scrollEnd', onScroll);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { InfiniteScrollPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e={}){const{lookAheadCount:t=1}=e;return e=>{const{container:l,options:o}=e;function n(e,l){return(l?e.slice(-t):e.slice(0,t)).reduce((e,t)=>e+t.offsetWidth,0)}e.on("scrollEnd",function(){const i=e.activeSlideIdx,r=e.getScrollLeft(),c=e.getInclusiveClientWidth(),s=e.getInclusiveScrollWidth();let d=Array.from(l.querySelectorAll(o.slidesSelector));if(0===d.length)return;const f=d[i],u=n(d,!1),S=n(d,!0);if(r+c>=s-u)for(let e=0;e<t&&d.length;e++)l.append(d.shift());else if(r<=S)for(let e=0;e<t&&d.length;e++)l.prepend(d.pop());e.setActiveSlideIdx(),d=Array.from(l.querySelectorAll(o.slidesSelector));const a=d.indexOf(f);d[a],a>=0&&e.canMoveToSlide(a)?e.moveToSlide(a):e.snapToClosestSlide("next")})}}export{e as default};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type ScrollIndicatorOptions = {
|
|
4
|
+
classNames: {
|
|
5
|
+
scrollIndicator: string;
|
|
6
|
+
scrollIndicatorBar: string;
|
|
7
|
+
scrollIndicatorButton: string;
|
|
8
|
+
};
|
|
9
|
+
container: HTMLElement | null;
|
|
10
|
+
};
|
|
11
|
+
declare function ScrollIndicatorPlugin(args?: DeepPartial<ScrollIndicatorOptions>): (slider: Slider) => void;
|
|
12
|
+
|
|
13
|
+
export { ScrollIndicatorPlugin as default };
|
|
14
|
+
export type { ScrollIndicatorOptions };
|
|
@@ -84,11 +84,13 @@ function ScrollIndicatorPlugin(args) {
|
|
|
84
84
|
const scrollbarButtonWidth = scrollbarButton.offsetWidth;
|
|
85
85
|
const scrollbarButtonLeft = getScrollbarButtonLeftOffset();
|
|
86
86
|
const scrollbarButtonRight = scrollbarButtonLeft + scrollbarButtonWidth;
|
|
87
|
-
const clickX = e.pageX -
|
|
87
|
+
const clickX = e.pageX - scrollbarContainer.getBoundingClientRect().left;
|
|
88
88
|
if (Math.floor(clickX) < Math.floor(scrollbarButtonLeft)) {
|
|
89
|
+
console.log('move left');
|
|
89
90
|
slider.moveToDirection(slider.options.rtl ? 'next' : 'prev');
|
|
90
91
|
}
|
|
91
92
|
else if (Math.floor(clickX) > Math.floor(scrollbarButtonRight)) {
|
|
93
|
+
console.log('move right');
|
|
92
94
|
slider.moveToDirection(slider.options.rtl ? 'prev' : 'next');
|
|
93
95
|
}
|
|
94
96
|
});
|
|
@@ -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 o=>{var r,
|
|
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 n,r,i;const a={classNames:Object.assign(Object.assign({},t),(null==e?void 0:e.classNames)||[]),container:null!==(n=null==e?void 0:e.container)&&void 0!==n?n:null},s=document.createElement("div");s.setAttribute("class",a.classNames.scrollIndicator),s.setAttribute("tabindex","0"),s.setAttribute("role","scrollbar"),s.setAttribute("aria-controls",null!==(r=o.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",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 n=o.getScrollLeft()/(o.getInclusiveScrollWidth()-o.container.offsetWidth)*100;s.setAttribute("aria-valuenow",Math.round(Number.isNaN(n)?0:n).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,g=o.getScrollLeft();s.addEventListener("click",t=>{if(t.target==c)return;const e=c.offsetWidth,n=u(),r=n+e,i=t.pageX-s.getBoundingClientRect().left;Math.floor(i)<Math.floor(n)?(console.log("move left"),o.moveToDirection(o.options.rtl?"next":"prev")):Math.floor(i)>Math.floor(r)&&(console.log("move right"),o.moveToDirection(o.options.rtl?"prev":"next"))});const m=t=>{b=!0;const e=t.pageX||t.touches[0].pageX;h=e-s.offsetLeft,g=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,n=o.details.scrollableAreaWidth/s.offsetWidth,r=(e-h)*n,i=o.options.rtl?g-r:g+r;o.setScrollLeft(i)},w=()=>{b=!1,c.style.cursor="",c.setAttribute("data-is-grabbed","false")};c.addEventListener("mousedown",m),c.addEventListener("touchstart",m),window.addEventListener("mousemove",p),window.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("mouseup",w),window.addEventListener("touchend",w)}}export{e as default};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type SkipLinkOptions = {
|
|
4
|
+
texts: {
|
|
5
|
+
skipList: string;
|
|
6
|
+
};
|
|
7
|
+
classNames: {
|
|
8
|
+
skipLink: string;
|
|
9
|
+
skipLinkTarget: string;
|
|
10
|
+
};
|
|
11
|
+
containerBefore: HTMLElement | null;
|
|
12
|
+
containerAfter: HTMLElement | null;
|
|
13
|
+
};
|
|
14
|
+
declare function SkipLinksPlugin(args?: DeepPartial<SkipLinkOptions>): (slider: Slider) => void;
|
|
15
|
+
|
|
16
|
+
export { SkipLinksPlugin as default };
|
|
17
|
+
export type { SkipLinkOptions };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function generateId(prefix, i = 1) {
|
|
2
|
+
const id = `${prefix}-${i}`;
|
|
3
|
+
if (document.getElementById(id)) {
|
|
4
|
+
return generateId(prefix, i + 1);
|
|
5
|
+
}
|
|
6
|
+
return id;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
const DEFAULT_TEXTS = {
|
|
4
10
|
skipList: 'Skip list'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(t,n=1){const i=`${t}-${n}`;return document.getElementById(i)?e(t,n+1):i}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"),v=document.createElement("a");v.setAttribute("href",`#${f}`),v.textContent=u.texts.skipList,v.classList.add(u.classNames.skipLink);const p=document.createElement("div");p.setAttribute("id",f),p.setAttribute("tabindex","-1"),u.containerBefore?null===(a=u.containerBefore.parentNode)||void 0===a||a.insertBefore(v,u.containerBefore):null===(l=r.container.parentNode)||void 0===l||l.insertBefore(v,r.container),u.containerAfter?null===(c=u.containerAfter.parentNode)||void 0===c||c.insertBefore(p,u.containerAfter.nextSibling):null===(d=r.container.parentNode)||void 0===d||d.insertBefore(p,r.container.nextSibling)}}export{i as default};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeepPartial, Slider } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
type ThumbnailsOptions = {
|
|
4
|
+
mainSlider: Slider;
|
|
5
|
+
};
|
|
6
|
+
declare function FullWidthPlugin(args: DeepPartial<ThumbnailsOptions>): (slider: Slider) => void;
|
|
7
|
+
|
|
8
|
+
export { FullWidthPlugin as default };
|
|
9
|
+
export type { ThumbnailsOptions };
|
|
@@ -1 +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(
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
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{
|
|
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{n as a,t as g,e as o};
|
|
@@ -34,4 +34,4 @@ function getOutermostChildrenEdgeMarginSum(el) {
|
|
|
34
34
|
return firstChildMarginLeft + lastChildMarginRight;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export {
|
|
37
|
+
export { getOutermostChildrenEdgeMarginSum as a, generateId as g, objectsAreEqual as o };
|
package/docs/assets/demo.css
CHANGED
|
@@ -370,6 +370,77 @@ h3:before {
|
|
|
370
370
|
gap: 1rem;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
.overflow-slider__autoplay {
|
|
374
|
+
--autoplay-bg-color: #e5e5e5;
|
|
375
|
+
--autoplay-progress-color: #303030;
|
|
376
|
+
--autoplay-icon-color: #303030;
|
|
377
|
+
cursor: pointer;
|
|
378
|
+
border-radius: 50%;
|
|
379
|
+
position: relative;
|
|
380
|
+
display: inline-flex;
|
|
381
|
+
align-items: center;
|
|
382
|
+
justify-content: center;
|
|
383
|
+
width: 2.5rem;
|
|
384
|
+
height: 2.5rem;
|
|
385
|
+
border: none;
|
|
386
|
+
background: var(--autoplay-bg-color);
|
|
387
|
+
color: var(--autoplay-icon-color);
|
|
388
|
+
/* ensure the pseudo-element paints on its own layer */
|
|
389
|
+
will-change: background;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.overflow-slider__autoplay::before {
|
|
393
|
+
content: "";
|
|
394
|
+
|
|
395
|
+
position: absolute;
|
|
396
|
+
inset: 0;
|
|
397
|
+
border-radius: 50%;
|
|
398
|
+
/* draw the circular progress using conic-gradient */
|
|
399
|
+
background:
|
|
400
|
+
conic-gradient(
|
|
401
|
+
var(--autoplay-progress-color) calc(var(--autoplay-delay-progress) * 1%),
|
|
402
|
+
transparent 0
|
|
403
|
+
);
|
|
404
|
+
/* rotate so “0%” starts at top */
|
|
405
|
+
transform: rotate(-90deg);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.overflow-slider__autoplay::after {
|
|
409
|
+
content: "";
|
|
410
|
+
position: absolute;
|
|
411
|
+
border-radius: 50%;
|
|
412
|
+
left: 10%;
|
|
413
|
+
width: 80%;
|
|
414
|
+
height: 80%;
|
|
415
|
+
top: 10%;
|
|
416
|
+
background: var(--autoplay-bg-color);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.overflow-slider__autoplay:hover,
|
|
420
|
+
.overflow-slider__autoplay:focus {
|
|
421
|
+
background: var(--color-primary);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.overflow-slider__autoplay:hover::before,
|
|
425
|
+
.overflow-slider__autoplay:focus::before {
|
|
426
|
+
background: transparent;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.overflow-slider__autoplay:hover::after,
|
|
430
|
+
.overflow-slider__autoplay:focus::after {
|
|
431
|
+
background: transparent;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.overflow-slider__autoplay svg {
|
|
435
|
+
position: absolute;
|
|
436
|
+
z-index: 2;
|
|
437
|
+
width: 1.25rem;
|
|
438
|
+
height: 1.25rem;
|
|
439
|
+
left: 50%;
|
|
440
|
+
top: 50%;
|
|
441
|
+
transform: translate(-50%, -50%);
|
|
442
|
+
}
|
|
443
|
+
|
|
373
444
|
.example-item {
|
|
374
445
|
aspect-ratio: 3/4;
|
|
375
446
|
width: 240px;
|
|
@@ -451,11 +522,21 @@ h3:before {
|
|
|
451
522
|
grid-template-columns: repeat(var(--slider-slides-count, 1), var(--slider-container-width, 900px));
|
|
452
523
|
}
|
|
453
524
|
|
|
525
|
+
.example-container-1-autoplay-wrap-view,
|
|
526
|
+
.example-container-1-autoplay-wrap-slide {
|
|
527
|
+
margin-top: 16px;
|
|
528
|
+
}
|
|
529
|
+
|
|
454
530
|
.example-container-1-dots .example-item {
|
|
455
531
|
aspect-ratio: 16/7;
|
|
456
532
|
width: 100%;
|
|
457
533
|
}
|
|
458
534
|
|
|
535
|
+
.example-container-1-infinite > * {
|
|
536
|
+
width: var(--slider-container-width, 400px);
|
|
537
|
+
aspect-ratio: 16/8;
|
|
538
|
+
}
|
|
539
|
+
|
|
459
540
|
.example-container-1-fade-wrap {
|
|
460
541
|
position: relative;
|
|
461
542
|
}
|
|
@@ -683,3 +764,37 @@ h3:before {
|
|
|
683
764
|
background: var(--color-grey-800);
|
|
684
765
|
color: #fff;
|
|
685
766
|
}
|
|
767
|
+
|
|
768
|
+
/* ===========================================================================
|
|
769
|
+
Example 4: Hero
|
|
770
|
+
=========================================================================== */
|
|
771
|
+
|
|
772
|
+
.example-container-4-hero__wrapper {
|
|
773
|
+
position: relative;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
.example-container-4-hero {
|
|
777
|
+
--slider-gap: 0;
|
|
778
|
+
gap: 0;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.example-container-4-hero > * {
|
|
782
|
+
width: var(--slider-container-width, 900px);
|
|
783
|
+
aspect-ratio: 16/9;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.example-container-4-hero__autoplay {
|
|
787
|
+
position: absolute;
|
|
788
|
+
bottom: 1rem;
|
|
789
|
+
right: 1rem;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.example-container-4-hero__dots {
|
|
793
|
+
z-index: 10;
|
|
794
|
+
position: absolute;
|
|
795
|
+
bottom: 1rem;
|
|
796
|
+
left: 50%;
|
|
797
|
+
transform: translateX(-50%);
|
|
798
|
+
--overflow-slider-dot-inactive-color: rgba(0, 0, 0, 0.2);
|
|
799
|
+
--overflow-slider-dot-active-color: rgba(0, 0, 0, .8);
|
|
800
|
+
}
|