well-waterfall 1.0.6 → 1.0.7
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 +1 -1
- package/package.json +2 -2
- package/src/lib/attributes.ts +252 -249
- package/src/modules/accessibility.ts +16 -16
- package/src/modules/breakpoints.ts +21 -21
- package/src/modules/controller.ts +5 -12
- package/src/modules/effect.ts +22 -22
- package/src/modules/general.ts +94 -97
- package/src/modules/hashhistory.ts +8 -8
- package/src/modules/input.ts +14 -14
- package/src/modules/layout.ts +3 -3
- package/src/modules/navigation.ts +7 -7
- package/src/modules/pagination.ts +35 -38
- package/src/modules/playback.ts +16 -16
- package/src/modules/scrollbar.ts +14 -14
- package/src/modules/thumbs.ts +2 -2
- package/src/modules/zoom.ts +8 -8
- package/src/util.ts +55 -100
- package/src/waterfall.ts +54 -45
package/src/modules/playback.ts
CHANGED
|
@@ -17,29 +17,29 @@ import {
|
|
|
17
17
|
} from "lib/attributes";
|
|
18
18
|
import { parseAttr } from "../util";
|
|
19
19
|
|
|
20
|
-
export function autoplayConfig(
|
|
21
|
-
const autoplayMode = parseAttr(
|
|
20
|
+
export function autoplayConfig(el: HTMLElement) {
|
|
21
|
+
const autoplayMode = parseAttr(el, ATTR_AUTOPLAY, false);
|
|
22
22
|
if (!autoplayMode) return null;
|
|
23
23
|
// Add CSS for Smooth Autoplay
|
|
24
24
|
$(`[${ATTR_SMOOTH_AUTOPLAY}='true']`).find(".swiper-wrapper").css("transition-timing-function", "linear");
|
|
25
25
|
return {
|
|
26
|
-
delay: parseAttr(
|
|
27
|
-
disableOnInteraction: parseAttr(
|
|
28
|
-
reverseDirection: parseAttr(
|
|
29
|
-
pauseOnMouseEnter: parseAttr(
|
|
30
|
-
stopOnLastSlide: parseAttr(
|
|
26
|
+
delay: parseAttr(el, ATTR_DELAY, 3000),
|
|
27
|
+
disableOnInteraction: parseAttr(el, ATTR_DISABLE_ON_INTERACTION, false), // documentation says default is true, doesn't appear to be correct
|
|
28
|
+
reverseDirection: parseAttr(el, ATTR_REVERSE_DIRECTION, false),
|
|
29
|
+
pauseOnMouseEnter: parseAttr(el, ATTR_PAUSE_ON_MOUSE_ENTER, false),
|
|
30
|
+
stopOnLastSlide: parseAttr(el, ATTR_STOP_ON_LAST_SLIDE, false),
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function freeModeConfig(
|
|
34
|
+
export function freeModeConfig(el: HTMLElement) {
|
|
35
35
|
return {
|
|
36
|
-
enabled: parseAttr(
|
|
37
|
-
minimumVelocity: parseAttr(
|
|
38
|
-
momentum: parseAttr(
|
|
39
|
-
momentumBounce: parseAttr(
|
|
40
|
-
momentumBounceRatio: parseAttr(
|
|
41
|
-
momentumRatio: parseAttr(
|
|
42
|
-
momentumVelocityRatio: parseAttr(
|
|
43
|
-
sticky: parseAttr(
|
|
36
|
+
enabled: parseAttr(el, ATTR_FREE_MODE_ENABLED, false),
|
|
37
|
+
minimumVelocity: parseAttr(el, ATTR_FREE_MODE_MINIMUM_VELOCITY, 0.02),
|
|
38
|
+
momentum: parseAttr(el, ATTR_FREE_MODE_MOMENTUM, true),
|
|
39
|
+
momentumBounce: parseAttr(el, ATTR_FREE_MODE_MOMENTUM_BOUNCE, true),
|
|
40
|
+
momentumBounceRatio: parseAttr(el, ATTR_FREE_MODE_MOMENTUM_BOUNCE_RATIO, 1),
|
|
41
|
+
momentumRatio: parseAttr(el, ATTR_FREE_MODE_MOMENTUM_RATIO, 1),
|
|
42
|
+
momentumVelocityRatio: parseAttr(el, ATTR_FREE_MODE_MOMENTUM_VELOCITY_RATIO, 1),
|
|
43
|
+
sticky: parseAttr(el, ATTR_FREE_MODE_STICKY, false),
|
|
44
44
|
};
|
|
45
45
|
}
|
package/src/modules/scrollbar.ts
CHANGED
|
@@ -14,21 +14,21 @@ import {
|
|
|
14
14
|
} from "lib/attributes";
|
|
15
15
|
import { parseAttr } from "../util";
|
|
16
16
|
|
|
17
|
-
export function scrollbarConfig(
|
|
18
|
-
const
|
|
19
|
-
const
|
|
17
|
+
export function scrollbarConfig(element: HTMLElement) {
|
|
18
|
+
const scrollbar = element.querySelector<HTMLElement>(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SCROLLBAR}]`);
|
|
19
|
+
const scrollbarDrag = scrollbar?.querySelector<HTMLElement>(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SCROLLBAR_DRAG}]`);
|
|
20
20
|
|
|
21
21
|
return {
|
|
22
|
-
dragClass:
|
|
23
|
-
dragSize: parseAttr(
|
|
24
|
-
draggable: parseAttr(
|
|
25
|
-
el:
|
|
26
|
-
enabled: parseAttr(
|
|
27
|
-
hide: parseAttr(
|
|
28
|
-
horizontalClass: parseAttr(
|
|
29
|
-
lockClass: parseAttr(
|
|
30
|
-
scrollbarDisabledClass: parseAttr(
|
|
31
|
-
snapOnRelease: parseAttr(
|
|
32
|
-
verticalClass: parseAttr(
|
|
22
|
+
dragClass: scrollbarDrag?.getAttribute("class") || "",
|
|
23
|
+
dragSize: parseAttr(element, ATTR_SCROLLBAR_DRAG_SIZE, "auto"),
|
|
24
|
+
draggable: parseAttr(element, ATTR_SCROLLBAR_DRAGGABLE, false),
|
|
25
|
+
el: scrollbar || null,
|
|
26
|
+
enabled: parseAttr(element, ATTR_SCROLLBAR_ENABLED, null),
|
|
27
|
+
hide: parseAttr(element, ATTR_SCROLLBAR_HIDE, true),
|
|
28
|
+
horizontalClass: parseAttr(element, ATTR_SCROLLBAR_HORIZONTAL_CLASS, "swiper-scrollbar-horizontal"),
|
|
29
|
+
lockClass: parseAttr(element, ATTR_SCROLLBAR_LOCK_CLASS, "swiper-scrollbar-lock"),
|
|
30
|
+
scrollbarDisabledClass: parseAttr(element, ATTR_SCROLLBAR_SCROLLBAR_DISABLED_CLASS, "swiper-scrollbar-disabled"),
|
|
31
|
+
snapOnRelease: parseAttr(element, ATTR_SCROLLBAR_SNAP_ON_RELEASE, true), // doc says false but actually true
|
|
32
|
+
verticalClass: parseAttr(element, ATTR_SCROLLBAR_VERTICAL_CLASS, "swiper-scrollbar-vertical"),
|
|
33
33
|
};
|
|
34
34
|
}
|
package/src/modules/thumbs.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ATTR_THUMBS_SLIDE_THUMB_ACTIVE_CLASS,
|
|
10
10
|
} from "lib/attributes";
|
|
11
11
|
|
|
12
|
-
function getThumbsSwiper(el:
|
|
12
|
+
function getThumbsSwiper(el: HTMLElement, sliders: Waterfall[]): Waterfall | null {
|
|
13
13
|
const sliderName = parseAttr(el, ATTR_THUMBS_NAME, null);
|
|
14
14
|
if (sliderName === null) return null;
|
|
15
15
|
|
|
@@ -20,7 +20,7 @@ function getThumbsSwiper(el: JQuery<HTMLElement>, sliders: Waterfall[]): Waterfa
|
|
|
20
20
|
return null; // Return null if no match is found
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function thumbsConfig(el:
|
|
23
|
+
export function thumbsConfig(el: HTMLElement, swipers: Waterfall[]) {
|
|
24
24
|
const waterfall = getThumbsSwiper(el, swipers);
|
|
25
25
|
if (!waterfall) return;
|
|
26
26
|
|
package/src/modules/zoom.ts
CHANGED
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
} from "lib/attributes";
|
|
10
10
|
import { parseAttr } from "../util";
|
|
11
11
|
|
|
12
|
-
export function zoomConfig(
|
|
12
|
+
export function zoomConfig(el: HTMLElement) {
|
|
13
13
|
return {
|
|
14
|
-
containerClass: parseAttr(
|
|
15
|
-
limitToOriginalSize: parseAttr(
|
|
16
|
-
maxRatio: parseAttr(
|
|
17
|
-
minRatio: parseAttr(
|
|
18
|
-
panOnMouseMove: parseAttr(
|
|
19
|
-
toggle: parseAttr(
|
|
20
|
-
zoomedSlideClass: parseAttr(
|
|
14
|
+
containerClass: parseAttr(el, ATTR_ZOOM_CONTAINER_CLASS, "swiper-zoom-container"),
|
|
15
|
+
limitToOriginalSize: parseAttr(el, ATTR_ZOOM_LIMIT_TO_ORIGINAL_SIZE, false),
|
|
16
|
+
maxRatio: parseAttr(el, ATTR_ZOOM_MAX_RATIO, 3),
|
|
17
|
+
minRatio: parseAttr(el, ATTR_ZOOM_MIN_RATIO, 1),
|
|
18
|
+
panOnMouseMove: parseAttr(el, ATTR_ZOOM_PAN_ON_MOUSE_MOVE, false),
|
|
19
|
+
toggle: parseAttr(el, ATTR_ZOOM_TOGGLE, true),
|
|
20
|
+
zoomedSlideClass: parseAttr(el, ATTR_ZOOMED_SLIDE_CLASS, "swiper-slide-zoomed"),
|
|
21
21
|
};
|
|
22
22
|
}
|
package/src/util.ts
CHANGED
|
@@ -1,147 +1,102 @@
|
|
|
1
|
-
import Swiper from
|
|
2
|
-
import { Waterfall } from
|
|
1
|
+
import Swiper from "swiper";
|
|
2
|
+
import { Waterfall } from "types/waterfall";
|
|
3
3
|
|
|
4
4
|
export function printDebug(debug: boolean, str: string, el: any) {
|
|
5
5
|
if (!debug) return;
|
|
6
|
-
console.log(str
|
|
6
|
+
console.log(`${str}:`, el);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
) {
|
|
13
|
-
if (!targetElement.length) return ''; // If no element, return an empty string
|
|
9
|
+
// ✅ Get unique classes without jQuery
|
|
10
|
+
export function getUniqueClasses(targetElement: HTMLElement, comparisonElement: HTMLElement): string {
|
|
11
|
+
if (!targetElement) return "";
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const targetClasses = Array.from(targetElement.classList);
|
|
14
|
+
const comparisonClasses = Array.from(comparisonElement.classList);
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
21
|
-
// Get the class attribute, split into an array, filter out the classToRemove, and join back into a string
|
|
22
|
-
return filtered.join(' '); // Join the remaining classes into a string
|
|
16
|
+
const filtered = targetClasses.filter((className) => className && !comparisonClasses.includes(className));
|
|
17
|
+
|
|
18
|
+
return filtered.join(" ");
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
attrName
|
|
28
|
-
defaultValue
|
|
29
|
-
) {
|
|
30
|
-
const attrValue = $(el).attr(attrName)?.trim();
|
|
31
|
-
if (!attrValue) return undefined;
|
|
32
|
-
// Nullify the attribute if it matches the default value from SwiperJS
|
|
33
|
-
if (attrValue === defaultValue) return undefined;
|
|
21
|
+
// ✅ Parse attribute as string (ignoring default value)
|
|
22
|
+
export function parseString(el: HTMLElement, attrName: string, defaultValue: string): string | undefined {
|
|
23
|
+
const attrValue = el.getAttribute(attrName)?.trim();
|
|
24
|
+
if (!attrValue || attrValue === defaultValue) return undefined;
|
|
34
25
|
return attrValue;
|
|
35
26
|
}
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
attrName
|
|
40
|
-
defaultValue: number,
|
|
41
|
-
): number | undefined {
|
|
42
|
-
const attrValue = $(el).attr(attrName)?.trim();
|
|
28
|
+
// ✅ Parse attribute as number
|
|
29
|
+
export function parseNumber(el: HTMLElement, attrName: string, defaultValue: number): number | undefined {
|
|
30
|
+
const attrValue = el.getAttribute(attrName)?.trim();
|
|
43
31
|
if (!attrValue) return undefined;
|
|
44
32
|
|
|
45
33
|
const parsedValue = Number(attrValue);
|
|
46
|
-
if (isNaN(parsedValue)) return undefined;
|
|
34
|
+
if (isNaN(parsedValue) || parsedValue === defaultValue) return undefined;
|
|
47
35
|
|
|
48
|
-
return parsedValue
|
|
36
|
+
return parsedValue;
|
|
49
37
|
}
|
|
50
38
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
attrName
|
|
54
|
-
defaultValue: boolean,
|
|
55
|
-
): boolean | undefined {
|
|
56
|
-
const attrValue = $(el).attr(attrName)?.trim()?.toLowerCase();
|
|
39
|
+
// ✅ Parse attribute as boolean
|
|
40
|
+
export function parseBoolean(el: HTMLElement, attrName: string, defaultValue: boolean): boolean | undefined {
|
|
41
|
+
const attrValue = el.getAttribute(attrName)?.trim()?.toLowerCase();
|
|
57
42
|
if (!attrValue) return undefined;
|
|
58
43
|
|
|
59
|
-
if (attrValue ===
|
|
60
|
-
if (attrValue ===
|
|
44
|
+
if (attrValue === "true") return defaultValue === true ? undefined : true;
|
|
45
|
+
if (attrValue === "false") return defaultValue === false ? undefined : false;
|
|
61
46
|
|
|
62
|
-
return
|
|
47
|
+
return undefined;
|
|
63
48
|
}
|
|
64
49
|
|
|
50
|
+
// ✅ Generic attribute parser
|
|
65
51
|
export function parseAttr(
|
|
66
|
-
el:
|
|
52
|
+
el: HTMLElement,
|
|
67
53
|
attrName: string,
|
|
68
54
|
defaultValue: string | number | boolean | null,
|
|
69
55
|
): string | number | boolean | null {
|
|
70
|
-
const attrValue =
|
|
56
|
+
const attrValue = el.getAttribute(attrName);
|
|
71
57
|
if (!attrValue) return null;
|
|
72
|
-
|
|
58
|
+
|
|
73
59
|
const trimmedInput = attrValue.trim();
|
|
74
60
|
|
|
75
|
-
//
|
|
61
|
+
// Number check
|
|
76
62
|
if (!isNaN(Number(trimmedInput))) {
|
|
77
63
|
const parsedNumber = parseFloat(trimmedInput);
|
|
78
|
-
|
|
79
|
-
return null; // Return null if it matches the default value
|
|
80
|
-
}
|
|
81
|
-
return parsedNumber; // Return the parsed number
|
|
64
|
+
return parsedNumber === defaultValue ? null : parsedNumber;
|
|
82
65
|
}
|
|
83
66
|
|
|
84
|
-
//
|
|
85
|
-
if (trimmedInput.toLowerCase() ===
|
|
86
|
-
|
|
87
|
-
return null; // Return null if it matches the default value
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
} else if (trimmedInput.toLowerCase() === 'false') {
|
|
91
|
-
if (defaultValue === false) {
|
|
92
|
-
return null; // Return null if it matches the default value
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
67
|
+
// Boolean check
|
|
68
|
+
if (trimmedInput.toLowerCase() === "true") return defaultValue === true ? null : true;
|
|
69
|
+
if (trimmedInput.toLowerCase() === "false") return defaultValue === false ? null : false;
|
|
96
70
|
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
71
|
+
// String match check
|
|
72
|
+
return trimmedInput === String(defaultValue) ? null : trimmedInput;
|
|
73
|
+
}
|
|
101
74
|
|
|
102
|
-
|
|
103
|
-
return
|
|
75
|
+
function isHTMLElement(value: unknown): value is HTMLElement {
|
|
76
|
+
return typeof HTMLElement !== "undefined" && value instanceof HTMLElement;
|
|
104
77
|
}
|
|
105
78
|
|
|
106
|
-
export function removeNullOrUndefinedKeys(obj:
|
|
107
|
-
if (typeof obj !==
|
|
108
|
-
return obj; // Return non-objects or null as is
|
|
109
|
-
}
|
|
79
|
+
export function removeNullOrUndefinedKeys<T extends Record<string, any>>(obj: T): T {
|
|
80
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
110
81
|
|
|
111
|
-
// Iterate over the keys in the object
|
|
112
82
|
for (const key in obj) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// Recursively handle nested objects
|
|
120
|
-
removeNullOrUndefinedKeys(obj[key]);
|
|
121
|
-
// Remove empty objects after recursion
|
|
122
|
-
if (Object.keys(obj[key]).length === 0) {
|
|
123
|
-
delete obj[key];
|
|
124
|
-
}
|
|
83
|
+
const value = obj[key];
|
|
84
|
+
if (value === null || value === undefined) {
|
|
85
|
+
delete obj[key];
|
|
86
|
+
} else if (typeof value === "object" && value !== null && !isHTMLElement(value)) {
|
|
87
|
+
removeNullOrUndefinedKeys(value as Record<string, any>);
|
|
88
|
+
if (Object.keys(value).length === 0) delete obj[key];
|
|
125
89
|
}
|
|
126
90
|
}
|
|
127
91
|
|
|
128
92
|
return obj;
|
|
129
93
|
}
|
|
130
94
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return false;
|
|
139
|
-
});
|
|
140
|
-
if (waterfall) swipers.push(waterfall?.swiper);
|
|
141
|
-
});
|
|
142
|
-
return swipers;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function splitByUnderscores(str: string) {
|
|
146
|
-
return str.split('_');
|
|
95
|
+
// ✅ Get swipers by name
|
|
96
|
+
export function getSwipersByName(waterfalls: Waterfall[], selector: string): Swiper[] {
|
|
97
|
+
return selector.split("_").reduce<Swiper[]>((swipers, name) => {
|
|
98
|
+
const waterfall = waterfalls.find((w) => w.name === name);
|
|
99
|
+
if (waterfall) swipers.push(waterfall.swiper);
|
|
100
|
+
return swipers;
|
|
101
|
+
}, []);
|
|
147
102
|
}
|
package/src/waterfall.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { controllerConfig } from "./modules/controller";
|
|
|
18
18
|
import { SwiperOptions } from "swiper/types";
|
|
19
19
|
import { accessibilityConfig } from "./modules/accessibility";
|
|
20
20
|
import { addSlides } from "./modules/manipulation";
|
|
21
|
+
import { zoomConfig } from "./modules/zoom";
|
|
21
22
|
|
|
22
23
|
import {
|
|
23
24
|
ATTR_WATERFALL_PRELOAD,
|
|
@@ -34,93 +35,105 @@ console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
|
|
|
34
35
|
const waterfalls: Waterfall[] = [];
|
|
35
36
|
window.waterfalls = waterfalls;
|
|
36
37
|
|
|
38
|
+
export * from "./lib/attributes";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Utility: Runs initConfig for a NodeList
|
|
42
|
+
*/
|
|
43
|
+
function initAll(selector: string) {
|
|
44
|
+
document.querySelectorAll(selector).forEach((el, index) => {
|
|
45
|
+
initConfig(el as HTMLElement, index);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
37
49
|
// Initialize Thumb Sliders first
|
|
38
|
-
|
|
50
|
+
initAll(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_PRELOAD}="true"]`);
|
|
39
51
|
|
|
40
52
|
// Initialize all other sliders
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
document.querySelectorAll(`[${ATTR_WATERFALL}]`).forEach((el, index) => {
|
|
54
|
+
if (el.getAttribute(ATTR_WATERFALL_PRELOAD) === "true" || el.getAttribute(ATTR_WATERFALL_POSTLOAD) === "true") return;
|
|
55
|
+
|
|
56
|
+
initConfig(el as HTMLElement, index);
|
|
57
|
+
});
|
|
45
58
|
|
|
46
|
-
|
|
59
|
+
// Initialize Postload sliders
|
|
60
|
+
initAll(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_POSTLOAD}="true"]`);
|
|
47
61
|
|
|
48
62
|
function initConfig(el: HTMLElement, index: number) {
|
|
49
63
|
{
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const name = parseString($this, ATTR_WATERFALL, `Swiper ${index}`);
|
|
64
|
+
const name = parseString(el, ATTR_WATERFALL, `Swiper ${index}`);
|
|
53
65
|
if (!name) return;
|
|
54
66
|
|
|
55
|
-
const debug = Boolean(parseAttr(
|
|
56
|
-
const debugAdvanced = Boolean(parseAttr(
|
|
67
|
+
const debug = Boolean(parseAttr(el, ATTR_DEBUG_MODE, false) || false);
|
|
68
|
+
const debugAdvanced = Boolean(parseAttr(el, ATTR_ADVANCED_DEBUG_MODE, false) || false);
|
|
57
69
|
console.log(`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`);
|
|
58
70
|
|
|
59
71
|
// GENERAL CONFIG
|
|
60
|
-
const swiperConfig: any = generalConfig(
|
|
72
|
+
const swiperConfig: any = generalConfig(el);
|
|
61
73
|
|
|
62
74
|
// BREAKPOINTS
|
|
63
|
-
swiperConfig.breakpoints = breakpointsConfig(
|
|
75
|
+
swiperConfig.breakpoints = breakpointsConfig(el);
|
|
64
76
|
|
|
65
77
|
// PLAYBACK
|
|
66
|
-
const playbackMode = parseAttr(
|
|
78
|
+
const playbackMode = parseAttr(el, ATTR_PLAYBACK_MODE, "none");
|
|
67
79
|
if (playbackMode === "loop") swiperConfig.loop = true;
|
|
68
80
|
if (playbackMode === "rewind") swiperConfig.rewind = true;
|
|
69
81
|
if (playbackMode === "none") {
|
|
70
82
|
swiperConfig.loop = false;
|
|
71
83
|
swiperConfig.rewind = false;
|
|
72
84
|
}
|
|
73
|
-
swiperConfig.autoplay = autoplayConfig(
|
|
85
|
+
swiperConfig.autoplay = autoplayConfig(el);
|
|
74
86
|
|
|
75
87
|
// NAVIGATION
|
|
76
|
-
swiperConfig.navigation = navigationConfig(
|
|
88
|
+
swiperConfig.navigation = navigationConfig(el, name);
|
|
77
89
|
|
|
78
90
|
// PAGINATION
|
|
79
|
-
|
|
80
|
-
if (
|
|
91
|
+
const paginationEl = el.querySelector(`[waterfall-el='pagination-bullet']`);
|
|
92
|
+
if (paginationEl) swiperConfig.pagination = paginationConfig(el);
|
|
81
93
|
|
|
82
94
|
// SCROLLBAR
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
95
|
+
const scrollbarEl = el.querySelector(`[waterfall-el='scrollbar']`);
|
|
96
|
+
if (scrollbarEl) swiperConfig.scrollbar = scrollbarConfig(el);
|
|
85
97
|
|
|
86
98
|
// EFFECT
|
|
87
|
-
swiperConfig.fadeEffect = fadeConfig(
|
|
88
|
-
swiperConfig.coverflowEffect = coverflowEffect(
|
|
89
|
-
swiperConfig.flipEffect = flipEffect(
|
|
90
|
-
swiperConfig.cardsEffect = cardsEffect(
|
|
91
|
-
swiperConfig.cubeEffect = cubeEffect(
|
|
99
|
+
swiperConfig.fadeEffect = fadeConfig(el);
|
|
100
|
+
swiperConfig.coverflowEffect = coverflowEffect(el);
|
|
101
|
+
swiperConfig.flipEffect = flipEffect(el);
|
|
102
|
+
swiperConfig.cardsEffect = cardsEffect(el);
|
|
103
|
+
swiperConfig.cubeEffect = cubeEffect(el);
|
|
92
104
|
|
|
93
105
|
// FREE MODE
|
|
94
|
-
swiperConfig.freeMode = freeModeConfig(
|
|
106
|
+
swiperConfig.freeMode = freeModeConfig(el);
|
|
95
107
|
|
|
96
108
|
// GRID
|
|
97
|
-
swiperConfig.grid = gridConfig(
|
|
109
|
+
swiperConfig.grid = gridConfig(el);
|
|
98
110
|
|
|
99
111
|
// THUMBS
|
|
100
|
-
const isThumbs = parseAttr(
|
|
101
|
-
if (!isThumbs) swiperConfig.thumbs = thumbsConfig(
|
|
112
|
+
const isThumbs = parseAttr(el, ATTR_THUMBS, null) === true;
|
|
113
|
+
if (!isThumbs) swiperConfig.thumbs = thumbsConfig(el, waterfalls);
|
|
102
114
|
|
|
103
115
|
// ZOOM - NOT IMPLEMENTED
|
|
116
|
+
swiperConfig.zoom = zoomConfig(el);
|
|
104
117
|
|
|
105
118
|
// KEYBOARD
|
|
106
|
-
swiperConfig.keyboard = keyboardConfig(
|
|
119
|
+
swiperConfig.keyboard = keyboardConfig(el);
|
|
107
120
|
|
|
108
121
|
// MOUSE
|
|
109
|
-
swiperConfig.mousewheel = mouseConfig(
|
|
122
|
+
swiperConfig.mousewheel = mouseConfig(el);
|
|
110
123
|
|
|
111
124
|
// VIRTUAL SLIDES - NOT IMPLEMENTED
|
|
112
125
|
|
|
113
126
|
// HASH NAVIGATION
|
|
114
|
-
swiperConfig.hashNavigation = hashNavigationConfig(
|
|
127
|
+
swiperConfig.hashNavigation = hashNavigationConfig(el);
|
|
115
128
|
|
|
116
129
|
// HISTORY NAVIGATION
|
|
117
|
-
swiperConfig.history = historyNavigationConfig(
|
|
130
|
+
swiperConfig.history = historyNavigationConfig(el);
|
|
118
131
|
|
|
119
132
|
// CONTROLLER
|
|
120
|
-
swiperConfig.controller = controllerConfig(
|
|
133
|
+
swiperConfig.controller = controllerConfig(el, waterfalls);
|
|
121
134
|
|
|
122
135
|
// A11Y
|
|
123
|
-
swiperConfig.a11y = accessibilityConfig(
|
|
136
|
+
swiperConfig.a11y = accessibilityConfig(el);
|
|
124
137
|
|
|
125
138
|
// Clean up the config and debug
|
|
126
139
|
if (debugAdvanced) printDebug(debug, "CONFIG (UNCLEANED)", swiperConfig);
|
|
@@ -128,19 +141,15 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
128
141
|
printDebug(debug, "CONFIG", config);
|
|
129
142
|
|
|
130
143
|
// Initialize swiper
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
// Check if there are slides, return if none are found
|
|
135
|
-
if ($slides.length === 0) {
|
|
144
|
+
const swiperEl = el.querySelector(".swiper");
|
|
145
|
+
const slides = swiperEl?.querySelectorAll(".swiper-slide") || [];
|
|
146
|
+
if (slides.length === 0) {
|
|
136
147
|
console.warn(`Skipping "${name}": no .swiper-slide elements found.`);
|
|
137
148
|
return;
|
|
138
149
|
}
|
|
139
|
-
|
|
140
|
-
const swiper = new Swiper(
|
|
141
|
-
|
|
142
|
-
// Add to sliders array
|
|
143
|
-
waterfalls.push({ name, swiper: swiper });
|
|
150
|
+
// INIT SWIPER
|
|
151
|
+
const swiper = new Swiper(swiperEl as HTMLElement, config);
|
|
152
|
+
waterfalls.push({ name, swiper });
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
|