well-waterfall 0.1.16 → 0.1.18
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/dist/waterfall.js +15 -15
- package/package.json +1 -1
- package/src/util.ts +0 -59
- package/src/waterfall.ts +35 -35
package/package.json
CHANGED
package/src/util.ts
CHANGED
|
@@ -19,65 +19,6 @@ export function getUniqueClasses(
|
|
|
19
19
|
return filtered.join(' '); // Join the remaining classes into a string
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Function to get a number attribute
|
|
23
|
-
export function getNumberAttr(
|
|
24
|
-
el: JQuery<HTMLElement>,
|
|
25
|
-
attrName: string,
|
|
26
|
-
defaultValue: number | null,
|
|
27
|
-
): number | null {
|
|
28
|
-
const attrValue = $(el).attr(attrName);
|
|
29
|
-
|
|
30
|
-
// If the attribute doesn't exist or the default is null, return null
|
|
31
|
-
if (attrValue === null || attrValue === undefined) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Parse the attribute as a number
|
|
36
|
-
const parsedValue = Number(attrValue);
|
|
37
|
-
|
|
38
|
-
// If the parsed value is not a number or matches the default value, return null
|
|
39
|
-
return isNaN(parsedValue) || parsedValue === defaultValue
|
|
40
|
-
? null
|
|
41
|
-
: parsedValue;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Function to get a boolean attribute
|
|
45
|
-
export function getBooleanAttr(
|
|
46
|
-
el: JQuery<HTMLElement>,
|
|
47
|
-
attrName: string,
|
|
48
|
-
defaultValue: boolean | null,
|
|
49
|
-
): boolean | null {
|
|
50
|
-
const value = $(el).attr(attrName);
|
|
51
|
-
|
|
52
|
-
// If the attribute doesn't exist or the default is null, return null
|
|
53
|
-
if (value === null || value === undefined || defaultValue === null) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Compare the attribute value (converted to lowercase) to 'true'
|
|
58
|
-
const booleanValue = String(value).toLowerCase() === 'true';
|
|
59
|
-
|
|
60
|
-
// If the value matches the default, return null
|
|
61
|
-
return booleanValue === defaultValue ? null : booleanValue;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Function to get a string attribute
|
|
65
|
-
export function getStringAttr(
|
|
66
|
-
el: JQuery<HTMLElement>,
|
|
67
|
-
attrName: string,
|
|
68
|
-
defaultValue: string | null,
|
|
69
|
-
): string | null {
|
|
70
|
-
const value = $(el).attr(attrName);
|
|
71
|
-
|
|
72
|
-
// If the attribute doesn't exist or the default is null, return null
|
|
73
|
-
if (value === null || value === undefined || defaultValue === null) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// If the attribute matches the default value, return null
|
|
78
|
-
return value.toString() === defaultValue ? null : value.toString();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
22
|
export function parseAttr(
|
|
82
23
|
el: JQuery<HTMLElement>,
|
|
83
24
|
attrName: string,
|
package/src/waterfall.ts
CHANGED
|
@@ -17,7 +17,8 @@ $('[waterfall]').each(function (index) {
|
|
|
17
17
|
const name = parseAttr($this, 'waterfall', `Swiper ${index}`);
|
|
18
18
|
const debug = Boolean(parseAttr($this, 'debug-mode', false) || false);
|
|
19
19
|
|
|
20
|
-
console.log(
|
|
20
|
+
console.log(`Initializing ${name}`);
|
|
21
|
+
console.log(debug && 'Debug Mode');
|
|
21
22
|
|
|
22
23
|
const swiperConfig: any = {
|
|
23
24
|
a11y: {
|
|
@@ -28,33 +29,6 @@ $('[waterfall]').each(function (index) {
|
|
|
28
29
|
allowSlidePrev: parseAttr($this, 'allow-slide-prev', true),
|
|
29
30
|
allowTouchMove: parseAttr($this, 'allow-touch-move', true),
|
|
30
31
|
autoHeight: parseAttr($this, 'auto-height', false),
|
|
31
|
-
breakpoints: {
|
|
32
|
-
478: {
|
|
33
|
-
centeredSlides: parseAttr($this, 'lmobile-centered-slides', null),
|
|
34
|
-
slidesPerView: parseAttr($this, 'lmobile-slides-per-view', null),
|
|
35
|
-
spaceBetween: parseAttr($this, 'lmobile-space-between', null),
|
|
36
|
-
},
|
|
37
|
-
767: {
|
|
38
|
-
centeredSlides: parseAttr($this, 'tablet-centered-slides', null),
|
|
39
|
-
slidesPerView: parseAttr($this, 'tablet-slides-per-view', null),
|
|
40
|
-
spaceBetween: parseAttr($this, 'tablet-space-between', null),
|
|
41
|
-
},
|
|
42
|
-
991: {
|
|
43
|
-
centeredSlides: parseAttr($this, 'desktop-centered-slides', null),
|
|
44
|
-
slidesPerView: parseAttr($this, 'desktop-slides-per-view', null),
|
|
45
|
-
spaceBetween: parseAttr($this, 'desktop-space-between', null),
|
|
46
|
-
},
|
|
47
|
-
1280: {
|
|
48
|
-
centeredSlides: parseAttr($this, 'large-centered-slides', null),
|
|
49
|
-
slidesPerView: parseAttr($this, 'large-slides-per-view', null),
|
|
50
|
-
spaceBetween: parseAttr($this, 'large-space-between', null),
|
|
51
|
-
},
|
|
52
|
-
1440: {
|
|
53
|
-
centeredSlides: parseAttr($this, 'xlarge-centered-slides', null),
|
|
54
|
-
slidesPerView: parseAttr($this, 'xlarge-slides-per-view', null),
|
|
55
|
-
spaceBetween: parseAttr($this, 'xlarge-space-between', null),
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
32
|
breakpointsBase: parseAttr($this, 'breakpoints-base', 'window'),
|
|
59
33
|
centerInsufficientSlides: parseAttr(
|
|
60
34
|
$this,
|
|
@@ -218,15 +192,46 @@ $('[waterfall]').each(function (index) {
|
|
|
218
192
|
//zoom: null,
|
|
219
193
|
};
|
|
220
194
|
|
|
195
|
+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
196
|
+
// --- BREAKPOINTS ----------------------------
|
|
197
|
+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
198
|
+
|
|
199
|
+
swiperConfig.breakpoints = {
|
|
200
|
+
478: {
|
|
201
|
+
centeredSlides: parseAttr($this, 'lmobile-centered-slides', null),
|
|
202
|
+
slidesPerView: parseAttr($this, 'lmobile-slides-per-view', null),
|
|
203
|
+
spaceBetween: parseAttr($this, 'lmobile-space-between', null),
|
|
204
|
+
},
|
|
205
|
+
767: {
|
|
206
|
+
centeredSlides: parseAttr($this, 'tablet-centered-slides', null),
|
|
207
|
+
slidesPerView: parseAttr($this, 'tablet-slides-per-view', null),
|
|
208
|
+
spaceBetween: parseAttr($this, 'tablet-space-between', null),
|
|
209
|
+
},
|
|
210
|
+
991: {
|
|
211
|
+
centeredSlides: parseAttr($this, 'desktop-centered-slides', null),
|
|
212
|
+
slidesPerView: parseAttr($this, 'desktop-slides-per-view', null),
|
|
213
|
+
spaceBetween: parseAttr($this, 'desktop-space-between', null),
|
|
214
|
+
},
|
|
215
|
+
1280: {
|
|
216
|
+
centeredSlides: parseAttr($this, 'large-centered-slides', null),
|
|
217
|
+
slidesPerView: parseAttr($this, 'large-slides-per-view', null),
|
|
218
|
+
spaceBetween: parseAttr($this, 'large-space-between', null),
|
|
219
|
+
},
|
|
220
|
+
1440: {
|
|
221
|
+
centeredSlides: parseAttr($this, 'xlarge-centered-slides', null),
|
|
222
|
+
slidesPerView: parseAttr($this, 'xlarge-slides-per-view', null),
|
|
223
|
+
spaceBetween: parseAttr($this, 'xlarge-space-between', null),
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
|
|
221
227
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
222
228
|
// --- AUTOPLAY --------------------------------
|
|
223
229
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
224
230
|
const autoplayMode = parseAttr($this, 'autoplay-mode', false);
|
|
225
|
-
printDebug(debug, 'AUTOPLAY MODE', autoplayMode);
|
|
226
231
|
|
|
227
232
|
if (autoplayMode) {
|
|
228
233
|
swiperConfig.autoplay = {
|
|
229
|
-
delay: parseAttr($this, 'delay',
|
|
234
|
+
delay: parseAttr($this, 'delay', 3000),
|
|
230
235
|
disableOnInteraction: parseAttr($this, 'disable-on-interaction', false), // documentation says default is true, doesn't appear to be correct
|
|
231
236
|
reverseDirection: parseAttr($this, 'reverse-direction', false),
|
|
232
237
|
pauseOnMouseEnter: parseAttr($this, 'pause-on-mouse-enter', false),
|
|
@@ -270,8 +275,6 @@ $('[waterfall]').each(function (index) {
|
|
|
270
275
|
"[waterfall-el='pagination-bullet-active']",
|
|
271
276
|
);
|
|
272
277
|
let pagination = $paginationBullet.length ? true : false;
|
|
273
|
-
printDebug(debug, 'PAGINATION:', pagination);
|
|
274
|
-
printDebug(debug, 'PAGINATION TYPE:', paginationType);
|
|
275
278
|
|
|
276
279
|
type RenderBulletFunction = (index: number, className: string) => string;
|
|
277
280
|
|
|
@@ -391,9 +394,6 @@ $('[waterfall]').each(function (index) {
|
|
|
391
394
|
const $scrollbar = $this.find("[waterfall-el='scrollbar']");
|
|
392
395
|
const $scrollbarDrag = $($scrollbar).find("[waterfall-el='scrollbar-drag']");
|
|
393
396
|
|
|
394
|
-
printDebug(debug, 'SCROLLBAR', $scrollbar);
|
|
395
|
-
printDebug(debug, 'SCROLLBAR DRAG', $scrollbarDrag);
|
|
396
|
-
|
|
397
397
|
if ($scrollbar) {
|
|
398
398
|
swiperConfig.scrollbar = {
|
|
399
399
|
dragClass: $scrollbarDrag.attr('class'),
|