well-waterfall 1.0.3 → 1.0.4
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 +1 -1
- package/src/lib/attributes.ts +3 -0
- package/src/modules/manipulation.ts +15 -32
- package/src/waterfall.ts +10 -29
- package/dist/waterfall.js +0 -754
- package/src/modules/.prettierrc +0 -4
package/package.json
CHANGED
|
@@ -1,52 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
console.log("[SlideAdder] DOMContentLoaded fired");
|
|
1
|
+
import {MANIPULATION_SLIDE_ADD_ATTR} from '../../../attributes';
|
|
3
2
|
|
|
3
|
+
export function addSlides() {
|
|
4
|
+
// Ensure the waterfall object is defined
|
|
4
5
|
if (!Array.isArray(window.waterfalls)) {
|
|
5
|
-
console.error(
|
|
6
|
-
"[SlideAdder] window.waterfalls is not an array or not defined.",
|
|
7
|
-
);
|
|
6
|
+
console.error("[SlideAdder] window.waterfalls is not an array or not defined.");
|
|
8
7
|
return;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
console.log(`[SlideAdder] Found ${window.waterfalls.length} waterfalls`);
|
|
12
|
-
|
|
13
|
-
const addSlideElements = document.querySelectorAll("[wtf-add-slide]");
|
|
14
|
-
console.log(
|
|
15
|
-
`[SlideAdder] Found ${addSlideElements.length} elements with [wtf-add-slide]`,
|
|
16
|
-
);
|
|
17
|
-
|
|
18
10
|
// Track the .w-dyn-list elements that originally contained matched slides
|
|
19
11
|
const dynListsToRemove: Set<Element> = new Set();
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.log(`[SlideAdder] Processing slide for Waterfall: "${targetName}"`);
|
|
24
|
-
|
|
25
|
-
const matchedWaterfall = window.waterfalls.find(
|
|
26
|
-
(wf) => wf.name === targetName,
|
|
27
|
-
);
|
|
13
|
+
// Find all elements with the wtf-add-slide attribute and add them to the corresponding Waterfall
|
|
14
|
+
const addSlideElements = document.querySelectorAll(`[${MANIPULATION_SLIDE_ADD_ATTR}]`);
|
|
28
15
|
|
|
16
|
+
addSlideElements.forEach((el) => {
|
|
17
|
+
// Get the target Waterfall name from the attribute
|
|
18
|
+
const targetName = el.getAttribute(MANIPULATION_SLIDE_ADD_ATTR);
|
|
19
|
+
// Find the matchhing Waterfall by name
|
|
20
|
+
const matchedWaterfall = window.waterfalls.find((wf) => wf.name === targetName);
|
|
29
21
|
if (!matchedWaterfall) {
|
|
30
|
-
console.warn(
|
|
31
|
-
`[SlideAdder] No Waterfall found with name: "${targetName}"`,
|
|
32
|
-
);
|
|
22
|
+
console.warn(`[SlideAdder] No Waterfall found with name: "${targetName}"`);
|
|
33
23
|
return;
|
|
34
24
|
}
|
|
35
25
|
|
|
36
26
|
const swiper = matchedWaterfall.swiper;
|
|
37
27
|
if (!swiper || typeof swiper.appendSlide !== "function") {
|
|
38
|
-
console.error(
|
|
39
|
-
`[SlideAdder] Invalid Swiper instance in Waterfall "${targetName}"`,
|
|
40
|
-
);
|
|
28
|
+
console.error(`[SlideAdder] Invalid Swiper instance in Waterfall "${targetName}"`);
|
|
41
29
|
return;
|
|
42
30
|
}
|
|
43
31
|
|
|
44
32
|
// Remove the wtf-add-slide attribute
|
|
45
|
-
el.removeAttribute(
|
|
33
|
+
el.removeAttribute(MANIPULATION_SLIDE_ADD_ATTR);
|
|
46
34
|
|
|
47
35
|
// Add to swiper
|
|
48
36
|
swiper.appendSlide(el.outerHTML);
|
|
49
|
-
console.log(`[SlideAdder] Appended swiper-slide to "${targetName}"`);
|
|
50
37
|
|
|
51
38
|
// Track parent .w-dyn-list
|
|
52
39
|
const dynList = el.closest(".w-dyn-list");
|
|
@@ -56,11 +43,7 @@ export function addSlides() {
|
|
|
56
43
|
});
|
|
57
44
|
|
|
58
45
|
// Cleanup matched .w-dyn-list containers
|
|
59
|
-
console.log(
|
|
60
|
-
`[SlideAdder] Cleaning up ${dynListsToRemove.size} matched .w-dyn-list containers`,
|
|
61
|
-
);
|
|
62
46
|
dynListsToRemove.forEach((list) => {
|
|
63
47
|
list.remove();
|
|
64
|
-
console.log("[SlideAdder] Removed .w-dyn-list from DOM");
|
|
65
48
|
});
|
|
66
|
-
}
|
|
49
|
+
}
|
package/src/waterfall.ts
CHANGED
|
@@ -1,33 +1,19 @@
|
|
|
1
1
|
import Swiper from "swiper/bundle";
|
|
2
2
|
import "swiper/css/bundle";
|
|
3
|
-
import {
|
|
4
|
-
parseAttr,
|
|
5
|
-
removeNullOrUndefinedKeys,
|
|
6
|
-
printDebug,
|
|
7
|
-
parseString,
|
|
8
|
-
} from "./util";
|
|
3
|
+
import { parseAttr, removeNullOrUndefinedKeys, printDebug, parseString } from "./util";
|
|
9
4
|
import { navigationConfig } from "./modules/navigation";
|
|
10
5
|
import { breakpointsConfig } from "./modules/breakpoints";
|
|
11
6
|
import { paginationConfig } from "./modules/pagination";
|
|
12
7
|
import { scrollbarConfig } from "./modules/scrollbar";
|
|
13
8
|
import { autoplayConfig, freeModeConfig } from "./modules/playback";
|
|
14
|
-
import {
|
|
15
|
-
coverflowEffect,
|
|
16
|
-
fadeConfig,
|
|
17
|
-
flipEffect,
|
|
18
|
-
cardsEffect,
|
|
19
|
-
cubeEffect,
|
|
20
|
-
} from "./modules/effect";
|
|
9
|
+
import { coverflowEffect, fadeConfig, flipEffect, cardsEffect, cubeEffect } from "./modules/effect";
|
|
21
10
|
import { gridConfig } from "./modules/layout";
|
|
22
11
|
import { generalConfig } from "./modules/general";
|
|
23
12
|
import { initSlideCount } from "./modules/slideCount";
|
|
24
13
|
import { thumbsConfig } from "./modules/thumbs";
|
|
25
14
|
import { Waterfall } from "./types/waterfall";
|
|
26
15
|
import { keyboardConfig, mouseConfig } from "./modules/input";
|
|
27
|
-
import {
|
|
28
|
-
hashNavigationConfig,
|
|
29
|
-
historyNavigationConfig,
|
|
30
|
-
} from "./modules/hashhistory";
|
|
16
|
+
import { hashNavigationConfig, historyNavigationConfig } from "./modules/hashhistory";
|
|
31
17
|
import { controllerConfig } from "./modules/controller";
|
|
32
18
|
import { SwiperOptions } from "swiper/types";
|
|
33
19
|
import { accessibilityConfig } from "./modules/accessibility";
|
|
@@ -39,9 +25,7 @@ const waterfalls: Waterfall[] = [];
|
|
|
39
25
|
window.waterfalls = waterfalls;
|
|
40
26
|
|
|
41
27
|
// Initialize Thumb Sliders first
|
|
42
|
-
$('[waterfall][waterfall-preload="true"]').each((index, el) =>
|
|
43
|
-
initConfig(el, index),
|
|
44
|
-
);
|
|
28
|
+
$('[waterfall][waterfall-preload="true"]').each((index, el) => initConfig(el, index));
|
|
45
29
|
|
|
46
30
|
// Initialize all other sliders
|
|
47
31
|
$("[waterfall]")
|
|
@@ -49,9 +33,7 @@ $("[waterfall]")
|
|
|
49
33
|
.not('[waterfall-postload="true"]')
|
|
50
34
|
.each((index, el) => initConfig(el, index));
|
|
51
35
|
|
|
52
|
-
$('[waterfall][waterfall-postload="true"]').each((index, el) =>
|
|
53
|
-
initConfig(el, index),
|
|
54
|
-
);
|
|
36
|
+
$('[waterfall][waterfall-postload="true"]').each((index, el) => initConfig(el, index));
|
|
55
37
|
|
|
56
38
|
function initConfig(el: HTMLElement, index: number) {
|
|
57
39
|
{
|
|
@@ -61,12 +43,8 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
61
43
|
if (!name) return;
|
|
62
44
|
|
|
63
45
|
const debug = Boolean(parseAttr($this, "debug-mode", false) || false);
|
|
64
|
-
const debugAdvanced = Boolean(
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
console.log(
|
|
68
|
-
`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`,
|
|
69
|
-
);
|
|
46
|
+
const debugAdvanced = Boolean(parseAttr($this, "advanced-debug-mode", false) || false);
|
|
47
|
+
console.log(`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`);
|
|
70
48
|
|
|
71
49
|
// GENERAL CONFIG
|
|
72
50
|
const swiperConfig: any = generalConfig($this);
|
|
@@ -158,6 +136,9 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
158
136
|
|
|
159
137
|
initSlideCount();
|
|
160
138
|
|
|
139
|
+
// MANIPULATION
|
|
161
140
|
document.addEventListener("DOMContentLoaded", function () {
|
|
162
141
|
addSlides();
|
|
163
142
|
});
|
|
143
|
+
|
|
144
|
+
export * from './lib/attributes';
|