well-waterfall 1.2.6 → 1.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "well-waterfall",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "Create Swipers in Webflow with attributes",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.es.js",
package/src/index.ts CHANGED
@@ -49,15 +49,26 @@ function initAll(selector: string, startIndex: number): number {
49
49
 
50
50
  let indexCounter = 0;
51
51
 
52
- // Initialize all other sliders
53
- document.querySelectorAll(`[${ATTR_WATERFALL}]`).forEach((el) => {
54
- if (el.hasAttribute(ATTR_THUMBS) || el.hasAttribute(ATTR_CONTROLLER)) return;
55
- initConfig(el as HTMLElement, indexCounter++);
56
- });
52
+ document.addEventListener("DOMContentLoaded", () => {
53
+ // Initialize all other sliders
54
+ document.querySelectorAll(`[${ATTR_WATERFALL}]`).forEach((el) => {
55
+ if (el.hasAttribute(ATTR_THUMBS) || el.hasAttribute(ATTR_CONTROLLER)) return;
56
+ initConfig(el as HTMLElement, indexCounter++);
57
+ });
58
+
59
+ // Initialize Controller Sliders last
60
+ indexCounter = initAll(`[${ATTR_WATERFALL}][${ATTR_THUMBS}]`, indexCounter);
61
+ indexCounter = initAll(`[${ATTR_WATERFALL}][${ATTR_CONTROLLER}]`, indexCounter);
62
+
63
+ // MANIPULATION
64
+ manipulateSlides();
57
65
 
58
- // Initialize Controller Sliders last
59
- indexCounter = initAll(`[${ATTR_WATERFALL}][${ATTR_THUMBS}]`, indexCounter);
60
- indexCounter = initAll(`[${ATTR_WATERFALL}][${ATTR_CONTROLLER}]`, indexCounter);
66
+ // SLIDE COUNT
67
+ initSlideCount();
68
+
69
+ // ARIA ROLE FIX FOR WEBFLOW CMS LIST
70
+ fixWebflowCMSListARIARole();
71
+ });
61
72
 
62
73
  // Config
63
74
  function initConfig(el: HTMLElement, index: number) {
@@ -100,7 +111,9 @@ function initConfig(el: HTMLElement, index: number) {
100
111
 
101
112
  // Initialize swiper
102
113
  const swiperEl = el.querySelector(".swiper");
114
+ if (debug) console.log("SWIPER: ", swiperEl);
103
115
  const slides = swiperEl?.querySelectorAll(".swiper-slide") || [];
116
+ if (debug) console.log("SWIPER SLIDES: ", slides);
104
117
  if (slides.length === 0) {
105
118
  console.warn(`Skipping "${name}": no .swiper-slide elements found.`);
106
119
  return;
@@ -110,11 +123,3 @@ function initConfig(el: HTMLElement, index: number) {
110
123
  }
111
124
  }
112
125
 
113
- // MANIPULATION
114
- manipulateSlides();
115
-
116
- // SLIDE COUNT
117
- initSlideCount();
118
-
119
- // ARIA ROLE FIX FOR WEBFLOW CMS LIST
120
- fixWebflowCMSListARIARole();