well-waterfall 1.0.4 → 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/.prettierrc +2 -1
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/lib/attributes.ts +278 -3
- package/src/modules/accessibility.ts +33 -52
- package/src/modules/breakpoints.ts +43 -22
- package/src/modules/controller.ts +8 -10
- package/src/modules/effect.ts +42 -23
- package/src/modules/general.ts +194 -161
- package/src/modules/hashhistory.ts +17 -9
- package/src/modules/input.ts +29 -19
- package/src/modules/layout.ts +5 -4
- package/src/modules/manipulation.ts +19 -9
- package/src/modules/navigation.ts +20 -18
- package/src/modules/pagination.ts +66 -92
- package/src/modules/playback.ts +35 -24
- package/src/modules/scrollbar.ts +29 -31
- package/src/modules/slideCount.ts +5 -3
- package/src/modules/thumbs.ts +19 -25
- package/src/modules/zoom.ts +18 -17
- package/src/util.ts +55 -100
- package/src/waterfall.ts +64 -47
- package/tsconfig.json +3 -0
- package/webpack.config.js +3 -0
package/src/waterfall.ts
CHANGED
|
@@ -18,99 +18,122 @@ 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";
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
ATTR_WATERFALL_PRELOAD,
|
|
25
|
+
ATTR_WATERFALL,
|
|
26
|
+
ATTR_WATERFALL_POSTLOAD,
|
|
27
|
+
ATTR_DEBUG_MODE,
|
|
28
|
+
ATTR_ADVANCED_DEBUG_MODE,
|
|
29
|
+
ATTR_PLAYBACK_MODE,
|
|
30
|
+
ATTR_THUMBS,
|
|
31
|
+
} from "./lib/attributes";
|
|
21
32
|
|
|
22
33
|
console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
|
|
23
34
|
|
|
24
35
|
const waterfalls: Waterfall[] = [];
|
|
25
36
|
window.waterfalls = waterfalls;
|
|
26
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
|
+
|
|
27
49
|
// Initialize Thumb Sliders first
|
|
28
|
-
|
|
50
|
+
initAll(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_PRELOAD}="true"]`);
|
|
29
51
|
|
|
30
52
|
// Initialize all other sliders
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
});
|
|
35
58
|
|
|
36
|
-
|
|
59
|
+
// Initialize Postload sliders
|
|
60
|
+
initAll(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_POSTLOAD}="true"]`);
|
|
37
61
|
|
|
38
62
|
function initConfig(el: HTMLElement, index: number) {
|
|
39
63
|
{
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const name = parseString($this, "waterfall", `Swiper ${index}`);
|
|
64
|
+
const name = parseString(el, ATTR_WATERFALL, `Swiper ${index}`);
|
|
43
65
|
if (!name) return;
|
|
44
66
|
|
|
45
|
-
const debug = Boolean(parseAttr(
|
|
46
|
-
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);
|
|
47
69
|
console.log(`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`);
|
|
48
70
|
|
|
49
71
|
// GENERAL CONFIG
|
|
50
|
-
const swiperConfig: any = generalConfig(
|
|
72
|
+
const swiperConfig: any = generalConfig(el);
|
|
51
73
|
|
|
52
74
|
// BREAKPOINTS
|
|
53
|
-
swiperConfig.breakpoints = breakpointsConfig(
|
|
75
|
+
swiperConfig.breakpoints = breakpointsConfig(el);
|
|
54
76
|
|
|
55
77
|
// PLAYBACK
|
|
56
|
-
const playbackMode = parseAttr(
|
|
78
|
+
const playbackMode = parseAttr(el, ATTR_PLAYBACK_MODE, "none");
|
|
57
79
|
if (playbackMode === "loop") swiperConfig.loop = true;
|
|
58
80
|
if (playbackMode === "rewind") swiperConfig.rewind = true;
|
|
59
81
|
if (playbackMode === "none") {
|
|
60
82
|
swiperConfig.loop = false;
|
|
61
83
|
swiperConfig.rewind = false;
|
|
62
84
|
}
|
|
63
|
-
swiperConfig.autoplay = autoplayConfig(
|
|
85
|
+
swiperConfig.autoplay = autoplayConfig(el);
|
|
64
86
|
|
|
65
87
|
// NAVIGATION
|
|
66
|
-
swiperConfig.navigation = navigationConfig(
|
|
88
|
+
swiperConfig.navigation = navigationConfig(el, name);
|
|
67
89
|
|
|
68
90
|
// PAGINATION
|
|
69
|
-
|
|
70
|
-
if (
|
|
91
|
+
const paginationEl = el.querySelector(`[waterfall-el='pagination-bullet']`);
|
|
92
|
+
if (paginationEl) swiperConfig.pagination = paginationConfig(el);
|
|
71
93
|
|
|
72
94
|
// SCROLLBAR
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
95
|
+
const scrollbarEl = el.querySelector(`[waterfall-el='scrollbar']`);
|
|
96
|
+
if (scrollbarEl) swiperConfig.scrollbar = scrollbarConfig(el);
|
|
75
97
|
|
|
76
98
|
// EFFECT
|
|
77
|
-
swiperConfig.fadeEffect = fadeConfig(
|
|
78
|
-
swiperConfig.coverflowEffect = coverflowEffect(
|
|
79
|
-
swiperConfig.flipEffect = flipEffect(
|
|
80
|
-
swiperConfig.cardsEffect = cardsEffect(
|
|
81
|
-
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);
|
|
82
104
|
|
|
83
105
|
// FREE MODE
|
|
84
|
-
swiperConfig.freeMode = freeModeConfig(
|
|
106
|
+
swiperConfig.freeMode = freeModeConfig(el);
|
|
85
107
|
|
|
86
108
|
// GRID
|
|
87
|
-
swiperConfig.grid = gridConfig(
|
|
109
|
+
swiperConfig.grid = gridConfig(el);
|
|
88
110
|
|
|
89
111
|
// THUMBS
|
|
90
|
-
const isThumbs = parseAttr(
|
|
91
|
-
if (!isThumbs) swiperConfig.thumbs = thumbsConfig(
|
|
112
|
+
const isThumbs = parseAttr(el, ATTR_THUMBS, null) === true;
|
|
113
|
+
if (!isThumbs) swiperConfig.thumbs = thumbsConfig(el, waterfalls);
|
|
92
114
|
|
|
93
115
|
// ZOOM - NOT IMPLEMENTED
|
|
116
|
+
swiperConfig.zoom = zoomConfig(el);
|
|
94
117
|
|
|
95
118
|
// KEYBOARD
|
|
96
|
-
swiperConfig.keyboard = keyboardConfig(
|
|
119
|
+
swiperConfig.keyboard = keyboardConfig(el);
|
|
97
120
|
|
|
98
121
|
// MOUSE
|
|
99
|
-
swiperConfig.mousewheel = mouseConfig(
|
|
122
|
+
swiperConfig.mousewheel = mouseConfig(el);
|
|
100
123
|
|
|
101
124
|
// VIRTUAL SLIDES - NOT IMPLEMENTED
|
|
102
125
|
|
|
103
126
|
// HASH NAVIGATION
|
|
104
|
-
swiperConfig.hashNavigation = hashNavigationConfig(
|
|
127
|
+
swiperConfig.hashNavigation = hashNavigationConfig(el);
|
|
105
128
|
|
|
106
129
|
// HISTORY NAVIGATION
|
|
107
|
-
swiperConfig.history = historyNavigationConfig(
|
|
130
|
+
swiperConfig.history = historyNavigationConfig(el);
|
|
108
131
|
|
|
109
132
|
// CONTROLLER
|
|
110
|
-
swiperConfig.controller = controllerConfig(
|
|
133
|
+
swiperConfig.controller = controllerConfig(el, waterfalls);
|
|
111
134
|
|
|
112
135
|
// A11Y
|
|
113
|
-
swiperConfig.a11y = accessibilityConfig(
|
|
136
|
+
swiperConfig.a11y = accessibilityConfig(el);
|
|
114
137
|
|
|
115
138
|
// Clean up the config and debug
|
|
116
139
|
if (debugAdvanced) printDebug(debug, "CONFIG (UNCLEANED)", swiperConfig);
|
|
@@ -118,19 +141,15 @@ function initConfig(el: HTMLElement, index: number) {
|
|
|
118
141
|
printDebug(debug, "CONFIG", config);
|
|
119
142
|
|
|
120
143
|
// Initialize swiper
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
// Check if there are slides, return if none are found
|
|
125
|
-
if ($slides.length === 0) {
|
|
144
|
+
const swiperEl = el.querySelector(".swiper");
|
|
145
|
+
const slides = swiperEl?.querySelectorAll(".swiper-slide") || [];
|
|
146
|
+
if (slides.length === 0) {
|
|
126
147
|
console.warn(`Skipping "${name}": no .swiper-slide elements found.`);
|
|
127
148
|
return;
|
|
128
149
|
}
|
|
129
|
-
|
|
130
|
-
const swiper = new Swiper(
|
|
131
|
-
|
|
132
|
-
// Add to sliders array
|
|
133
|
-
waterfalls.push({ name, swiper: swiper });
|
|
150
|
+
// INIT SWIPER
|
|
151
|
+
const swiper = new Swiper(swiperEl as HTMLElement, config);
|
|
152
|
+
waterfalls.push({ name, swiper });
|
|
134
153
|
}
|
|
135
154
|
}
|
|
136
155
|
|
|
@@ -140,5 +159,3 @@ initSlideCount();
|
|
|
140
159
|
document.addEventListener("DOMContentLoaded", function () {
|
|
141
160
|
addSlides();
|
|
142
161
|
});
|
|
143
|
-
|
|
144
|
-
export * from './lib/attributes';
|
package/tsconfig.json
CHANGED
package/webpack.config.js
CHANGED
|
@@ -34,6 +34,9 @@ module.exports = {
|
|
|
34
34
|
mode: 'development', // Can be 'development' for debugging
|
|
35
35
|
resolve: {
|
|
36
36
|
extensions: ['.js', '.ts', '.json'], // Add file extensions you use
|
|
37
|
+
alias: {
|
|
38
|
+
lib: path.resolve(__dirname, 'src/lib'),
|
|
39
|
+
},
|
|
37
40
|
},
|
|
38
41
|
plugins: [
|
|
39
42
|
new webpack.DefinePlugin({
|