well-waterfall 1.1.10 → 1.2.0

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,7 +1,7 @@
1
1
  {
2
2
  "name": "well-waterfall",
3
- "version": "1.1.10",
4
- "description": "An attribute-based wrapper of SwiperJS for Webflow",
3
+ "version": "1.2.0",
4
+ "description": "Create Swipers in Webflow with attributes",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
package/src/index.ts CHANGED
@@ -68,7 +68,7 @@ function initConfig(el: HTMLElement, index: number) {
68
68
  const debug = Boolean(parseBoolean(el, ATTR_DEBUG_MODE, false) || false);
69
69
  if (debug) console.warn(`Initializing Waterfall: ${name}`);
70
70
 
71
- let swiperConfig: any = {};
71
+ let swiperConfig: SwiperOptions = {};
72
72
 
73
73
  generalConfig(swiperConfig, el);
74
74
  breakpointsConfig(swiperConfig, el);
@@ -206,6 +206,7 @@ export const ATTR_PAGINATION_MODIFIER_CLASS = "waterfall-pagination-modifier-cla
206
206
  export const ATTR_PAGINATION_PAGINATION_DISABLED_CLASS = "waterfall-pagination-pagination-disabled-class";
207
207
  export const ATTR_PAGINATION_PROGRESSBAR_FILL_CLASS = "waterfall-pagination-progressbar-fill-class";
208
208
  export const ATTR_PAGINATION_PROGRESSBAR_OPPOSITE = "waterfall-pagination-progressbar-opposite";
209
+ export const ATTR_PAGINATION_PROGRESSBAR_OPPOSITE_CLASS = "waterfall-pagination-progressbar-opposite-class";
209
210
  export const ATTR_PAGINATION_TOTAL_CLASS = "waterfall-pagination-total-class";
210
211
  export const ATTR_PAGINATION_VERTICAL_CLASS = "waterfall-pagination-vertical-class";
211
212
  // Playback
@@ -1,4 +1,4 @@
1
- import { A11yOptions } from "swiper/types";
1
+ import { A11yOptions, SwiperOptions } from "swiper/types";
2
2
  import { parseBoolean, parseString } from "../util";
3
3
  import {
4
4
  ATTR_A11Y_CONTAINER_MESSAGE,
@@ -18,7 +18,7 @@ import {
18
18
  ATTR_A11Y_SLIDE_ROLE,
19
19
  } from "../lib/attributes";
20
20
 
21
- export function accessibilityConfig(config: any, el: HTMLElement) {
21
+ export function accessibilityConfig(config: SwiperOptions, el: HTMLElement) {
22
22
  config.a11y = {
23
23
  containerMessage: parseString(el, ATTR_A11Y_CONTAINER_MESSAGE, ""),
24
24
  containerRole: parseString(el, ATTR_A11Y_CONTAINER_ROLE, ""),
@@ -14,8 +14,9 @@ import {
14
14
  ATTR_USER_AGENT,
15
15
  } from "lib/attributes";
16
16
  import { parseBoolean, parseNumber, parseString } from "../util";
17
+ import { SwiperOptions } from "swiper/types";
17
18
 
18
- export default function advancedConfig(config: any, el: HTMLElement) {
19
+ export default function advancedConfig(config: SwiperOptions, el: HTMLElement) {
19
20
  // NOTE Not using Create Elements because they should be created in Webflow instead
20
21
  config.createElements = parseBoolean(el, ATTR_CREATE_ELEMENTS, false);
21
22
  // NOTE This option breaks several properties when used
@@ -21,8 +21,9 @@ import {
21
21
  ATTR_XLARGE_SPACE_BETWEEN,
22
22
  ATTR_BREAKPOINTS_BASE,
23
23
  } from "../lib/attributes";
24
+ import { SwiperOptions } from "swiper/types";
24
25
 
25
- export function breakpointsConfig(config: any, el: HTMLElement) {
26
+ export function breakpointsConfig(config: SwiperOptions, el: HTMLElement) {
26
27
  config.breakpointsBase = parseString(el, ATTR_BREAKPOINTS_BASE, "window");
27
28
 
28
29
  config.breakpoints = {
@@ -1,9 +1,10 @@
1
1
  import { Waterfall } from "types/waterfall";
2
- import { getSwipersByName, parseBoolean, parseString } from "../util";
2
+ import { getSwipersByName, parseAny, parseBoolean, parseString } from "../util";
3
3
  import Swiper from "swiper";
4
4
  import { ATTR_CONTROLLER, ATTR_CONTROLLER_BY, ATTR_CONTROLLER_INVERSE } from "../lib/attributes";
5
+ import { SwiperOptions } from "swiper/types";
5
6
 
6
- export function controllerConfig(config: any, el: HTMLElement, waterfalls: Waterfall[], debug: boolean) {
7
+ export function controllerConfig(config: SwiperOptions, el: HTMLElement, waterfalls: Waterfall[], debug: boolean) {
7
8
  const controllerSelector = parseString(el, ATTR_CONTROLLER, "");
8
9
  if (!controllerSelector) return;
9
10
  const swipers: Swiper[] = getSwipersByName(waterfalls, controllerSelector, debug);
@@ -14,7 +15,7 @@ export function controllerConfig(config: any, el: HTMLElement, waterfalls: Water
14
15
  }
15
16
 
16
17
  config.controller = {
17
- by: parseString(el, ATTR_CONTROLLER_BY, "slide"),
18
+ by: parseAny(el, ATTR_CONTROLLER_BY, "slide"),
18
19
  control: swipers,
19
20
  inverse: parseBoolean(el, ATTR_CONTROLLER_INVERSE, false),
20
21
  };
@@ -18,13 +18,14 @@ import {
18
18
  ATTR_EFFECT,
19
19
  } from "lib/attributes";
20
20
  import { parseBoolean, parseNumber, parseString } from "../util";
21
+ import { SwiperOptions } from "swiper/types";
21
22
 
22
- export function effectConfig(config: any, el: HTMLElement) {
23
+ export function effectConfig(config: SwiperOptions, el: HTMLElement) {
23
24
  const effect = parseString(el, ATTR_EFFECT, "slide");
24
25
  config.effect = effect;
25
26
 
26
27
  if (effect === "fade") {
27
- config.fadeEffect = { crossFade: "true" };
28
+ config.fadeEffect = { crossFade: true };
28
29
  } else if (effect === "coverflow") {
29
30
  config.coverflowEffect = {
30
31
  depth: parseNumber(el, ATTR_COVERFLOW_DEPTH, 100),
@@ -9,8 +9,9 @@ import {
9
9
  ATTR_FREE_MODE_STICKY,
10
10
  } from "lib/attributes";
11
11
  import { parseBoolean, parseNumber } from "../util";
12
+ import { SwiperOptions } from "swiper/types";
12
13
 
13
- export function freeModeConfig(config: any, el: HTMLElement) {
14
+ export function freeModeConfig(config: SwiperOptions, el: HTMLElement) {
14
15
  config.freeMode = {
15
16
  enabled: parseBoolean(el, ATTR_FREE_MODE_ENABLED, false),
16
17
  minimumVelocity: parseNumber(el, ATTR_FREE_MODE_MINIMUM_VELOCITY, 0.02),
@@ -15,8 +15,9 @@ import {
15
15
  ATTR_WRAPPER_CLASS,
16
16
  } from "lib/attributes";
17
17
  import { parseBoolean, parseNumber, parseString } from "../util";
18
+ import { SwiperOptions } from "swiper/types";
18
19
 
19
- export function generalConfig(config: any, el: HTMLElement) {
20
+ export function generalConfig(config: SwiperOptions, el: HTMLElement) {
20
21
  config.containerModifierClass = parseString(el, ATTR_CONTAINER_MODIFIER_CLASS, "swiper-");
21
22
  config.initialSlide = parseNumber(el, ATTR_INITIAL_SLIDE, 0);
22
23
  config.nested = parseBoolean(el, ATTR_NESTED, false);
@@ -7,8 +7,9 @@ import {
7
7
  ATTR_HISTORY_ROOT,
8
8
  } from "lib/attributes";
9
9
  import { parseBoolean, parseString } from "../util";
10
+ import { SwiperOptions } from "swiper/types";
10
11
 
11
- export function hashNavigationConfig(config: any, el: HTMLElement) {
12
+ export function hashNavigationConfig(config: SwiperOptions, el: HTMLElement) {
12
13
  config.hashNavigation = {
13
14
  //getSlideIndex
14
15
  replaceState: parseBoolean(el, ATTR_HASH_REPLACE_STATE, false),
@@ -16,7 +17,7 @@ export function hashNavigationConfig(config: any, el: HTMLElement) {
16
17
  };
17
18
  }
18
19
 
19
- export function historyNavigationConfig(config: any, el: HTMLElement) {
20
+ export function historyNavigationConfig(config: SwiperOptions, el: HTMLElement) {
20
21
  config.history = {
21
22
  keepQuery: parseBoolean(el, ATTR_HISTORY_KEEP_QUERY, false),
22
23
  key: parseString(el, ATTR_HISTORY_KEY, "slides"),
@@ -1,7 +1,8 @@
1
1
  import { ATTR_KEYBOARD_ENABLED, ATTR_KEYBOARD_ONLY_IN_VIEWPORT, ATTR_KEYBOARD_PAGE_UP_DOWN } from "lib/attributes";
2
2
  import { parseBoolean } from "../util";
3
+ import { SwiperOptions } from "swiper/types";
3
4
 
4
- export function keyboardConfig(config: any, el: HTMLElement) {
5
+ export function keyboardConfig(config: SwiperOptions, el: HTMLElement) {
5
6
  config.keyboard = {
6
7
  enabled: parseBoolean(el, ATTR_KEYBOARD_ENABLED, false),
7
8
  onlyInViewport: parseBoolean(el, ATTR_KEYBOARD_ONLY_IN_VIEWPORT, true),
@@ -15,15 +15,16 @@ import {
15
15
  ATTR_SPACE_BETWEEN,
16
16
  ATTR_WIDTH,
17
17
  } from "lib/attributes";
18
- import { parseBoolean, parseNumber, parseString } from "../util";
18
+ import { parseAny, parseBoolean, parseNumber, parseString } from "../util";
19
+ import { SwiperOptions } from "swiper/types";
19
20
 
20
- export function layoutConfig(config: any, el: HTMLElement) {
21
+ export function layoutConfig(config: SwiperOptions, el: HTMLElement) {
21
22
  config.autoHeight = parseBoolean(el, ATTR_AUTO_HEIGHT, false);
22
23
  config.centerInsufficientSlides = parseBoolean(el, ATTR_CENTER_INSUFFICIENT_SLIDES, false);
23
24
  config.centeredSlides = parseBoolean(el, ATTR_CENTERED_SLIDES, false);
24
- config.direction = parseString(el, ATTR_DIRECTION, "horizontal");
25
+ config.direction = parseAny(el, ATTR_DIRECTION, "horizontal");
25
26
  config.grid = {
26
- fill: parseString(el, ATTR_GRID_FILL, "column"),
27
+ fill: parseAny(el, ATTR_GRID_FILL, "column"),
27
28
  rows: parseNumber(el, ATTR_GRID_ROWS, 1),
28
29
  };
29
30
  config.height = parseNumber(el, ATTR_HEIGHT);
@@ -1,7 +1,8 @@
1
1
  import { ATTR_LAZY_PRELOAD_PREV_NEXT, ATTR_LAZY_PRELOADER_CLASS } from "lib/attributes";
2
2
  import { parseNumber, parseString } from "../util";
3
+ import { SwiperOptions } from "swiper/types";
3
4
 
4
- export default function lazyLoadConfig(config: any, el: HTMLElement) {
5
+ export default function lazyLoadConfig(config: SwiperOptions, el: HTMLElement) {
5
6
  config.lazyPreloadPrevNext = parseNumber(el, ATTR_LAZY_PRELOAD_PREV_NEXT, 0);
6
7
  config.lazyPreloaderClass = parseString(el, ATTR_LAZY_PRELOADER_CLASS, "swiper-lazy-preloader");
7
8
  }
@@ -10,14 +10,15 @@ import {
10
10
  ATTR_MOUSE_THRESHOLD_TIME,
11
11
  } from "lib/attributes";
12
12
  import { parseBoolean, parseNumber, parseString } from "../util";
13
+ import { SwiperOptions } from "swiper/types";
13
14
 
14
- export function mouseConfig(config: any, el: HTMLElement) {
15
+ export function mouseConfig(config: SwiperOptions, el: HTMLElement) {
15
16
  config.mousewheel = {
16
17
  enabled: parseBoolean(el, ATTR_MOUSE_ENABLED, false),
17
18
  eventsTarget: parseString(el, ATTR_MOUSE_EVENTS_TARGET, "container"),
18
19
  forceToAxis: parseBoolean(el, ATTR_MOUSE_FORCE_TO_AXIS, false),
19
20
  invert: parseBoolean(el, ATTR_MOUSE_INVERT, false),
20
- noMouseWheelClass: parseString(el, ATTR_MOUSE_NO_MOUSE_WHEEL_CLASS, "swiper-no-mousewheel"),
21
+ noMousewheelClass: parseString(el, ATTR_MOUSE_NO_MOUSE_WHEEL_CLASS, "swiper-no-mousewheel"),
21
22
  releaseOnEdges: parseBoolean(el, ATTR_MOUSE_RELEASE_ON_EDGES, false),
22
23
  sensitivity: parseNumber(el, ATTR_MOUSE_SENSITIVITY, 1),
23
24
  thresholdDelta: parseNumber(el, ATTR_MOUSE_THRESHOLD_DELTA),
@@ -11,21 +11,18 @@ import {
11
11
  } from "lib/attributes";
12
12
  import { ATTR_WATERFALL_ELEMENT, EL_NAVIGATION_NEXT, EL_NAVIGATION_PREV } from "lib/elements";
13
13
  import { parseBoolean, parseString } from "../util";
14
+ import { SwiperOptions } from "swiper/types";
14
15
 
15
- export function navigationConfig(config: any, el: HTMLElement, name: string) {
16
+ export function navigationConfig(config: SwiperOptions, el: HTMLElement, name: string) {
16
17
  config.allowSlideNext = parseBoolean(el, ATTR_ALLOW_SLIDE_NEXT, true);
17
18
  config.allowSlidePrev = parseBoolean(el, ATTR_ALLOW_SLIDE_PREV, true);
18
- config.disabledClass = parseString(el, ATTR_NAVIGATION_DISABLED_CLASS, "swiper-button-disabled");
19
- config.enabled = parseBoolean(el, ATTR_NAVIGATION_ENABLED);
20
- config.hiddenClass = parseString(el, ATTR_NAVIGATION_HIDDEN_CLASS, "swiper-button-hidden");
21
- config.hideOnClick = parseBoolean(el, ATTR_NAVIGATION_HIDE_ON_CLICK, false);
22
- config.lockClass = parseString(el, ATTR_NAVIGATION_LOCK_CLASS, "swiper-button-lock");
23
- config.navigationDisabledClass = parseString(
24
- el,
25
- ATTR_NAVIGATION_NAVIGATION_DISABLED_CLASS,
26
- "swiper-navigation-disabled",
27
- );
28
19
  config.navigation = {
20
+ disabledClass: parseString(el, ATTR_NAVIGATION_DISABLED_CLASS, "swiper-button-disabled"),
21
+ enabled: parseBoolean(el, ATTR_NAVIGATION_ENABLED),
22
+ hiddenClass: parseString(el, ATTR_NAVIGATION_HIDDEN_CLASS, "swiper-button-hidden"),
23
+ hideOnClick: parseBoolean(el, ATTR_NAVIGATION_HIDE_ON_CLICK, false),
24
+ lockClass: parseString(el, ATTR_NAVIGATION_LOCK_CLASS, "swiper-button-lock"),
25
+ navigationDisabledClass: parseString(el, ATTR_NAVIGATION_NAVIGATION_DISABLED_CLASS, "swiper-navigation-disabled"),
29
26
  nextEl: `[${ATTR_WATERFALL}='${name}'] [${ATTR_WATERFALL_ELEMENT}=${EL_NAVIGATION_NEXT}]`,
30
27
  prevEl: `[${ATTR_WATERFALL}='${name}'] [${ATTR_WATERFALL_ELEMENT}=${EL_NAVIGATION_PREV}]`,
31
28
  };
@@ -8,8 +8,9 @@ import {
8
8
  ATTR_WATCH_SLIDES_PROGRESS,
9
9
  } from "lib/attributes";
10
10
  import { parseBoolean } from "../util";
11
+ import { SwiperOptions } from "swiper/types";
11
12
 
12
- export default function observerConfig(config: any, el: HTMLElement) {
13
+ export default function observerConfig(config: SwiperOptions, el: HTMLElement) {
13
14
  config.observeParents = parseBoolean(el, ATTR_OBSERVE_SLIDE_PARENTS, false);
14
15
  config.observeSlideChildren = parseBoolean(el, ATTR_OBSERVE_SLIDE_CHILDREN, false);
15
16
  config.observer = parseBoolean(el, ATTR_OBSERVER, false);
@@ -14,14 +14,16 @@ import {
14
14
  ATTR_PAGINATION_PAGINATION_DISABLED_CLASS,
15
15
  ATTR_PAGINATION_PROGRESSBAR_FILL_CLASS,
16
16
  ATTR_PAGINATION_PROGRESSBAR_OPPOSITE,
17
+ ATTR_PAGINATION_PROGRESSBAR_OPPOSITE_CLASS,
17
18
  ATTR_PAGINATION_TOTAL_CLASS,
18
19
  ATTR_PAGINATION_TYPE,
19
20
  ATTR_PAGINATION_VERTICAL_CLASS,
20
21
  } from "lib/attributes";
21
- import { getUniqueClasses, parseBoolean, parseNumber, parseString } from "../util";
22
+ import { parseBoolean, parseNumber, parseString } from "../util";
22
23
  import { ATTR_WATERFALL_ELEMENT, EL_PAGINATION, EL_PAGINATION_BULLET, EL_PAGINATION_BULLET_ACTIVE } from "lib/elements";
24
+ import { SwiperOptions } from "swiper/types";
23
25
 
24
- export function paginationConfig(config: any, element: HTMLElement) {
26
+ export function paginationConfig(config: SwiperOptions, element: HTMLElement) {
25
27
  const paginationEl = element.querySelector<HTMLElement>(`[${ATTR_WATERFALL_ELEMENT}=${EL_PAGINATION}]`);
26
28
  if (!paginationEl) return;
27
29
 
@@ -36,7 +38,7 @@ export function paginationConfig(config: any, element: HTMLElement) {
36
38
  clickable: parseBoolean(element, ATTR_PAGINATION_CLICKABLE, false),
37
39
  clickableClass: parseString(element, ATTR_PAGINATION_CLICKABLE_CLASS, "swiper-pagination-clickable"),
38
40
  currentClass: parseString(element, ATTR_PAGINATION_CURRENT_CLASS, "swiper-pagination-current"),
39
- dynamicBullets: parseString(element, ATTR_PAGINATION_DYNAMIC_BULLETS, "swiper-pagination-current"),
41
+ dynamicBullets: parseBoolean(element, ATTR_PAGINATION_DYNAMIC_BULLETS, false),
40
42
  dynamicMainBullets: parseNumber(element, ATTR_PAGINATION_DYNAMIC_MAIN_BULLETS, 1),
41
43
  el: paginationEl || null,
42
44
  enabled: parseBoolean(element, ATTR_PAGINATION_ENABLED),
@@ -55,9 +57,10 @@ export function paginationConfig(config: any, element: HTMLElement) {
55
57
  ATTR_PAGINATION_PROGRESSBAR_FILL_CLASS,
56
58
  "swiper-pagination-progressbar-fill",
57
59
  ),
58
- progressbarOpposite: parseString(
60
+ progressbarOpposite: parseBoolean(element, ATTR_PAGINATION_PROGRESSBAR_OPPOSITE, false),
61
+ progressbarOppositeClass: parseString(
59
62
  element,
60
- ATTR_PAGINATION_PROGRESSBAR_OPPOSITE,
63
+ ATTR_PAGINATION_PROGRESSBAR_OPPOSITE_CLASS,
61
64
  "swiper-pagination-progressbar-opposite",
62
65
  ),
63
66
  renderBullet: customRenderBullet(),
@@ -67,14 +70,13 @@ export function paginationConfig(config: any, element: HTMLElement) {
67
70
  };
68
71
 
69
72
  function customRenderBullet() {
70
- let renderBullet: RenderBulletFunction | null = null;
71
73
  if (paginationType === "numberBullets") {
72
- renderBullet = (index, className) => `<span class="${className}">${index + 1}</span>`;
74
+ return (index: number, className: string) => `<span class="${className}">${index + 1}</span>`;
73
75
  }
74
76
  if (paginationType === "bullets") {
75
- renderBullet = (index, className) => `<span class="${className}"></span>`;
77
+ return (index: number, className: string) => `<span class="${className}"></span>`;
76
78
  }
77
- return renderBullet;
79
+ return undefined;
78
80
  }
79
81
 
80
82
  function getPaginationType() {
@@ -86,4 +88,3 @@ export function paginationConfig(config: any, element: HTMLElement) {
86
88
  }
87
89
  }
88
90
 
89
- type RenderBulletFunction = (index: number, className: string) => string;
@@ -1,7 +1,8 @@
1
1
  import { ATTR_PARALLAX_ENABLED } from "lib/attributes";
2
2
  import { parseBoolean } from "../util";
3
+ import { SwiperOptions } from "swiper/types";
3
4
 
4
- export default function parallaxConfig(config: any, el: HTMLElement) {
5
+ export default function parallaxConfig(config: SwiperOptions, el: HTMLElement) {
5
6
  config.parallax = {
6
7
  enabled: parseBoolean(el, ATTR_PARALLAX_ENABLED, false),
7
8
  };
@@ -23,8 +23,9 @@ import {
23
23
  ATTR_STOP_ON_LAST_SLIDE,
24
24
  } from "lib/attributes";
25
25
  import { parseBoolean, parseNumber, parseString } from "../util";
26
+ import { SwiperOptions } from "swiper/types";
26
27
 
27
- export function playbackConfig(config: any, el: HTMLElement) {
28
+ export function playbackConfig(config: SwiperOptions, el: HTMLElement) {
28
29
  // Set Loop, Rewind, or None
29
30
  const playbackMode = parseString(el, ATTR_PLAYBACK_MODE, "none");
30
31
  if (playbackMode === "loop") config.loop = true;
@@ -10,16 +10,17 @@ import {
10
10
  ATTR_SCROLLBAR_VERTICAL_CLASS,
11
11
  } from "lib/attributes";
12
12
  import { ATTR_WATERFALL_ELEMENT, EL_SCROLLBAR, EL_SCROLLBAR_DRAG } from "lib/elements";
13
- import { parseBoolean, parseString } from "../util";
13
+ import { parseAny, parseBoolean, parseString } from "../util";
14
+ import { SwiperOptions } from "swiper/types";
14
15
 
15
- export function scrollbarConfig(config: any, element: HTMLElement) {
16
+ export function scrollbarConfig(config: SwiperOptions, element: HTMLElement) {
16
17
  const scrollbar = element.querySelector<HTMLElement>(`[${ATTR_WATERFALL_ELEMENT}=${EL_SCROLLBAR}]`);
17
18
  if (!scrollbar) return;
18
19
  const scrollbarDrag = scrollbar?.querySelector<HTMLElement>(`[${ATTR_WATERFALL_ELEMENT}=${EL_SCROLLBAR_DRAG}]`);
19
20
 
20
21
  config.scrollbar = {
21
22
  dragClass: scrollbarDrag?.getAttribute("class") || "",
22
- dragSize: parseString(element, ATTR_SCROLLBAR_DRAG_SIZE, "auto"),
23
+ dragSize: parseAny(element, ATTR_SCROLLBAR_DRAG_SIZE, "auto"),
23
24
  draggable: parseBoolean(element, ATTR_SCROLLBAR_DRAGGABLE, false),
24
25
  el: scrollbar || null,
25
26
  enabled: parseBoolean(element, ATTR_SCROLLBAR_ENABLED),
@@ -1,4 +1,4 @@
1
- import { ThumbsOptions } from "swiper/types";
1
+ import { SwiperOptions } from "swiper/types";
2
2
  import { parseBoolean, parseNumber, parseString } from "../util";
3
3
  import { Waterfall } from "types/waterfall";
4
4
  import {
@@ -9,7 +9,7 @@ import {
9
9
  ATTR_THUMBS_SLIDE_THUMB_ACTIVE_CLASS,
10
10
  } from "lib/attributes";
11
11
 
12
- export function thumbsConfig(config: any, el: HTMLElement, swipers: Waterfall[], debug: boolean) {
12
+ export function thumbsConfig(config: SwiperOptions, el: HTMLElement, swipers: Waterfall[], debug: boolean) {
13
13
  const thumbsName = parseString(el, ATTR_THUMBS, "");
14
14
  if (!thumbsName || thumbsName === "") {
15
15
  return;
@@ -28,9 +28,10 @@ import {
28
28
  ATTR_TOUCH_START_FORCE_PREVENT_DEFAULT,
29
29
  ATTR_TOUCH_START_PREVENT_DEFAULT,
30
30
  } from "lib/attributes";
31
- import { parseBoolean, parseNumber, parseString } from "../util";
31
+ import { parseAny, parseBoolean, parseNumber, parseString } from "../util";
32
+ import { SwiperOptions } from "swiper/types";
32
33
 
33
- export function touchConfig(config: any, el: HTMLElement) {
34
+ export function touchConfig(config: SwiperOptions, el: HTMLElement) {
34
35
  config.allowTouchMove = parseBoolean(el, ATTR_ALLOW_TOUCH_MOVE, true);
35
36
  config.edgeSwipeDetection = parseBoolean(el, ATTR_EDGE_SWIPE_DETECTION, false);
36
37
  config.edgeSwipeThreshold = parseNumber(el, ATTR_EDGE_SWIPE_THRESHOLD, 20);
@@ -57,7 +58,7 @@ export function touchConfig(config: any, el: HTMLElement) {
57
58
  config.slideToClickedSlide = parseBoolean(el, ATTR_SLIDE_TO_CLICKED_SLIDE, false);
58
59
  config.threshold = parseNumber(el, ATTR_THRESHOLD, 5);
59
60
  config.touchAngle = parseNumber(el, ATTR_TOUCH_ANGLE, 45);
60
- config.touchEventsTarget = parseString(el, ATTR_TOUCH_EVENTS_TARGET, "wrapper");
61
+ config.touchEventsTarget = parseAny(el, ATTR_TOUCH_EVENTS_TARGET, "wrapper");
61
62
  config.touchMoveStopPropagation = parseBoolean(el, ATTR_TOUCH_MOVE_STOP_PROPAGATION, false);
62
63
  config.touchRatio = parseNumber(el, ATTR_TOUCH_RATIO, 1);
63
64
  config.touchReleaseOnEdges = parseBoolean(el, ATTR_TOUCH_RELEASE_ON_EDGES, false);
@@ -8,8 +8,9 @@ import {
8
8
  ATTR_ZOOMED_SLIDE_CLASS,
9
9
  } from "lib/attributes";
10
10
  import { parseBoolean, parseNumber, parseString } from "../util";
11
+ import { SwiperOptions } from "swiper/types";
11
12
 
12
- export function zoomConfig(config: any, el: HTMLElement) {
13
+ export function zoomConfig(config: SwiperOptions, el: HTMLElement) {
13
14
  config.zoom = {
14
15
  containerClass: parseString(el, ATTR_ZOOM_CONTAINER_CLASS, "swiper-zoom-container"),
15
16
  limitToOriginalSize: parseBoolean(el, ATTR_ZOOM_LIMIT_TO_ORIGINAL_SIZE, false),
package/src/util.ts CHANGED
@@ -24,6 +24,12 @@ export function parseString(el: HTMLElement, attrName: string, defaultValue?: st
24
24
  return attrValue;
25
25
  }
26
26
 
27
+ export function parseAny(el: HTMLElement, attrName: string, defaultValue?: any): any | undefined {
28
+ const attrValue = el.getAttribute(attrName)?.trim();
29
+ if (!attrValue || attrValue === defaultValue) return undefined;
30
+ return attrValue;
31
+ }
32
+
27
33
  // ✅ Parse attribute as number
28
34
  export function parseNumber(el: HTMLElement, attrName: string, defaultValue?: number): number | undefined {
29
35
  const attrValue = el.getAttribute(attrName)?.trim();