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.
@@ -17,29 +17,29 @@ import {
17
17
  } from "lib/attributes";
18
18
  import { parseAttr } from "../util";
19
19
 
20
- export function autoplayConfig($this: JQuery<HTMLElement>) {
21
- const autoplayMode = parseAttr($this, ATTR_AUTOPLAY, false);
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($this, ATTR_DELAY, 3000),
27
- disableOnInteraction: parseAttr($this, ATTR_DISABLE_ON_INTERACTION, false), // documentation says default is true, doesn't appear to be correct
28
- reverseDirection: parseAttr($this, ATTR_REVERSE_DIRECTION, false),
29
- pauseOnMouseEnter: parseAttr($this, ATTR_PAUSE_ON_MOUSE_ENTER, false),
30
- stopOnLastSlide: parseAttr($this, ATTR_STOP_ON_LAST_SLIDE, false),
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($this: JQuery<HTMLElement>) {
34
+ export function freeModeConfig(el: HTMLElement) {
35
35
  return {
36
- enabled: parseAttr($this, ATTR_FREE_MODE_ENABLED, false),
37
- minimumVelocity: parseAttr($this, ATTR_FREE_MODE_MINIMUM_VELOCITY, 0.02),
38
- momentum: parseAttr($this, ATTR_FREE_MODE_MOMENTUM, true),
39
- momentumBounce: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_BOUNCE, true),
40
- momentumBounceRatio: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_BOUNCE_RATIO, 1),
41
- momentumRatio: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_RATIO, 1),
42
- momentumVelocityRatio: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_VELOCITY_RATIO, 1),
43
- sticky: parseAttr($this, ATTR_FREE_MODE_STICKY, false),
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
  }
@@ -14,21 +14,21 @@ import {
14
14
  } from "lib/attributes";
15
15
  import { parseAttr } from "../util";
16
16
 
17
- export function scrollbarConfig($this: JQuery<HTMLElement>) {
18
- const $scrollbar = $this.find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SCROLLBAR}]`);
19
- const $scrollbarDrag = $($scrollbar).find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SCROLLBAR_DRAG}]`);
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: $scrollbarDrag.attr("class"),
23
- dragSize: parseAttr($this, ATTR_SCROLLBAR_DRAG_SIZE, "auto"),
24
- draggable: parseAttr($this, ATTR_SCROLLBAR_DRAGGABLE, false),
25
- el: $scrollbar[0],
26
- enabled: parseAttr($this, ATTR_SCROLLBAR_ENABLED, null),
27
- hide: parseAttr($this, ATTR_SCROLLBAR_HIDE, true),
28
- horizontalClass: parseAttr($this, ATTR_SCROLLBAR_HORIZONTAL_CLASS, "swiper-scrollbar-horizontal"),
29
- lockClass: parseAttr($this, ATTR_SCROLLBAR_LOCK_CLASS, "swiper-scrollbar-lock"),
30
- scrollbarDisabledClass: parseAttr($this, ATTR_SCROLLBAR_SCROLLBAR_DISABLED_CLASS, "swiper-scrollbar-disabled"),
31
- snapOnRelease: parseAttr($this, ATTR_SCROLLBAR_SNAP_ON_RELEASE, true), //NOTE documentation says default is false, but is lying lmao
32
- verticalClass: parseAttr($this, ATTR_SCROLLBAR_VERTICAL_CLASS, "swiper-scrollbar-vertical"),
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
  }
@@ -9,7 +9,7 @@ import {
9
9
  ATTR_THUMBS_SLIDE_THUMB_ACTIVE_CLASS,
10
10
  } from "lib/attributes";
11
11
 
