@evermade/overflow-slider 4.2.0 → 4.2.1
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 +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +8 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/overflow-slider.css +1 -1
- package/dist/plugins/arrows/index.d.ts +1 -1
- package/dist/plugins/autoplay/index.d.ts +1 -1
- package/dist/plugins/classnames/index.d.ts +1 -1
- package/dist/plugins/core/index.d.ts +65 -10
- package/dist/plugins/core/index.d2.ts +12 -63
- package/dist/plugins/dots/index.d.ts +1 -1
- package/dist/plugins/dots/index.esm.js +9 -1
- package/dist/plugins/dots/index.min.js +1 -1
- package/dist/plugins/drag-scrolling/index.d.ts +1 -1
- package/dist/plugins/fade/index.d.ts +1 -1
- package/dist/plugins/full-width/index.d.ts +1 -1
- package/dist/plugins/scroll-indicator/index.d.ts +1 -1
- package/dist/plugins/skip-links/index.d.ts +1 -1
- package/dist/plugins/thumbnails/index.d.ts +1 -1
- package/docs/assets/demo.css +6 -0
- package/docs/assets/demo.js +22 -0
- package/docs/dist/index.esm.js +8 -3
- package/docs/dist/index.esm.js.map +1 -1
- package/docs/dist/index.min.js +1 -1
- package/docs/dist/index.min.js.map +1 -1
- package/docs/dist/overflow-slider.css +1 -1
- package/docs/dist/plugins/core/index.d.ts +2 -0
- package/docs/dist/plugins/core/index.d2.ts +2 -0
- package/docs/dist/plugins/dots/index.esm.js +9 -1
- package/docs/dist/plugins/dots/index.min.js +1 -1
- package/docs/index.html +15 -0
- package/package.json +1 -1
- package/src/core/details.ts +6 -3
- package/src/core/slider.ts +2 -0
- package/src/core/types.ts +2 -0
- package/src/plugins/dots/index.ts +13 -2
- package/src/plugins/dots/styles.scss +0 -1
package/dist/overflow-slider.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--overflow-slider-arrows-size:1.5rem;--overflow-slider-arrows-gap:.5rem;--overflow-slider-arrows-inactive-opacity:0.5}.overflow-slider__arrows{display:flex;gap:var(--overflow-slider-arrows-gap)}.overflow-slider__arrows-button{align-items:center;cursor:pointer;display:flex;outline-offset:-2px}.overflow-slider__arrows-button svg{height:var(--overflow-slider-arrows-size);width:var(--overflow-slider-arrows-size)}.overflow-slider__arrows-button[data-has-content=false]{opacity:var(--overflow-slider-arrows-inactive-opacity)}:root{--overflow-slider-autoplay-background:#000}.overflow-slider__autoplay{background:var(--overflow-slider-autoplay-background)}:root{--overflow-slider-dots-gap:0.5rem;--overflow-slider-dot-size:0.75rem;--overflow-slider-dot-inactive-color:rgba(0,0,0,.1);--overflow-slider-dot-active-color:rgba(0,0,0,.8)}.overflow-slider__dots{align-items:center;display:flex;justify-content:center}.overflow-slider__dots ul{display:flex;flex-wrap:wrap;gap:var(--overflow-slider-dots-gap);list-style:none;margin:0;padding:0}.overflow-slider__dots li{line-height:0;margin:0;padding:0}.overflow-slider__dot-item{background:var(--overflow-slider-dot-inactive-color);border-radius:50%;cursor:pointer;height:var(--overflow-slider-dot-size);margin:0;outline-offset:2px;padding:0;position:relative;width:var(--overflow-slider-dot-size)}.overflow-slider__dot-item:after{bottom:calc(var(--overflow-slider-dots-gap)*-1);content:"";display:block;left:calc(var(--overflow-slider-dots-gap)*-1);position:absolute;right:calc(var(--overflow-slider-dots-gap)*-1);top:calc(var(--overflow-slider-dots-gap)*-1)}.overflow-slider__dot-item:
|
|
1
|
+
:root{--overflow-slider-arrows-size:1.5rem;--overflow-slider-arrows-gap:.5rem;--overflow-slider-arrows-inactive-opacity:0.5}.overflow-slider__arrows{display:flex;gap:var(--overflow-slider-arrows-gap)}.overflow-slider__arrows-button{align-items:center;cursor:pointer;display:flex;outline-offset:-2px}.overflow-slider__arrows-button svg{height:var(--overflow-slider-arrows-size);width:var(--overflow-slider-arrows-size)}.overflow-slider__arrows-button[data-has-content=false]{opacity:var(--overflow-slider-arrows-inactive-opacity)}:root{--overflow-slider-autoplay-background:#000}.overflow-slider__autoplay{background:var(--overflow-slider-autoplay-background)}:root{--overflow-slider-dots-gap:0.5rem;--overflow-slider-dot-size:0.75rem;--overflow-slider-dot-inactive-color:rgba(0,0,0,.1);--overflow-slider-dot-active-color:rgba(0,0,0,.8)}.overflow-slider__dots{align-items:center;display:flex;justify-content:center}.overflow-slider__dots ul{display:flex;flex-wrap:wrap;gap:var(--overflow-slider-dots-gap);list-style:none;margin:0;padding:0}.overflow-slider__dots li{line-height:0;margin:0;padding:0}.overflow-slider__dot-item{background:var(--overflow-slider-dot-inactive-color);border-radius:50%;cursor:pointer;height:var(--overflow-slider-dot-size);margin:0;outline-offset:2px;padding:0;position:relative;width:var(--overflow-slider-dot-size)}.overflow-slider__dot-item:after{bottom:calc(var(--overflow-slider-dots-gap)*-1);content:"";display:block;left:calc(var(--overflow-slider-dots-gap)*-1);position:absolute;right:calc(var(--overflow-slider-dots-gap)*-1);top:calc(var(--overflow-slider-dots-gap)*-1)}.overflow-slider__dot-item:hover,.overflow-slider__dot-item[aria-pressed=true]{background:var(--overflow-slider-dot-active-color)}:root{--overflow-slider-fade-color:#fff;--overflow-slider-fade-width:3rem}.overflow-slider-fade{height:100%;pointer-events:none;position:absolute;top:0;width:var(--overflow-slider-fade-width);z-index:1}.overflow-slider-fade--start{background:linear-gradient(to right,var(--overflow-slider-fade-color) 0,transparent 100%);left:0}[dir=rtl] .overflow-slider-fade--start{left:auto}.overflow-slider-fade--end,[dir=rtl] .overflow-slider-fade--start{background:linear-gradient(to left,var(--overflow-slider-fade-color) 0,transparent 100%);right:0}[dir=rtl] .overflow-slider-fade--end{background:linear-gradient(to right,var(--overflow-slider-fade-color) 0,transparent 100%);left:0;right:auto}[data-has-drag-scrolling][data-has-overflow=true]{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}:root{--overflow-slider-scroll-indicator-button-height:4px;--overflow-slider-scroll-indicator-padding:1rem;--overflow-slider-scroll-indicator-button-color:rgba(0,0,0,.75);--overflow-slider-scroll-indicator-bar-color:rgba(0,0,0,.25)}.overflow-slider__scroll-indicator{cursor:pointer;outline:0;padding-block:var(--overflow-slider-scroll-indicator-padding);position:relative;width:100%}.overflow-slider__scroll-indicator[data-has-overflow=false]{display:none}.overflow-slider__scroll-indicator:focus-visible .overflow-slider__scroll-indicator-button{outline:2px solid;outline-offset:2px}.overflow-slider__scroll-indicator-bar{background:var(--overflow-slider-scroll-indicator-bar-color);border-radius:3px;height:2px;left:0;position:absolute;top:50%;transform:translateY(-50%);width:100%}.overflow-slider__scroll-indicator-button{background:var(--overflow-slider-scroll-indicator-button-color);border-radius:3px;cursor:grab;height:var(--overflow-slider-scroll-indicator-button-height);left:0;position:absolute;top:calc(50% - var(--overflow-slider-scroll-indicator-button-height)/2)}.overflow-slider__scroll-indicator-button:hover,.overflow-slider__scroll-indicator-button[data-is-grabbed=true]{--overflow-slider-scroll-indicator-button-height:6px}.overflow-slider__scroll-indicator-button:after{bottom:calc(var(--overflow-slider-scroll-indicator-padding)*-1);content:"";display:block;position:absolute;top:calc(var(--overflow-slider-scroll-indicator-padding)*-1);width:100%}.overflow-slider{-ms-overflow-style:none;display:grid;grid-auto-flow:column;grid-template-columns:max-content;max-width:-moz-max-content;max-width:max-content;overflow:auto;position:relative;scrollbar-width:none;width:100%}.overflow-slider::-webkit-scrollbar{display:none}.overflow-slider>*{outline-offset:-2px;scroll-snap-align:start}
|
|
@@ -1,23 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare function OverflowSlider(container: HTMLElement, options?: SliderOptionArgs, plugins?: SliderPlugin[]): {
|
|
1
|
+
type Slider<O = {}, C = {}, H extends string = string> = {
|
|
4
2
|
container: HTMLElement;
|
|
5
3
|
slides: HTMLElement[];
|
|
6
|
-
emit: (name:
|
|
7
|
-
moveToDirection: (direction:
|
|
8
|
-
moveToSlideInDirection: (direction:
|
|
9
|
-
snapToClosestSlide: (direction:
|
|
4
|
+
emit: (name: H | SliderHooks) => void;
|
|
5
|
+
moveToDirection: (direction: 'prev' | 'next') => void;
|
|
6
|
+
moveToSlideInDirection: (direction: 'prev' | 'next') => void;
|
|
7
|
+
snapToClosestSlide: (direction: 'prev' | 'next') => void;
|
|
10
8
|
moveToSlide: (index: number) => void;
|
|
11
9
|
canMoveToSlide: (index: number) => boolean;
|
|
12
10
|
getInclusiveScrollWidth: () => number;
|
|
13
11
|
getInclusiveClientWidth: () => number;
|
|
12
|
+
getGapSize: () => number;
|
|
13
|
+
getLeftOffset: () => number;
|
|
14
14
|
getScrollLeft: () => number;
|
|
15
15
|
setScrollLeft: (value: number) => void;
|
|
16
16
|
setActiveSlideIdx: () => void;
|
|
17
|
-
on: (name:
|
|
17
|
+
on: (name: H | SliderHooks, cb: SliderCallback) => void;
|
|
18
18
|
options: SliderOptions;
|
|
19
19
|
details: SliderDetails;
|
|
20
20
|
activeSlideIdx: number;
|
|
21
|
-
}
|
|
21
|
+
} & C;
|
|
22
|
+
type SliderCallback<O = {}, C = {}, H extends string = string> = (props: Slider<O, C, H>) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Recursively makes all properties of T optional.
|
|
25
|
+
* @see https://www.typescriptlang.org/docs/handbook/utility-types.html#mapped-types
|
|
26
|
+
*/
|
|
27
|
+
type DeepPartial<T> = {
|
|
28
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
29
|
+
};
|
|
30
|
+
type SliderOptions = {
|
|
31
|
+
scrollBehavior: string;
|
|
32
|
+
scrollStrategy: string;
|
|
33
|
+
slidesSelector: string;
|
|
34
|
+
emulateScrollSnap: boolean;
|
|
35
|
+
emulateScrollSnapMaxThreshold?: number;
|
|
36
|
+
cssVariableContainer: HTMLElement;
|
|
37
|
+
rtl: boolean;
|
|
38
|
+
targetWidth?: (slider: Slider) => number;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
type SliderOptionArgs = {
|
|
42
|
+
scrollBehavior?: 'smooth' | 'auto';
|
|
43
|
+
scrollStrategy?: 'fullSlide' | 'partialSlide';
|
|
44
|
+
slidesSelector?: string;
|
|
45
|
+
emulateScrollSnap?: boolean;
|
|
46
|
+
emulateScrollSnapMaxThreshold?: number;
|
|
47
|
+
cssVariableContainer?: HTMLElement;
|
|
48
|
+
rtl?: boolean;
|
|
49
|
+
targetWidth?: (slider: Slider) => number;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
type SliderDetails = {
|
|
53
|
+
hasOverflow: boolean;
|
|
54
|
+
slideCount: number;
|
|
55
|
+
containerWidth: number;
|
|
56
|
+
containerHeight: number;
|
|
57
|
+
scrollableAreaWidth: number;
|
|
58
|
+
amountOfPages: number;
|
|
59
|
+
currentPage: number;
|
|
60
|
+
};
|
|
61
|
+
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;
|
|
62
|
+
type HOOK_CREATED = 'created';
|
|
63
|
+
type HOOK_DETAILS_CHANGED = 'detailsChanged';
|
|
64
|
+
type HOOK_CONTENTS_CHANGED = 'contentsChanged';
|
|
65
|
+
type HOOK_CONTAINER_SIZE_CHANGED = 'containerSizeChanged';
|
|
66
|
+
type HOOK_ACTIVE_SLIDE_CHANGED = 'activeSlideChanged';
|
|
67
|
+
type HOOK_SCROLL_START = 'scrollStart';
|
|
68
|
+
type HOOK_SCROLL = 'scroll';
|
|
69
|
+
type HOOK_SCROLL_END = 'scrollEnd';
|
|
70
|
+
type HOOK_NATIVE_SCROLL_START = 'nativeScrollStart';
|
|
71
|
+
type HOOK_NATIVE_SCROLL = 'nativeScroll';
|
|
72
|
+
type HOOK_NATIVE_SCROLL_END = 'nativeScrollEnd';
|
|
73
|
+
type HOOK_PROGRAMMATIC_SCROLL_START = 'programmaticScrollStart';
|
|
74
|
+
type HOOK_PROGRAMMATIC_SCROLL = 'programmaticScroll';
|
|
75
|
+
type HOOK_PROGRAMMATIC_SCROLL_END = 'programmaticScrollEnd';
|
|
76
|
+
type SliderPlugin = (slider: Slider) => void;
|
|
22
77
|
|
|
23
|
-
export {
|
|
78
|
+
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 };
|
|
@@ -1,76 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { SliderOptionArgs, SliderPlugin, SliderCallback, SliderOptions, SliderDetails } from './index.js';
|
|
2
|
+
|
|
3
|
+
declare function OverflowSlider(container: HTMLElement, options?: SliderOptionArgs, plugins?: SliderPlugin[]): {
|
|
2
4
|
container: HTMLElement;
|
|
3
5
|
slides: HTMLElement[];
|
|
4
|
-
emit: (name:
|
|
5
|
-
moveToDirection: (direction:
|
|
6
|
-
moveToSlideInDirection: (direction:
|
|
7
|
-
snapToClosestSlide: (direction:
|
|
6
|
+
emit: (name: string) => void;
|
|
7
|
+
moveToDirection: (direction: "prev" | "next") => void;
|
|
8
|
+
moveToSlideInDirection: (direction: "prev" | "next") => void;
|
|
9
|
+
snapToClosestSlide: (direction: "prev" | "next") => void;
|
|
8
10
|
moveToSlide: (index: number) => void;
|
|
9
11
|
canMoveToSlide: (index: number) => boolean;
|
|
10
12
|
getInclusiveScrollWidth: () => number;
|
|
11
13
|
getInclusiveClientWidth: () => number;
|
|
14
|
+
getGapSize: () => number;
|
|
15
|
+
getLeftOffset: () => number;
|
|
12
16
|
getScrollLeft: () => number;
|
|
13
17
|
setScrollLeft: (value: number) => void;
|
|
14
18
|
setActiveSlideIdx: () => void;
|
|
15
|
-
on: (name:
|
|
19
|
+
on: (name: string, cb: SliderCallback) => void;
|
|
16
20
|
options: SliderOptions;
|
|
17
21
|
details: SliderDetails;
|
|
18
22
|
activeSlideIdx: number;
|
|
19
|
-
}
|
|
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
|
-
targetWidth?: (slider: Slider) => number;
|
|
48
|
-
[key: string]: unknown;
|
|
49
|
-
};
|
|
50
|
-
type SliderDetails = {
|
|
51
|
-
hasOverflow: boolean;
|
|
52
|
-
slideCount: number;
|
|
53
|
-
containerWidth: number;
|
|
54
|
-
containerHeight: number;
|
|
55
|
-
scrollableAreaWidth: number;
|
|
56
|
-
amountOfPages: number;
|
|
57
|
-
currentPage: number;
|
|
58
|
-
};
|
|
59
|
-
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;
|
|
60
|
-
type HOOK_CREATED = 'created';
|
|
61
|
-
type HOOK_DETAILS_CHANGED = 'detailsChanged';
|
|
62
|
-
type HOOK_CONTENTS_CHANGED = 'contentsChanged';
|
|
63
|
-
type HOOK_CONTAINER_SIZE_CHANGED = 'containerSizeChanged';
|
|
64
|
-
type HOOK_ACTIVE_SLIDE_CHANGED = 'activeSlideChanged';
|
|
65
|
-
type HOOK_SCROLL_START = 'scrollStart';
|
|
66
|
-
type HOOK_SCROLL = 'scroll';
|
|
67
|
-
type HOOK_SCROLL_END = 'scrollEnd';
|
|
68
|
-
type HOOK_NATIVE_SCROLL_START = 'nativeScrollStart';
|
|
69
|
-
type HOOK_NATIVE_SCROLL = 'nativeScroll';
|
|
70
|
-
type HOOK_NATIVE_SCROLL_END = 'nativeScrollEnd';
|
|
71
|
-
type HOOK_PROGRAMMATIC_SCROLL_START = 'programmaticScrollStart';
|
|
72
|
-
type HOOK_PROGRAMMATIC_SCROLL = 'programmaticScroll';
|
|
73
|
-
type HOOK_PROGRAMMATIC_SCROLL_END = 'programmaticScrollEnd';
|
|
74
|
-
type SliderPlugin = (slider: Slider) => void;
|
|
23
|
+
} | undefined;
|
|
75
24
|
|
|
76
|
-
export
|
|
25
|
+
export { OverflowSlider as default };
|
|
@@ -20,6 +20,7 @@ function DotsPlugin(args) {
|
|
|
20
20
|
const buildDots = () => {
|
|
21
21
|
dots.setAttribute('data-has-content', slider.details.hasOverflow.toString());
|
|
22
22
|
dots.innerHTML = '';
|
|
23
|
+
console.log('buildDots');
|
|
23
24
|
const dotsList = document.createElement('ul');
|
|
24
25
|
const count = options.type === 'view' ? slider.details.amountOfPages : slider.details.slideCount;
|
|
25
26
|
const currentIndex = options.type === 'view' ? slider.details.currentPage : slider.activeSlideIdx;
|
|
@@ -77,8 +78,15 @@ function DotsPlugin(args) {
|
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
80
|
const activateDot = (index) => {
|
|
81
|
+
console.log('activateDot', index, 'slider.details', slider.details);
|
|
80
82
|
if (options.type === 'view') {
|
|
81
|
-
const
|
|
83
|
+
const count = slider.details.amountOfPages;
|
|
84
|
+
let targetPosition = slider.details.containerWidth * (index - 1);
|
|
85
|
+
// For the last page, scroll to the maximum scroll position to ensure it activates
|
|
86
|
+
if (index === count) {
|
|
87
|
+
const maxScroll = slider.details.scrollableAreaWidth - slider.details.containerWidth;
|
|
88
|
+
targetPosition = maxScroll;
|
|
89
|
+
}
|
|
82
90
|
const scrollLeft = slider.options.rtl ? -targetPosition : targetPosition;
|
|
83
91
|
slider.container.scrollTo({
|
|
84
92
|
left: scrollLeft,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={dotDescription:"Page %d of %d"},e={dotsContainer:"overflow-slider__dots",dotsItem:"overflow-slider__dot-item"};function n(n){return i=>{var o,s,a;const
|
|
1
|
+
const t={dotDescription:"Page %d of %d"},e={dotsContainer:"overflow-slider__dots",dotsItem:"overflow-slider__dot-item"};function n(n){return i=>{var o,s,a;const l={type:null!==(o=null==n?void 0:n.type)&&void 0!==o?o:"slide",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!==(s=null==n?void 0:n.container)&&void 0!==s?s:null},r=document.createElement("div");r.classList.add(l.classNames.dotsContainer);let d=null;const c=()=>{r.setAttribute("data-has-content",i.details.hasOverflow.toString()),r.innerHTML="",console.log("buildDots");const t=document.createElement("ul"),e="view"===l.type?i.details.amountOfPages:i.details.slideCount,n="view"===l.type?i.details.currentPage:i.activeSlideIdx;if(!(e<=1)){for(let i=0;i<e;i++){const o=document.createElement("li"),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("class",l.classNames.dotsItem),s.setAttribute("aria-label",l.texts.dotDescription.replace("%d",(i+1).toString()).replace("%d",e.toString())),s.setAttribute("aria-pressed",(i===n).toString()),s.setAttribute("data-item",(i+1).toString()),o.appendChild(s),t.appendChild(o),s.addEventListener("click",()=>u(i+1)),s.addEventListener("focus",()=>d=i+1),s.addEventListener("keydown",t=>{var n;const i=r.querySelector('[aria-pressed="true"]');if(!i)return;const o=parseInt(null!==(n=i.getAttribute("data-item"))&&void 0!==n?n:"1");if("ArrowLeft"===t.key){const t=o-1;if(t>0){const e=r.querySelector(`[data-item="${t}"]`);e&&e.focus(),u(t)}}if("ArrowRight"===t.key){const t=o+1;if(t<=e){const e=r.querySelector(`[data-item="${t}"]`);e&&e.focus(),u(t)}}})}if(r.appendChild(t),d){const t=r.querySelector(`[data-item="${d}"]`);t&&t.focus()}}},u=t=>{if(console.log("activateDot",t,"slider.details",i.details),"view"===l.type){const e=i.details.amountOfPages;let n=i.details.containerWidth*(t-1);if(t===e){n=i.details.scrollableAreaWidth-i.details.containerWidth}const o=i.options.rtl?-n:n;i.container.scrollTo({left:o,behavior:i.options.scrollBehavior})}else i.moveToSlide(t-1)};c(),l.container?l.container.appendChild(r):null===(a=i.container.parentNode)||void 0===a||a.insertBefore(r,i.container.nextSibling),i.on("scrollEnd",c),i.on("contentsChanged",c),i.on("containerSizeChanged",c),i.on("detailsChanged",c)}}export{n as default};
|
package/docs/assets/demo.css
CHANGED
|
@@ -665,6 +665,12 @@ h3:before {
|
|
|
665
665
|
/* transform: scale(0); */
|
|
666
666
|
}
|
|
667
667
|
|
|
668
|
+
.example-container-1-dots-view-full {
|
|
669
|
+
width: 100vw;
|
|
670
|
+
margin-inline-start: calc(-50vw + 50%);
|
|
671
|
+
scroll-snap-type: x mandatory;
|
|
672
|
+
}
|
|
673
|
+
|
|
668
674
|
/* ===========================================================================
|
|
669
675
|
Example 4: Filters
|
|
670
676
|
=========================================================================== */
|
package/docs/assets/demo.js
CHANGED
|
@@ -139,6 +139,28 @@ import ClassNamesPlugin from '../dist/plugins/classnames/index.esm.js';
|
|
|
139
139
|
);
|
|
140
140
|
console.log( '1-dots-view', example1DotsView );
|
|
141
141
|
|
|
142
|
+
const example1DotsViewFull = new OverflowSlider(
|
|
143
|
+
document.querySelector( '.example-container-1-dots-view-full' ),
|
|
144
|
+
{
|
|
145
|
+
emulateScrollSnap: true,
|
|
146
|
+
rtl: document.documentElement.dir === 'rtl',
|
|
147
|
+
targetWidth: (slider) => {
|
|
148
|
+
return slider.container.parentElement.clientWidth;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[
|
|
152
|
+
FullWidthPlugin(),
|
|
153
|
+
DragScrollingPlugin(),
|
|
154
|
+
SkipLinksPlugin(),
|
|
155
|
+
DotsPlugin(
|
|
156
|
+
{
|
|
157
|
+
type: 'view'
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
]
|
|
161
|
+
);
|
|
162
|
+
console.log( '1-dots-view-full', example1DotsViewFull );
|
|
163
|
+
|
|
142
164
|
const example1Fade = new OverflowSlider(
|
|
143
165
|
document.querySelector( '.example-container-1-fade' ),
|
|
144
166
|
{
|
package/docs/dist/index.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ function details(slider) {
|
|
|
7
7
|
let containerHeight = 0;
|
|
8
8
|
let scrollableAreaWidth = 0;
|
|
9
9
|
let amountOfPages = 0;
|
|
10
|
-
let currentPage =
|
|
10
|
+
let currentPage = 0;
|
|
11
11
|
if (Math.floor(slider.getInclusiveScrollWidth()) > Math.floor(slider.getInclusiveClientWidth())) {
|
|
12
12
|
hasOverflow = true;
|
|
13
13
|
}
|
|
@@ -18,8 +18,11 @@ function details(slider) {
|
|
|
18
18
|
amountOfPages = Math.ceil(scrollableAreaWidth / containerWidth);
|
|
19
19
|
if (Math.floor(slider.getScrollLeft()) >= 0) {
|
|
20
20
|
currentPage = Math.floor(slider.getScrollLeft() / containerWidth);
|
|
21
|
-
//
|
|
22
|
-
|
|
21
|
+
// Consider as last page if we're within tolerance of the maximum scroll position
|
|
22
|
+
// When FullWidthPlugin is active, account for the margin offset
|
|
23
|
+
const maxScroll = scrollableAreaWidth - containerWidth - (2 * slider.getLeftOffset());
|
|
24
|
+
const currentScroll = slider.getScrollLeft();
|
|
25
|
+
if (currentScroll >= maxScroll - 1) {
|
|
23
26
|
currentPage = amountOfPages - 1;
|
|
24
27
|
}
|
|
25
28
|
}
|
|
@@ -604,6 +607,8 @@ function Slider(container, options, plugins) {
|
|
|
604
607
|
snapToClosestSlide,
|
|
605
608
|
getInclusiveScrollWidth,
|
|
606
609
|
getInclusiveClientWidth,
|
|
610
|
+
getLeftOffset,
|
|
611
|
+
getGapSize,
|
|
607
612
|
getScrollLeft,
|
|
608
613
|
setScrollLeft,
|
|
609
614
|
setActiveSlideIdx,
|