well-waterfall 1.0.4 → 1.0.6

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.
@@ -1,103 +1,81 @@
1
- import { getUniqueClasses, parseAttr } from '../util';
1
+ import {
2
+ ATTR_NAVIGATION_LOCK_CLASS,
3
+ ATTR_PAGINATION,
4
+ ATTR_PAGINATION_BULLET,
5
+ ATTR_PAGINATION_BULLET_ACTIVE,
6
+ ATTR_PAGINATION_CLICKABLE,
7
+ ATTR_PAGINATION_CLICKABLE_CLASS,
8
+ ATTR_PAGINATION_CURRENT_CLASS,
9
+ ATTR_PAGINATION_DYNAMIC_BULLETS,
10
+ ATTR_PAGINATION_DYNAMIC_MAIN_BULLETS,
11
+ ATTR_PAGINATION_ENABLED,
12
+ ATTR_PAGINATION_HIDDEN_CLASS,
13
+ ATTR_PAGINATION_HIDE_ON_CLICK,
14
+ ATTR_PAGINATION_HORIZONTAL_CLASS,
15
+ ATTR_PAGINATION_MODIFIER_CLASS,
16
+ ATTR_PAGINATION_PAGINATION_DISABLED_CLASS,
17
+ ATTR_PAGINATION_PROGRESSBAR_FILL_CLASS,
18
+ ATTR_PAGINATION_PROGRESSBAR_OPPOSITE,
19
+ ATTR_PAGINATION_TOTAL_CLASS,
20
+ ATTR_PAGINATION_TYPE,
21
+ ATTR_PAGINATION_VERTICAL_CLASS,
22
+ ATTR_WATERFALL_ELEMENT,
23
+ } from "lib/attributes";
24
+ import { getUniqueClasses, parseAttr } from "../util";
2
25
 
3
26
  export function paginationConfig($this: JQuery<HTMLElement>) {
4
- let paginationType = parseAttr($this, 'pagination-type', '');
27
+ let paginationType = parseAttr($this, ATTR_PAGINATION_TYPE, "");
5
28
 
6
- let $paginationBullet = $this.find("[waterfall-el='pagination-bullet']");
7
- let paginationBulletActive = $this.find(
8
- "[waterfall-el='pagination-bullet-active']",
9
- );
29
+ let $paginationBullet = $this.find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_PAGINATION_BULLET}]`);
30
+ let paginationBulletActive = $this.find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_PAGINATION_BULLET_ACTIVE}]`);
10
31
 
