well-waterfall 0.1.37 → 0.1.39
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 +316 -6
- package/package.json +1 -1
- package/src/modules/autoplay.ts +16 -0
- package/src/modules/navigation.ts +22 -0
- package/src/waterfall.ts +14 -122
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { parseAttr } from '../util';
|
|
2
|
+
|
|
3
|
+
export function autoplayConfig($this: JQuery<HTMLElement>) {
|
|
4
|
+
// Add CSS for Smooth Autoplay
|
|
5
|
+
$("[smooth-autoplay='true']")
|
|
6
|
+
.find('.swiper-wrapper')
|
|
7
|
+
.css('transition-timing-function', 'linear');
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
delay: parseAttr($this, 'delay', 3000),
|
|
11
|
+
disableOnInteraction: parseAttr($this, 'disable-on-interaction', false), // documentation says default is true, doesn't appear to be correct
|
|
12
|
+
reverseDirection: parseAttr($this, 'reverse-direction', false),
|
|
13
|
+
pauseOnMouseEnter: parseAttr($this, 'pause-on-mouse-enter', false),
|
|
14
|
+
stopOnLastSlide: parseAttr($this, 'stop-on-last-slide', false),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseAttr } from '../util';
|
|
2
|
+
|
|
3
|
+
export function navigationConfig($this: JQuery<HTMLElement>) {
|
|
4
|
+
return {
|
|
5
|
+
disabledClass: parseAttr(
|
|
6
|
+
$this,
|
|
7
|
+
'nav-disabled-class',
|
|
8
|
+
'swiper-button-disabled',
|
|
9
|
+
),
|
|
10
|
+
enabled: parseAttr($this, 'nav-enabled', null),
|
|
11
|
+
hiddenClass: parseAttr($this, 'nav-hidden-class', 'swiper-button-hidden'),
|
|
12
|
+
hideOnClick: parseAttr($this, 'nav-hide-on-click', false),
|
|
13
|
+
lockClass: parseAttr($this, 'nav-lock-class', 'swiper-button-lock'),
|
|
14
|
+
navigationDisabledClass: parseAttr(
|
|
15
|
+
$this,
|
|
16
|
+
'nav-disabled-class',
|
|
17
|
+
'swiper-navigation-disabled',
|
|
18
|
+
),
|
|
19
|
+
nextEl: `[waterfall='${name}'] [waterfall-el='next']`,
|
|
20
|
+
prevEl: `[waterfall='${name}'] [waterfall-el='prev']`,
|
|
21
|
+
};
|
|
22
|
+
}
|
package/src/waterfall.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Swiper from 'swiper/bundle';
|
|
1
2
|
import 'swiper/css/bundle';
|
|
2
3
|
import {
|
|
3
4
|
getUniqueClasses,
|
|
@@ -5,28 +6,21 @@ import {
|
|
|
5
6
|
removeNullKeys,
|
|
6
7
|
printDebug,
|
|
7
8
|
} from './util';
|
|
8
|
-
import
|
|
9
|
+
import { navigationConfig } from './modules/navigation';
|
|
10
|
+
import { autoplayConfig } from './modules/autoplay';
|
|
9
11
|
|
|
10
12
|
console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
|
|
11
13
|
|
|
12
14
|
const sliders: any[] = [];
|
|
13
15
|
|
|
14
|
-
$('[waterfall]
|
|
15
|
-
const $
|
|
16
|
-
createConfig($wtf, index);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
$('[waterfall][thumbs-swiper]').each(function (index) {
|
|
20
|
-
const $wtf = $(this);
|
|
21
|
-
console.log('PROCESSING THUMBS:', $wtf);
|
|
22
|
-
createConfig($wtf, index);
|
|
23
|
-
});
|
|
16
|
+
$('[waterfall]').each(function (index) {
|
|
17
|
+
const $this = $(this);
|
|
24
18
|
|
|
25
|
-
function createConfig($this: JQuery<HTMLElement>, index: number) {
|
|
26
19
|
const name = parseAttr($this, 'waterfall', `Swiper ${index}`);
|
|
27
|
-
console.log(`Initializing Waterfall: ${name}}`);
|
|
28
20
|
const debug = Boolean(parseAttr($this, 'debug-mode', false) || false);
|
|
29
21
|
|
|
22
|
+
console.log(`Initializing Waterfall: ${name} ${debug ? '[DEBUG MODE]' : ''}`);
|
|
23
|
+
|
|
30
24
|
const swiperConfig: any = {
|
|
31
25
|
a11y: {
|
|
32
26
|
prevSlideMessage: parseAttr($this, 'a11y-prev-message', 'Previous Slide'),
|
|
@@ -84,6 +78,7 @@ function createConfig($this: JQuery<HTMLElement>, index: number) {
|
|
|
84
78
|
longSwipes: parseAttr($this, 'long-swipes', true), // no effect
|
|
85
79
|
longSwipesMs: parseAttr($this, 'long-swipes-ms', 300), // no effect
|
|
86
80
|
longSwipesRatio: parseAttr($this, 'long-swipes-ratio', 0.5), // no effect
|
|
81
|
+
loop: parseAttr($this, 'loop-mode', false),
|
|
87
82
|
loopAddBlankSlides: parseAttr($this, 'loop-add-blank-slides', true),
|
|
88
83
|
loopAdditionalSlides: parseAttr($this, 'loop-additional-slides', 0),
|
|
89
84
|
loopPreventsSliding: parseAttr($this, 'loop-prevents-sliding', true),
|
|
@@ -119,6 +114,7 @@ function createConfig($this: JQuery<HTMLElement>, index: number) {
|
|
|
119
114
|
resistance: parseAttr($this, 'resistance', true),
|
|
120
115
|
resistanceRatio: parseAttr($this, 'resistance-ratio', 0.85),
|
|
121
116
|
resizeObserver: parseAttr($this, 'resize-observer', true),
|
|
117
|
+
rewind: parseAttr($this, 'rewind', false),
|
|
122
118
|
roundLengths: parseAttr($this, 'round-lengths', false),
|
|
123
119
|
runCallbacksOnInit: parseAttr($this, 'run-callbacks-on-init', true),
|
|
124
120
|
// scrollbar: null,
|
|
@@ -205,84 +201,34 @@ function createConfig($this: JQuery<HTMLElement>, index: number) {
|
|
|
205
201
|
478: {
|
|
206
202
|
centeredSlides: parseAttr($this, 'lmobile-centered-slides', null),
|
|
207
203
|
slidesPerView: parseAttr($this, 'lmobile-slides-per-view', null),
|
|
208
|
-
slidesPerGroup: parseAttr($this, 'lmobile-slides-per-group', null),
|
|
209
204
|
spaceBetween: parseAttr($this, 'lmobile-space-between', null),
|
|
210
205
|
},
|
|
211
206
|
767: {
|
|
212
207
|
centeredSlides: parseAttr($this, 'tablet-centered-slides', null),
|
|
213
208
|
slidesPerView: parseAttr($this, 'tablet-slides-per-view', null),
|
|
214
|
-
slidesPerGroup: parseAttr($this, 'tablet-slides-per-group', null),
|
|
215
209
|
spaceBetween: parseAttr($this, 'tablet-space-between', null),
|
|
216
210
|
},
|
|
217
211
|
991: {
|
|
218
212
|
centeredSlides: parseAttr($this, 'desktop-centered-slides', null),
|
|
219
213
|
slidesPerView: parseAttr($this, 'desktop-slides-per-view', null),
|
|
220
|
-
slidesPerGroup: parseAttr($this, 'desktop-slides-per-group', null),
|
|
221
214
|
spaceBetween: parseAttr($this, 'desktop-space-between', null),
|
|
222
215
|
},
|
|
223
216
|
1280: {
|
|
224
217
|
centeredSlides: parseAttr($this, 'large-centered-slides', null),
|
|
225
218
|
slidesPerView: parseAttr($this, 'large-slides-per-view', null),
|
|
226
|
-
slidesPerGroup: parseAttr($this, 'large-slides-per-group', null),
|
|
227
219
|
spaceBetween: parseAttr($this, 'large-space-between', null),
|
|
228
220
|
},
|
|
229
221
|
1440: {
|
|
230
222
|
centeredSlides: parseAttr($this, 'xlarge-centered-slides', null),
|
|
231
223
|
slidesPerView: parseAttr($this, 'xlarge-slides-per-view', null),
|
|
232
|
-
slidesPerGroup: parseAttr($this, 'xlarge-slides-per-group', null),
|
|
233
224
|
spaceBetween: parseAttr($this, 'xlarge-space-between', null),
|
|
234
225
|
},
|
|
235
226
|
};
|
|
236
227
|
|
|
237
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
238
|
-
// --- PLAYBACK -------------------------------
|
|
239
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
240
|
-
|
|
241
|
-
const playbackMode = parseAttr($this, 'playback-mode', 'none');
|
|
242
|
-
if (playbackMode === 'loop') swiperConfig.loop = true;
|
|
243
|
-
if (playbackMode === 'rewind') swiperConfig.rewind = true;
|
|
244
|
-
if (playbackMode === 'none') {
|
|
245
|
-
swiperConfig.loop = false;
|
|
246
|
-
swiperConfig.rewind = false;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
228
|
const autoplayMode = parseAttr($this, 'autoplay-mode', false);
|
|
250
|
-
if (autoplayMode)
|
|
251
|
-
swiperConfig.autoplay = {
|
|
252
|
-
delay: parseAttr($this, 'delay', 3000),
|
|
253
|
-
disableOnInteraction: parseAttr($this, 'disable-on-interaction', false), // documentation says default is true, doesn't appear to be correct
|
|
254
|
-
reverseDirection: parseAttr($this, 'reverse-direction', false),
|
|
255
|
-
pauseOnMouseEnter: parseAttr($this, 'pause-on-mouse-enter', false),
|
|
256
|
-
stopOnLastSlide: parseAttr($this, 'stop-on-last-slide', false),
|
|
257
|
-
};
|
|
258
|
-
// Add CSS for Smooth Autoplay
|
|
259
|
-
$("[smooth-autoplay='true']")
|
|
260
|
-
.find('.swiper-wrapper')
|
|
261
|
-
.css('transition-timing-function', 'linear');
|
|
262
|
-
}
|
|
229
|
+
if (autoplayMode) swiperConfig.autoplay = autoplayConfig($this);
|
|
263
230
|
|
|
264
|
-
|
|
265
|
-
// --- NAVIGATION -----------------------------
|
|
266
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
267
|
-
|
|
268
|
-
swiperConfig.navigation = {
|
|
269
|
-
disabledClass: parseAttr(
|
|
270
|
-
$this,
|
|
271
|
-
'nav-disabled-class',
|
|
272
|
-
'swiper-button-disabled',
|
|
273
|
-
),
|
|
274
|
-
enabled: parseAttr($this, 'nav-enabled', null),
|
|
275
|
-
hiddenClass: parseAttr($this, 'nav-hidden-class', 'swiper-button-hidden'),
|
|
276
|
-
hideOnClick: parseAttr($this, 'nav-hide-on-click', false),
|
|
277
|
-
lockClass: parseAttr($this, 'nav-lock-class', 'swiper-button-lock'),
|
|
278
|
-
navigationDisabledClass: parseAttr(
|
|
279
|
-
$this,
|
|
280
|
-
'nav-disabled-class',
|
|
281
|
-
'swiper-navigation-disabled',
|
|
282
|
-
),
|
|
283
|
-
nextEl: `[waterfall='${name}'] [waterfall-el='next']`,
|
|
284
|
-
prevEl: `[waterfall='${name}'] [waterfall-el='prev']`,
|
|
285
|
-
};
|
|
231
|
+
swiperConfig.navigation = navigationConfig($this);
|
|
286
232
|
|
|
287
233
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
288
234
|
// --- PAGINATION -----------------------------
|
|
@@ -473,67 +419,16 @@ function createConfig($this: JQuery<HTMLElement>, index: number) {
|
|
|
473
419
|
rows: parseAttr($this, 'grid-rows', 1),
|
|
474
420
|
};
|
|
475
421
|
|
|
476
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
477
|
-
// --- EFFECT ---------------------------------
|
|
478
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
479
|
-
|
|
480
|
-
swiperConfig.fadeEffect = {
|
|
481
|
-
crossFade: parseAttr($this, 'fade-cross-fade', false),
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
swiperConfig.coverflowEffect = {
|
|
485
|
-
depth: parseAttr($this, 'coverflow-depth', 100),
|
|
486
|
-
modifier: parseAttr($this, 'coverflow-modifier', 1),
|
|
487
|
-
rotate: parseAttr($this, 'coverflow-rotate', 50),
|
|
488
|
-
scale: parseAttr($this, 'coverflow-scale', 1),
|
|
489
|
-
slideShadows: parseAttr($this, 'coverflow-slide-shadows', true),
|
|
490
|
-
stretch: parseAttr($this, 'coverflow-stretch', 0),
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
swiperConfig.flipEffect = {
|
|
494
|
-
limitRotation: parseAttr($this, 'flip-limit-rotation', true),
|
|
495
|
-
slideShadows: parseAttr($this, 'flip-slide-shadows', true),
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
swiperConfig.cubeEffect = {
|
|
499
|
-
shadow: parseAttr($this, 'cube-shadow', true),
|
|
500
|
-
shadowOffset: parseAttr($this, 'cube-shadow-offset', 20),
|
|
501
|
-
shadowScale: parseAttr($this, 'cube-shadow-scale', 0.94),
|
|
502
|
-
slideShadows: parseAttr($this, 'cube-slide-shadows', true),
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
swiperConfig.cardsEffect = {
|
|
506
|
-
perSlideOffset: parseAttr($this, 'cards-per-slide-offset', 8),
|
|
507
|
-
perSlideRotate: parseAttr($this, 'cards-per-slide-rotate', 2),
|
|
508
|
-
rotate: parseAttr($this, 'cards-rotate', true),
|
|
509
|
-
slideShadows: parseAttr($this, 'cards-slide-shadows', true),
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
//NOTE - Creative Effect Not implemented
|
|
513
|
-
|
|
514
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
515
|
-
// --- THUMBS ---------------------------------
|
|
516
|
-
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
517
|
-
|
|
518
|
-
const thumbsSwiper = parseAttr($this, 'thumbs-swiper', null);
|
|
519
|
-
if (thumbsSwiper) {
|
|
520
|
-
swiperConfig.thumbs = {
|
|
521
|
-
swiper: sliders.find((slider) => slider.name === thumbsSwiper)?.slider,
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
|
|
525
422
|
// --- CLEANUP AND EXPORT ---
|
|
526
423
|
|
|
527
424
|
const config = removeNullKeys(swiperConfig);
|
|
528
|
-
printDebug(debug,
|
|
425
|
+
printDebug(debug, 'CONFIG', config);
|
|
529
426
|
|
|
427
|
+
// Initialize swiper
|
|
530
428
|
const swiper = new Swiper($this.find('.swiper')[0], config);
|
|
531
429
|
|
|
532
|
-
console.log('SWIEPR');
|
|
533
|
-
console.log(swiper);
|
|
534
|
-
|
|
535
430
|
sliders.push({ name, slider: swiper });
|
|
536
|
-
}
|
|
431
|
+
});
|
|
537
432
|
|
|
538
433
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
|
539
434
|
// --- SLIDE COUNT ----------------------------
|
|
@@ -547,6 +442,3 @@ document.querySelectorAll('.swiper-wrapper').forEach((swiperWrapper) => {
|
|
|
547
442
|
}
|
|
548
443
|
});
|
|
549
444
|
});
|
|
550
|
-
|
|
551
|
-
// Add the role="listitem" attribute to each slide
|
|
552
|
-
$('.swiper-slide').attr('role', 'listitem');
|