12
- function getThumbsSwiper(el: JQuery<HTMLElement>, sliders: Waterfall[]): Waterfall | null {
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: JQuery<HTMLElement>, swipers: Waterfall[]) {
23
+ export function thumbsConfig(el: HTMLElement, swipers: Waterfall[]) {
24
24
  const waterfall = getThumbsSwiper(el, swipers);
25
25
  if (!waterfall) return;
26
26
 
@@ -9,14 +9,14 @@ import {
9
9
  } from "lib/attributes";
10
10
  import { parseAttr } from "../util";
11
11
 
12
- export function zoomConfig($el: JQuery<HTMLElement>) {
12
+ export function zoomConfig(el: HTMLElement) {
13
13
  return {
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"),
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 'swiper';
2
- import { Waterfall } from 'types/waterfall';
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, ': ', el);
6
+ console.log(`${str}:`, el);
7
7
  }
8
8
 
9
- export function getUniqueClasses(
10
- targetElement: JQuery<HTMLElement>,
11
- comparisonElement: JQuery<HTMLElement>,
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
- let targetClasses = (targetElement.attr('class') || '').split(/\s+/);
16
- let comparisonClasses = (comparisonElement.attr('class') || '').split(/\s+/);
13
+ const targetClasses = Array.from(targetElement.classList);
14
+ const comparisonClasses = Array.from(comparisonElement.classList);
17
15
 
18
- let filtered = targetClasses.filter(
19
- (className) => className && !comparisonClasses.includes(className),
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
- export function parseString(
26
- el: JQuery<HTMLElement>,
27
- attrName: string,
28
- defaultValue: string,
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
- export function parseNumber(
38
- el: JQuery<HTMLElement>,
39
- attrName: string,
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 === defaultValue ? undefined : parsedValue;
36
+ return parsedValue;
49
37
  }
50
38
 
51
- export function parseBoolean(
52
- el: JQuery<HTMLElement>,
53
- attrName: string,
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 === 'true') return true;
60
- if (attrValue === 'false') return false;
44
+ if (attrValue === "true") return defaultValue === true ? undefined : true;
45
+ if (attrValue === "false") return defaultValue === false ? undefined : false;
61
46
 
62
- return attrValue === defaultValue.toString() ? undefined : undefined;
47
+ return undefined;
63
48
  }
64
49
 
50
+ // ✅ Generic attribute parser
65
51
  export function parseAttr(
66
- el: JQuery<HTMLElement>,
52
+ el: HTMLElement,
67
53
  attrName: string,
68
54
  defaultValue: string | number | boolean | null,
69
55
  ): string | number | boolean | null {
70
- const attrValue = $(el).attr(attrName);
56
+ const attrValue = el.getAttribute(attrName);
71
57
  if (!attrValue) return null;
72
- // Trim the input to avoid issues with leading/trailing spaces
58
+
73
59
  const trimmedInput = attrValue.trim();
74
60
 
75
- // Check if input is a number
61
+ // Number check
76
62
  if (!isNaN(Number(trimmedInput))) {
77
63
  const parsedNumber = parseFloat(trimmedInput);
78
- if (parsedNumber === defaultValue) {
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
- // Check if input is a boolean
85
- if (trimmedInput.toLowerCase() === 'true') {
86
- if (defaultValue === true) {
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
- // Return null if the input matches the default value (as a string)
98
- if (trimmedInput === String(defaultValue)) {
99
- return null;
100
- }
71
+ // String match check
72
+ return trimmedInput === String(defaultValue) ? null : trimmedInput;
73
+ }
101
74
 
102
- // Return the input as a string
103
- return trimmedInput;
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: any) {
107
- if (typeof obj !== 'object' || obj === null) {
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
- if (obj[key] === null || obj[key] === undefined) {
114
- delete obj[key]; // ✅ Remove `null` or `undefined` keys
115
- } else if (
116
- typeof obj[key] === 'object' &&
117
- !(obj[key] instanceof HTMLElement)
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
- export function getSwipersByName(waterfalls: Waterfall[], selector: string) {
132
- const strArr = splitByUnderscores(selector);
133
- const swipers: Swiper[] = [];
134
-
135
- strArr.forEach((str) => {
136
- const waterfall = waterfalls.find((w) => {
137
- if (w.name === str) return true;
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
- $(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_PRELOAD}="true"]`).each((index, el) => initConfig(el, index));
50
+ initAll(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_PRELOAD}="true"]`);
39
51
 
40
52
  // Initialize all other sliders
41
- $(`[${ATTR_WATERFALL}]`)
42
- .not(`[${ATTR_WATERFALL_PRELOAD}="true"]`)
43
- .not(`[${ATTR_WATERFALL_POSTLOAD}="true"]`)
44
- .each((index, el) => initConfig(el, index));
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
- $(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_POSTLOAD}="true"]`).each((index, el) => initConfig(el, index));
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 $this = $(el);
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($this, ATTR_DEBUG_MODE, false) || false);
56
- const debugAdvanced = Boolean(parseAttr($this, ATTR_ADVANCED_DEBUG_MODE, false) || false);
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($this);
72
+ const swiperConfig: any = generalConfig(el);
61
73
 
62
74
  // BREAKPOINTS
63
- swiperConfig.breakpoints = breakpointsConfig($this);
75
+ swiperConfig.breakpoints = breakpointsConfig(el);
64
76
 
65
77
  // PLAYBACK
66
- const playbackMode = parseAttr($this, ATTR_PLAYBACK_MODE, "none");
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($this);
85
+ swiperConfig.autoplay = autoplayConfig(el);
74
86
 
75
87
  // NAVIGATION
76
- swiperConfig.navigation = navigationConfig($this, name);
88
+ swiperConfig.navigation = navigationConfig(el, name);
77
89
 
78
90
  // PAGINATION
79
- let pagination = $this.find(`[${"waterfall-el='pagination-bullet'"}]`).length;
80
- if (pagination) swiperConfig.pagination = paginationConfig($this);
91
+ const paginationEl = el.querySelector(`[waterfall-el='pagination-bullet']`);
92
+ if (paginationEl) swiperConfig.pagination = paginationConfig(el);
81
93
 
82
94
  // SCROLLBAR
83
- const $scrollbar = $this.find(`[${"waterfall-el='scrollbar'"}]`);
84
- if ($scrollbar) swiperConfig.scrollbar = scrollbarConfig($this);
95
+ const scrollbarEl = el.querySelector(`[waterfall-el='scrollbar']`);
96
+ if (scrollbarEl) swiperConfig.scrollbar = scrollbarConfig(el);
85
97
 
86
98
  // EFFECT
87
- swiperConfig.fadeEffect = fadeConfig($this);
88
- swiperConfig.coverflowEffect = coverflowEffect($this);
89
- swiperConfig.flipEffect = flipEffect($this);
90
- swiperConfig.cardsEffect = cardsEffect($this);
91
- swiperConfig.cubeEffect = cubeEffect($this);
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($this);
106
+ swiperConfig.freeMode = freeModeConfig(el);
95
107
 
96
108
  // GRID
97
- swiperConfig.grid = gridConfig($this);
109
+ swiperConfig.grid = gridConfig(el);
98
110
 
99
111
  // THUMBS
100
- const isThumbs = parseAttr($this, ATTR_THUMBS, null) === true;
101
- if (!isThumbs) swiperConfig.thumbs = thumbsConfig($this, waterfalls);
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($this);
119
+ swiperConfig.keyboard = keyboardConfig(el);
107
120
 
108
121
  // MOUSE
109
- swiperConfig.mousewheel = mouseConfig($this);
122
+ swiperConfig.mousewheel = mouseConfig(el);
110
123
 
111
124
  // VIRTUAL SLIDES - NOT IMPLEMENTED
112
125
 
113
126
  // HASH NAVIGATION
114
- swiperConfig.hashNavigation = hashNavigationConfig($this);
127
+ swiperConfig.hashNavigation = hashNavigationConfig(el);
115
128
 
116
129
  // HISTORY NAVIGATION
117
- swiperConfig.history = historyNavigationConfig($this);
130
+ swiperConfig.history = historyNavigationConfig(el);
118
131
 
119
132
  // CONTROLLER
120
- swiperConfig.controller = controllerConfig($this, waterfalls);
133
+ swiperConfig.controller = controllerConfig(el, waterfalls);
121
134
 
122
135
  // A11Y
123
- swiperConfig.a11y = accessibilityConfig($this);
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 $swiperEl = $this.find(".swiper");
132
- const $slides = $swiperEl.find(".swiper-slide");
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($swiperEl[0], config);
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