11
32
  return {
12
- bulletActiveClass: getUniqueClasses(
13
- paginationBulletActive,
14
- $paginationBullet,
15
- ),
16
- bulletClass: $paginationBullet.attr('class'),
17
- bulletElement: $paginationBullet.prop('tagName')?.toLowerCase() || 'span', //ISSUE HERE
18
- clickable: parseAttr($this, 'pagination-clickable', false),
19
- clickableClass: parseAttr(
20
- $this,
21
- 'pagination-clickable-class',
22
- 'swiper-pagination-clickable',
23
- ),
24
- currentClass: parseAttr(
25
- $this,
26
- 'pagination-current-class',
27
- 'swiper-pagination-current',
28
- ),
29
- dynamicBullets: parseAttr(
30
- $this,
31
- 'dynamic-bullets',
32
- 'swiper-pagination-current',
33
- ),
34
- dynamicMainBullets: parseAttr($this, 'dynamic-main-bullets', 1),
35
- el: $this.find("[waterfall-el='pagination']")[0],
36
- enabled: parseAttr($this, 'pagination-enabled', null),
37
- //formatFractionCurrent: null,
38
- //formatFractionTotal: null,
39
- hiddenClass: parseAttr(
40
- $this,
41
- 'pagination-hidden-class',
42
- 'swiper-pagination-hidden',
43
- ),
44
- hideOnClick: parseAttr($this, 'pagination-hide-on-click', true),
45
- horizontalClass: parseAttr(
46
- $this,
47
- 'pagination-horizontal-class',
48
- 'swiper-pagination-horizontal',
49
- ),
50
- lockClass: parseAttr(
51
- $this,
52
- 'pagination-lock-class',
53
- 'swiper-pagination-lock',
54
- ),
55
- modifierClass: parseAttr(
56
- $this,
57
- 'pagination-modifier-class',
58
- 'swiper-pagination-',
59
- ),
60
- paginationDisabledClass: parseAttr(
61
- $this,
62
- 'pagination-disabled-class',
63
- 'swiper-pagination-disabled',
64
- ),
33
+ bulletActiveClass: getUniqueClasses(paginationBulletActive, $paginationBullet),
34
+ bulletClass: $paginationBullet.attr("class"),
35
+ bulletElement: $paginationBullet.prop("tagName")?.toLowerCase() || "span", //FIXME - some issue here
36
+ clickable: parseAttr($this, ATTR_PAGINATION_CLICKABLE, false),
37
+ clickableClass: parseAttr($this, ATTR_PAGINATION_CLICKABLE_CLASS, "swiper-pagination-clickable"),
38
+ currentClass: parseAttr($this, ATTR_PAGINATION_CURRENT_CLASS, "swiper-pagination-current"),
39
+ dynamicBullets: parseAttr($this, ATTR_PAGINATION_DYNAMIC_BULLETS, "swiper-pagination-current"),
40
+ dynamicMainBullets: parseAttr($this, ATTR_PAGINATION_DYNAMIC_MAIN_BULLETS, 1),
41
+ el: $this.find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_PAGINATION}]`)[0],
42
+ enabled: parseAttr($this, ATTR_PAGINATION_ENABLED, null),
43
+ //formatFractionCurrent: null, //NOTE - not implemented
44
+ //formatFractionTotal: null, //NOTE - not implemented
45
+ hiddenClass: parseAttr($this, ATTR_PAGINATION_HIDDEN_CLASS, "swiper-pagination-hidden"),
46
+ hideOnClick: parseAttr($this, ATTR_PAGINATION_HIDE_ON_CLICK, true),
47
+ horizontalClass: parseAttr($this, ATTR_PAGINATION_HORIZONTAL_CLASS, "swiper-pagination-horizontal"),
48
+ lockClass: parseAttr($this, ATTR_NAVIGATION_LOCK_CLASS, "swiper-pagination-lock"),
49
+ modifierClass: parseAttr($this, ATTR_PAGINATION_MODIFIER_CLASS, "swiper-pagination-"),
50
+ paginationDisabledClass: parseAttr($this, ATTR_PAGINATION_PAGINATION_DISABLED_CLASS, "swiper-pagination-disabled"),
65
51
  progressbarFillClass: parseAttr(
66
52
  $this,
67
- 'pagination-progressbar-fill-class',
68
- 'swiper-pagination-progressbar-fill',
53
+ ATTR_PAGINATION_PROGRESSBAR_FILL_CLASS,
54
+ "swiper-pagination-progressbar-fill",
69
55
  ),
70
56
  progressbarOpposite: parseAttr(
71
57
  $this,
72
- 'pagination-progressbar-opposite',
73
- 'swiper-pagination-progressbar-opposite',
58
+ ATTR_PAGINATION_PROGRESSBAR_OPPOSITE,
59
+ "swiper-pagination-progressbar-opposite",
74
60
  ),
75
61
  renderBullet: customRenderBullet(),
76
62
  //renderCustom: null,
77
63
  //renderFraction: null,
78
64
  //renderProgressBar: null,
79
- totalClass: parseAttr(
80
- $this,
81
- 'pagination-total-class',
82
- 'swiper-pagination-total',
83
- ),
65
+ totalClass: parseAttr($this, ATTR_PAGINATION_TOTAL_CLASS, "swiper-pagination-total"),
84
66
  type: getPaginationType(),
85
- verticalClass: parseAttr(
86
- $this,
87
- 'pagination-vertical-class',
88
- 'swiper-pagination-vertical',
89
- ),
67
+ verticalClass: parseAttr($this, ATTR_PAGINATION_VERTICAL_CLASS, "swiper-pagination-vertical"),
90
68
  };
91
69
 
92
70
  // Custom pagination type rendering functions
93
71
  function customRenderBullet() {
94
72
  let renderBullet: RenderBulletFunction | null = null;
95
- if (paginationType === 'numberBullets') {
73
+ if (paginationType === "numberBullets") {
96
74
  renderBullet = function (index, className) {
97
75
  return `<span class="${className}">${index + 1}</span>`;
98
76
  };
99
77
  }
100
- if (paginationType === 'bullets') {
78
+ if (paginationType === "bullets") {
101
79
  renderBullet = function (index, className) {
102
80
  return `<span class="${className}"></span>`;
103
81
  };
@@ -107,12 +85,11 @@ export function paginationConfig($this: JQuery<HTMLElement>) {
107
85
 
108
86
  // Custom function to get extended pagination types
109
87
  function getPaginationType() {
110
- if (paginationType === 'numberBullets' || paginationType === 'bullets')
111
- return 'bullets';
112
- if (paginationType === 'fraction') return 'fraction';
113
- if (paginationType === 'progressbar') return 'progressbar';
114
- if (paginationType === 'custom') return 'custom';
115
- else return 'bullets'; // default
88
+ if (paginationType === "numberBullets" || paginationType === "bullets") return "bullets";
89
+ if (paginationType === "fraction") return "fraction";
90
+ if (paginationType === "progressbar") return "progressbar";
91
+ if (paginationType === "custom") return "custom";
92
+ else return "bullets"; // default
116
93
  }
117
94
  }
118
95
 
@@ -1,34 +1,45 @@
1
- import { parseAttr } from '../util';
1
+ import {
2
+ ATTR_AUTOPLAY,
3
+ ATTR_DELAY,
4
+ ATTR_DISABLE_ON_INTERACTION,
5
+ ATTR_FREE_MODE_ENABLED,
6
+ ATTR_FREE_MODE_MINIMUM_VELOCITY,
7
+ ATTR_FREE_MODE_MOMENTUM,
8
+ ATTR_FREE_MODE_MOMENTUM_BOUNCE,
9
+ ATTR_FREE_MODE_MOMENTUM_BOUNCE_RATIO,
10
+ ATTR_FREE_MODE_MOMENTUM_RATIO,
11
+ ATTR_FREE_MODE_MOMENTUM_VELOCITY_RATIO,
12
+ ATTR_FREE_MODE_STICKY,
13
+ ATTR_PAUSE_ON_MOUSE_ENTER,
14
+ ATTR_REVERSE_DIRECTION,
15
+ ATTR_SMOOTH_AUTOPLAY,
16
+ ATTR_STOP_ON_LAST_SLIDE,
17
+ } from "lib/attributes";
18
+ import { parseAttr } from "../util";
2
19
 
3
20
  export function autoplayConfig($this: JQuery<HTMLElement>) {
4
- const autoplayMode = parseAttr($this, 'autoplay-mode', false);
21
+ const autoplayMode = parseAttr($this, ATTR_AUTOPLAY, false);
5
22
  if (!autoplayMode) return null;
6
23
  // Add CSS for Smooth Autoplay
7
- $("[smooth-autoplay='true']")
8
- .find('.swiper-wrapper')
9
- .css('transition-timing-function', 'linear');
24
+ $(`[${ATTR_SMOOTH_AUTOPLAY}='true']`).find(".swiper-wrapper").css("transition-timing-function", "linear");
10
25
  return {
11
- delay: parseAttr($this, 'delay', 3000),
12
- disableOnInteraction: parseAttr($this, 'disable-on-interaction', false), // documentation says default is true, doesn't appear to be correct
13
- reverseDirection: parseAttr($this, 'reverse-direction', false),
14
- pauseOnMouseEnter: parseAttr($this, 'pause-on-mouse-enter', false),
15
- stopOnLastSlide: parseAttr($this, 'stop-on-last-slide', false),
26
+ delay: parseAttr($this, ATTR_DELAY, 3000),
27
+ disableOnInteraction: parseAttr($this, ATTR_DISABLE_ON_INTERACTION, false), // documentation says default is true, doesn't appear to be correct
28
+ reverseDirection: parseAttr($this, ATTR_REVERSE_DIRECTION, false),
29
+ pauseOnMouseEnter: parseAttr($this, ATTR_PAUSE_ON_MOUSE_ENTER, false),
30
+ stopOnLastSlide: parseAttr($this, ATTR_STOP_ON_LAST_SLIDE, false),
16
31
  };
17
32
  }
18
33
 
19
34
  export function freeModeConfig($this: JQuery<HTMLElement>) {
20
35
  return {
21
- enabled: parseAttr($this, 'free-mode-enabled', false),
22
- minimumVelocity: parseAttr($this, 'free-mode-minimum-velocity', 0.02),
23
- momentum: parseAttr($this, 'free-mode-momentum', true),
24
- momentumBounce: parseAttr($this, 'free-mode-momentum-bounce', true),
25
- momentumBounceRatio: parseAttr($this, 'free-mode-momentum-bounce-ratio', 1),
26
- momentumRatio: parseAttr($this, 'free-mode-momentum-ratio', 1),
27
- momentumVelocityRatio: parseAttr(
28
- $this,
29
- 'free-mode-momentum-velocity-ratio',
30
- 1,
31
- ),
32
- sticky: parseAttr($this, 'free-mode-sticky', false),
36
+ enabled: parseAttr($this, ATTR_FREE_MODE_ENABLED, false),
37
+ minimumVelocity: parseAttr($this, ATTR_FREE_MODE_MINIMUM_VELOCITY, 0.02),
38
+ momentum: parseAttr($this, ATTR_FREE_MODE_MOMENTUM, true),
39
+ momentumBounce: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_BOUNCE, true),
40
+ momentumBounceRatio: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_BOUNCE_RATIO, 1),
41
+ momentumRatio: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_RATIO, 1),
42
+ momentumVelocityRatio: parseAttr($this, ATTR_FREE_MODE_MOMENTUM_VELOCITY_RATIO, 1),
43
+ sticky: parseAttr($this, ATTR_FREE_MODE_STICKY, false),
33
44
  };
34
45
  }
@@ -1,36 +1,34 @@
1
- import { parseAttr } from '../util';
1
+ import {
2
+ ATTR_SCROLLBAR,
3
+ ATTR_SCROLLBAR_DRAG,
4
+ ATTR_SCROLLBAR_DRAG_SIZE,
5
+ ATTR_SCROLLBAR_DRAGGABLE,
6
+ ATTR_SCROLLBAR_ENABLED,
7
+ ATTR_SCROLLBAR_HIDE,
8
+ ATTR_SCROLLBAR_HORIZONTAL_CLASS,
9
+ ATTR_SCROLLBAR_LOCK_CLASS,
10
+ ATTR_SCROLLBAR_SCROLLBAR_DISABLED_CLASS,
11
+ ATTR_SCROLLBAR_SNAP_ON_RELEASE,
12
+ ATTR_SCROLLBAR_VERTICAL_CLASS,
13
+ ATTR_WATERFALL_ELEMENT,
14
+ } from "lib/attributes";
15
+ import { parseAttr } from "../util";
2
16
 
3
17
  export function scrollbarConfig($this: JQuery<HTMLElement>) {
4
- const $scrollbar = $this.find("[waterfall-el='scrollbar']");
5
- const $scrollbarDrag = $($scrollbar).find("[waterfall-el='scrollbar-drag']");
18
+ const $scrollbar = $this.find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SCROLLBAR}]`);
19
+ const $scrollbarDrag = $($scrollbar).find(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SCROLLBAR_DRAG}]`);
6
20
 
7
21
  return {
8
- dragClass: $scrollbarDrag.attr('class'),
9
- dragSize: parseAttr($this, 'scrollbar-drag-size', 'auto'),
10
- draggable: parseAttr($this, 'scrollbar-draggable', false),
22
+ dragClass: $scrollbarDrag.attr("class"),
23
+ dragSize: parseAttr($this, ATTR_SCROLLBAR_DRAG_SIZE, "auto"),
24
+ draggable: parseAttr($this, ATTR_SCROLLBAR_DRAGGABLE, false),
11
25
  el: $scrollbar[0],
12
- enabled: parseAttr($this, 'scrollbar-enabled', null),
13
- hide: parseAttr($this, 'scrollbar-hide', true),
14
- horizontalClass: parseAttr(
15
- $this,
16
- 'scrollbar-horizontal-class',
17
- 'swiper-scrollbar-horizontal',
18
- ),
19
- lockClass: parseAttr(
20
- $this,
21
- 'scrollbar-lock-class',
22
- 'swiper-scrollbar-lock',
23
- ),
24
- scrollbarDisabledClass: parseAttr(
25
- $this,
26
- 'scrollbar-disabled-class',
27
- 'swiper-scrollbar-disabled',
28
- ),
29
- snapOnRelease: parseAttr($this, 'snap-on-release', true), // documentation says default is false, but is lying lmao
30
- verticalClass: parseAttr(
31
- $this,
32
- 'scrollbar-vertical-class',
33
- 'swiper-scrollbar-vertical',
34
- ),
26
+ enabled: parseAttr($this, ATTR_SCROLLBAR_ENABLED, null),
27
+ hide: parseAttr($this, ATTR_SCROLLBAR_HIDE, true),
28
+ horizontalClass: parseAttr($this, ATTR_SCROLLBAR_HORIZONTAL_CLASS, "swiper-scrollbar-horizontal"),
29
+ lockClass: parseAttr($this, ATTR_SCROLLBAR_LOCK_CLASS, "swiper-scrollbar-lock"),
30
+ scrollbarDisabledClass: parseAttr($this, ATTR_SCROLLBAR_SCROLLBAR_DISABLED_CLASS, "swiper-scrollbar-disabled"),
31
+ snapOnRelease: parseAttr($this, ATTR_SCROLLBAR_SNAP_ON_RELEASE, true), //NOTE documentation says default is false, but is lying lmao
32
+ verticalClass: parseAttr($this, ATTR_SCROLLBAR_VERTICAL_CLASS, "swiper-scrollbar-vertical"),
35
33
  };
36
34
  }
@@ -1,10 +1,12 @@
1
+ import { ATTR_SLIDE_COUNT, ATTR_WATERFALL_ELEMENT } from "lib/attributes";
2
+
1
3
  /**
2
4
  * Creates a Slide Count element that displays the current slide number.
3
5
  */
4
6
  export function initSlideCount() {
5
- document.querySelectorAll('.swiper-wrapper').forEach((swiperWrapper) => {
6
- swiperWrapper.querySelectorAll('.swiper-slide').forEach((slide, index) => {
7
- const countEl = slide.querySelector('[waterfall-el="slide-count"]');
7
+ document.querySelectorAll(".swiper-wrapper").forEach((swiperWrapper) => {
8
+ swiperWrapper.querySelectorAll(".swiper-slide").forEach((slide, index) => {
9
+ const countEl = slide.querySelector(`[${ATTR_WATERFALL_ELEMENT}=${ATTR_SLIDE_COUNT}]`);
8
10
  if (countEl) {
9
11
  countEl.textContent = (index + 1).toString();
10
12
  }
@@ -1,20 +1,22 @@
1
- import { ThumbsOptions } from 'swiper/types';
2
- import { parseAttr, parseBoolean, parseNumber, parseString } from '../util';
3
- import { Waterfall } from 'types/waterfall';
1
+ import { ThumbsOptions } from "swiper/types";
2
+ import { parseAttr, parseBoolean, parseNumber, parseString } from "../util";
3
+ import { Waterfall } from "types/waterfall";
4
+ import {
5
+ ATTR_THUMBS_AUTO_SCROLL_OFFSET,
6
+ ATTR_THUMBS_CONTAINER_CLASS,
7
+ ATTR_THUMBS_MULTIPLE_ACTIVE_THUMBS,
8
+ ATTR_THUMBS_NAME,
9
+ ATTR_THUMBS_SLIDE_THUMB_ACTIVE_CLASS,
10
+ } from "lib/attributes";
4
11
 
5
- function getThumbsSwiper(
6
- el: JQuery<HTMLElement>,
7
- sliders: Waterfall[],
8
- ): Waterfall | null {
9
- const sliderName = parseAttr(el, 'thumbs-name', null);
12
+ function getThumbsSwiper(el: JQuery<HTMLElement>, sliders: Waterfall[]): Waterfall | null {
13
+ const sliderName = parseAttr(el, ATTR_THUMBS_NAME, null);
10
14
  if (sliderName === null) return null;
11
15
 
12
- const foundSlider = sliders.find(
13
- (slider: Waterfall) => slider.name === sliderName,
14
- );
16
+ const foundSlider = sliders.find((slider: Waterfall) => slider.name === sliderName);
15
17
 
16
18
  if (foundSlider) return foundSlider;
17
- console.log('A matching thumbs waterfall was not found for ', sliderName);
19
+ console.log("A matching thumbs waterfall was not found for ", sliderName);
18
20
  return null; // Return null if no match is found
19
21
  }
20
22
 
@@ -23,19 +25,11 @@ export function thumbsConfig(el: JQuery<HTMLElement>, swipers: Waterfall[]) {
23
25
  if (!waterfall) return;
24
26
 
25
27
  let config: ThumbsOptions = {
26
- autoScrollOffset: parseNumber(el, 'auto-scroll-offset', 0),
27
- multipleActiveThumbs: parseBoolean(el, 'multiple-active-thumbs', false),
28
- slideThumbActiveClass: parseString(
29
- el,
30
- 'slide-thumb-active-class',
31
- 'swiper-slide-thumb-active',
32
- ),
28
+ autoScrollOffset: parseNumber(el, ATTR_THUMBS_AUTO_SCROLL_OFFSET, 0),
29
+ multipleActiveThumbs: parseBoolean(el, ATTR_THUMBS_MULTIPLE_ACTIVE_THUMBS, false),
30
+ slideThumbActiveClass: parseString(el, ATTR_THUMBS_SLIDE_THUMB_ACTIVE_CLASS, "swiper-slide-thumb-active"),
33
31
  swiper: waterfall.swiper,
34
- thumbsContainerClass: parseString(
35
- el,
36
- 'thumbs-container-class',
37
- 'swiper-thumbs',
38
- ),
32
+ thumbsContainerClass: parseString(el, ATTR_THUMBS_CONTAINER_CLASS, "swiper-thumbs"),
39
33
  };
40
34
  return config;
41
35
  }
@@ -1,21 +1,22 @@
1
- import { parseAttr } from '../util';
1
+ import {
2
+ ATTR_ZOOM_CONTAINER_CLASS,
3
+ ATTR_ZOOM_LIMIT_TO_ORIGINAL_SIZE,
4
+ ATTR_ZOOM_MAX_RATIO,
5
+ ATTR_ZOOM_MIN_RATIO,
6
+ ATTR_ZOOM_PAN_ON_MOUSE_MOVE,
7
+ ATTR_ZOOM_TOGGLE,
8
+ ATTR_ZOOMED_SLIDE_CLASS,
9
+ } from "lib/attributes";
10
+ import { parseAttr } from "../util";
2
11
 
3
12
  export function zoomConfig($el: JQuery<HTMLElement>) {
4
13
  return {
5
- containerClass: parseAttr(
6
- $el,
7
- 'zoom-container-class',
8
- 'swiper-zoom-container',
9
- ),
10
- limitToOriginalSize: parseAttr($el, 'zoom-limit-to-original-size', false),
11
- maxRatio: parseAttr($el, 'zoom-max-ratio', 3),
12
- minRatio: parseAttr($el, 'zoom-min-ratio', 1),
13
- panOnMouseMove: parseAttr($el, 'zoom-pan-on-mouse-move', false),
14
- toggle: parseAttr($el, 'zoom-toggle', true),
15
- zoomedSlideClass: parseAttr(
16
- $el,
17
- 'zoomed-slide-class',
18
- 'swiper-slide-zoomed',
19
- ),
14
+ containerClass: parseAttr($el, ATTR_ZOOM_CONTAINER_CLASS, "swiper-zoom-container"),
15
+ limitToOriginalSize: parseAttr($el, ATTR_ZOOM_LIMIT_TO_ORIGINAL_SIZE, false),
16
+ maxRatio: parseAttr($el, ATTR_ZOOM_MAX_RATIO, 3),
17
+ minRatio: parseAttr($el, ATTR_ZOOM_MIN_RATIO, 1),
18
+ panOnMouseMove: parseAttr($el, ATTR_ZOOM_PAN_ON_MOUSE_MOVE, false),
19
+ toggle: parseAttr($el, ATTR_ZOOM_TOGGLE, true),
20
+ zoomedSlideClass: parseAttr($el, ATTR_ZOOMED_SLIDE_CLASS, "swiper-slide-zoomed"),
20
21
  };
21
22
  }
package/src/waterfall.ts CHANGED
@@ -19,31 +19,41 @@ import { SwiperOptions } from "swiper/types";
19
19
  import { accessibilityConfig } from "./modules/accessibility";
20
20
  import { addSlides } from "./modules/manipulation";
21
21
 
22
+ import {
23
+ ATTR_WATERFALL_PRELOAD,
24
+ ATTR_WATERFALL,
25
+ ATTR_WATERFALL_POSTLOAD,
26
+ ATTR_DEBUG_MODE,
27
+ ATTR_ADVANCED_DEBUG_MODE,
28
+ ATTR_PLAYBACK_MODE,
29
+ ATTR_THUMBS,
30
+ } from "./lib/attributes";
31
+
22
32
  console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
23
33
 
24
34
  const waterfalls: Waterfall[] = [];
25
35
  window.waterfalls = waterfalls;
26
36
 
27
37
  // Initialize Thumb Sliders first
28
- $('[waterfall][waterfall-preload="true"]').each((index, el) => initConfig(el, index));
38
+ $(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_PRELOAD}="true"]`).each((index, el) => initConfig(el, index));
29
39
 
