well-waterfall 1.0.2 → 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 +49 -0
- package/src/waterfall.ts +14 -30
- package/dist/waterfall.js +0 -744
- package/src/modules/.prettierrc +0 -4
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {MANIPULATION_SLIDE_ADD_ATTR} from '../../../attributes';
|
|
2
|
+
|
|
3
|
+
export function addSlides() {
|
|
4
|
+
// Ensure the waterfall object is defined
|
|
5
|
+
if (!Array.isArray(window.waterfalls)) {
|
|
6
|
+
console.error("[SlideAdder] window.waterfalls is not an array or not defined.");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Track the .w-dyn-list elements that originally contained matched slides
|
|
11
|
+
const dynListsToRemove: Set<Element> = new Set();
|
|
12
|
+
|
|
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}]`);
|
|
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);
|
|
21
|
+
if (!matchedWaterfall) {
|
|
22
|
+
console.warn(`[SlideAdder] No Waterfall found with name: "${targetName}"`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const swiper = matchedWaterfall.swiper;
|
|
27
|
+
if (!swiper || typeof swiper.appendSlide !== "function") {
|
|
28
|
+
console.error(`[SlideAdder] Invalid Swiper instance in Waterfall "${targetName}"`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Remove the wtf-add-slide attribute
|
|
33
|
+
el.removeAttribute(MANIPULATION_SLIDE_ADD_ATTR);
|
|
34
|
+
|
|
35
|
+
// Add to swiper
|
|
36
|
+
swiper.appendSlide(el.outerHTML);
|
|
37
|
+
|
|
38
|
+
// Track parent .w-dyn-list
|
|
39
|
+
const dynList = el.closest(".w-dyn-list");
|
|
40
|
+
if (dynList) {
|
|
41
|
+
dynListsToRemove.add(dynList);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Cleanup matched .w-dyn-list containers
|
|
46
|
+
dynListsToRemove.forEach((list) => {
|
|
47
|
+
list.remove();
|
|
48
|
+
});
|
|
49
|
+
}
|
package/src/waterfall.ts
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
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";
|
|
20
|
+
import { addSlides } from "./modules/manipulation";
|
|
34
21
|
|
|
35
22
|
console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
|
|
36
23
|
|
|
@@ -38,9 +25,7 @@ const waterfalls: Waterfall[] = [];
|
|
|
38
25
|
window.waterfalls = waterfalls;
|
|
39
26
|
|
|
40
27
|
// Initialize Thumb Sliders first
|
|
41
|
-
$('[waterfall][waterfall-preload="true"]').each((index, el) =>
|
|
42
|
-
initConfig(el, index),
|
|
43
|
-
);
|
|
28
|
+
$('[waterfall][waterfall-preload="true"]').each((index, el) => initConfig(el, index));
|
|
44
29
|
|
|
45
30
|
// Initialize all other sliders
|
|
46
31
|
$("[waterfall]")
|
|
@@ -48,9 +33,7 @@ $("[waterfall]")
|
|
|
48
33
|
.not('[waterfall-postload="true"]')
|
|
49
34
|
.each((index, el) => initConfig(el, index));
|
|
50
35
|
|
|
51
|
-
$('[waterfall][waterfall-postload="true"]').each((index, el) =>
|
|
52
|
-
initConfig(el, index),
|
|
53
|
-
);
|
|
36
|
+
$('[waterfall][waterfall-postload="true"]').each((index, el) => initConfig(el, index));
|
|
54
37
|
|
|
55
38
|
function initConfig(el: HTMLElement, index: number) {
|
|
56
39
|
{
|
|
@@ -60,12 +43,8 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
60
43
|
if (!name) return;
|
|
61
44
|
|
|
62
45
|
const debug = Boolean(parseAttr($this, "debug-mode", false) || false);
|
|
63
|
-
const debugAdvanced = Boolean(
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
console.log(
|
|
67
|
-
`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`,
|
|
68
|
-
);
|
|
46
|
+
const debugAdvanced = Boolean(parseAttr($this, "advanced-debug-mode", false) || false);
|
|
47
|
+
console.log(`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`);
|
|
69
48
|
|
|
70
49
|
// GENERAL CONFIG
|
|
71
50
|
const swiperConfig: any = generalConfig($this);
|
|
@@ -139,7 +118,6 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
139
118
|
printDebug(debug, "CONFIG", config);
|
|
140
119
|
|
|
141
120
|
// Initialize swiper
|
|
142
|
-
|
|
143
121
|
const $swiperEl = $this.find(".swiper");
|
|
144
122
|
const $slides = $swiperEl.find(".swiper-slide");
|
|
145
123
|
|
|
@@ -158,3 +136,9 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
158
136
|
|
|
159
137
|
initSlideCount();
|
|
160
138
|
|
|
139
|
+
// MANIPULATION
|
|
140
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
141
|
+
addSlides();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export * from './lib/attributes';
|