well-waterfall 0.1.32 → 0.1.34

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "well-waterfall",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "An attribute-based wrapper of SwiperJS for Webflow",
5
5
  "main": "waterfall.js",
6
6
  "scripts": {
package/src/waterfall.ts CHANGED
@@ -1,4 +1,3 @@
1
- import Swiper from 'swiper/bundle';
2
1
  import 'swiper/css/bundle';
3
2
  import {
4
3
  getUniqueClasses,
@@ -11,13 +10,21 @@ console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
11
10
 
12
11
  const sliders: any[] = [];
13
12
 
14
- $('[waterfall]').each(function (index) {
15
- const $this = $(this);
13
+ $('[waterfall]:not([thumbs-swiper])').each(function (index) {
14
+ const $wtf = $(this);
15
+ createConfig($wtf, index);
16
+ });
16
17
 
17
- const name = parseAttr($this, 'waterfall', `Swiper ${index}`);
18
- const debug = Boolean(parseAttr($this, 'debug-mode', false) || false);
18
+ $('[waterfall][thumbs-swiper]').each(function (index) {
19
+ const $wtf = $(this);
20
+ console.log('PROCESSING THUMBS:', $wtf);
21
+ createConfig($wtf, index);
22
+ });
19
23
 
24
+ function createConfig($this: JQuery<HTMLElement>, index: number) {
25
+ const name = parseAttr($this, 'waterfall', `Swiper ${index}`);
20
26
  console.log(`Initializing Waterfall: ${name}}`);
27
+ const debug = Boolean(parseAttr($this, 'debug-mode', false) || false);
21
28
 
22
29
  const swiperConfig: any = {
23
30
  a11y: {
@@ -507,53 +514,20 @@ $('[waterfall]').each(function (index) {
507
514
  // --- THUMBS ---------------------------------
508
515
  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
509
516
 
510
- swiperConfig.thumbs = {
511
- swiper: parseAttr($this, 'thumbs-swiper', null),
512
- autoScrollOffset: parseAttr($this, 'thumbs-auto-scroll-offset', 0),
513
- multipleActiveThumbs: parseAttr(
514
- $this,
515
- 'thumbs-multiple-active-thumbs',
516
- true,
517
- ),
518
- slideThumbActiveClass: parseAttr(
519
- $this,
520
- 'thumbs-slide-thumb-active-class',
521
- 'swiper-slide-thumb-active',
522
- ),
523
- thumbsContainerClass: parseAttr(
524
- $this,
525
- 'thumbs-container-class',
526
- 'swiper-thumbs',
527
- ),
528
- };
517
+ const thumbsSwiper = parseAttr($this, 'thumbs-swiper', null);
518
+ if (thumbsSwiper) {
519
+ swiperConfig.thumbs = {
520
+ swiper: sliders.find((slider) => slider.name === thumbsSwiper)?.slider,
521
+ };
522
+ }
529
523
 
530
524
  // --- CLEANUP AND EXPORT ---
531
525
 
532
526
  const config = removeNullKeys(swiperConfig);
533
527
  printDebug(debug, `${name} Config:`, config);
534
528
 
535
- // Initialize swiper
536
- const swiper = new Swiper($this.find('.swiper')[0], config);
537
-
538
- sliders.push({ name, slider: swiper });
539
- });
540
-
541
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
542
- // --- THUMBS ---------------------------------
543
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
544
-
545
- sliders.forEach((s) => {
546
- const { name, slider } = s;
547
- console.log('PROCESSING SLIDER:', name);
548
- console.log(slider);
549
- const thumbs = slider.thumbs.swiper;
550
- console.log('THUMBS:', thumbs);
551
-
552
- if (thumbs) {
553
- const thumbsSlider = sliders.find((s) => s.name === thumbs.swiper)?.slider;
554
- console.log('THUMBS SLIDER:', thumbsSlider);
555
- }
556
- });
529
+ sliders.push({ name, slider: config });
530
+ }
557
531
 
558
532
  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
559
533
  // --- SLIDE COUNT ----------------------------