30
40
  // Initialize all other sliders
31
- $("[waterfall]")
32
- .not('[waterfall-preload="true"]')
33
- .not('[waterfall-postload="true"]')
41
+ $(`[${ATTR_WATERFALL}]`)
42
+ .not(`[${ATTR_WATERFALL_PRELOAD}="true"]`)
43
+ .not(`[${ATTR_WATERFALL_POSTLOAD}="true"]`)
34
44
  .each((index, el) => initConfig(el, index));
35
45
 
36
- $('[waterfall][waterfall-postload="true"]').each((index, el) => initConfig(el, index));
46
+ $(`[${ATTR_WATERFALL}][${ATTR_WATERFALL_POSTLOAD}="true"]`).each((index, el) => initConfig(el, index));
37
47
 
38
48
  function initConfig(el: HTMLElement, index: number) {
39
49
  {
40
50
  const $this = $(el);
41
51
 
42
- const name = parseString($this, "waterfall", `Swiper ${index}`);
52
+ const name = parseString($this, ATTR_WATERFALL, `Swiper ${index}`);
43
53
  if (!name) return;
44
54
 
45
- const debug = Boolean(parseAttr($this, "debug-mode", false) || false);
46
- const debugAdvanced = Boolean(parseAttr($this, "advanced-debug-mode", false) || false);
55
+ const debug = Boolean(parseAttr($this, ATTR_DEBUG_MODE, false) || false);
56
+ const debugAdvanced = Boolean(parseAttr($this, ATTR_ADVANCED_DEBUG_MODE, false) || false);
47
57
  console.log(`Initializing Waterfall: ${name} ${debug ? `[${debugAdvanced ? "ADVANCED " : ""}DEBUG]` : ""}`);
48
58
 
49
59
  // GENERAL CONFIG
@@ -53,7 +63,7 @@ function initConfig(el: HTMLElement, index: number) {
53
63
  swiperConfig.breakpoints = breakpointsConfig($this);
54
64
 
55
65
  // PLAYBACK
56
- const playbackMode = parseAttr($this, "playback-mode", "none");
66
+ const playbackMode = parseAttr($this, ATTR_PLAYBACK_MODE, "none");
57
67
  if (playbackMode === "loop") swiperConfig.loop = true;
58
68
  if (playbackMode === "rewind") swiperConfig.rewind = true;
59
69
  if (playbackMode === "none") {
@@ -66,11 +76,11 @@ function initConfig(el: HTMLElement, index: number) {
66
76
  swiperConfig.navigation = navigationConfig($this, name);
67
77
 
68
78
  // PAGINATION
69
- let pagination = $this.find("[waterfall-el='pagination-bullet']").length;
79
+ let pagination = $this.find(`[${"waterfall-el='pagination-bullet'"}]`).length;
70
80
  if (pagination) swiperConfig.pagination = paginationConfig($this);
71
81
 
72
82
  // SCROLLBAR
73
- const $scrollbar = $this.find("[waterfall-el='scrollbar']");
83
+ const $scrollbar = $this.find(`[${"waterfall-el='scrollbar'"}]`);
74
84
  if ($scrollbar) swiperConfig.scrollbar = scrollbarConfig($this);
75
85
 
76
86
  // EFFECT
@@ -87,7 +97,7 @@ function initConfig(el: HTMLElement, index: number) {
87
97
  swiperConfig.grid = gridConfig($this);
88
98
 
89
99
  // THUMBS
90
- const isThumbs = parseAttr($this, "waterfall-thumbs", null) === true;
100
+ const isThumbs = parseAttr($this, ATTR_THUMBS, null) === true;
91
101
  if (!isThumbs) swiperConfig.thumbs = thumbsConfig($this, waterfalls);
92
102
 
93
103
  // ZOOM - NOT IMPLEMENTED
@@ -140,5 +150,3 @@ initSlideCount();
140
150
  document.addEventListener("DOMContentLoaded", function () {
141
151
  addSlides();
142
152
  });
143
-
144
- export * from './lib/attributes';
package/tsconfig.json CHANGED
@@ -12,6 +12,9 @@
12
12
  "skipLibCheck": true,
13
13
  "outDir": "package/dist",
14
14
  "baseUrl": "./src",
15
+ "paths": {
16
+ "lib/*": ["./lib/*"]
17
+ },
15
18
  "resolveJsonModule": true,
16
19
  "sourceMap": true,
17
20
  "types": ["jquery"]
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({