well-waterfall 0.3.2 → 0.3.4

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 CHANGED
@@ -140,6 +140,16 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
140
140
 
141
141
  /***/ }),
142
142
 
143
+ /***/ "./src/modules/controller.ts":
144
+ /*!***********************************!*\
145
+ !*** ./src/modules/controller.ts ***!
146
+ \***********************************/
147
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
148
+
149
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ controllerConfig: () => (/* binding */ controllerConfig)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util */ \"./src/util.ts\");\n\nfunction controllerConfig($this, waterfalls) {\n const controllerSelector = (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseString)($this, 'controller-control', '');\n if (!controllerSelector)\n return;\n const swipers = (0,_util__WEBPACK_IMPORTED_MODULE_0__.getSwipersByName)(waterfalls, controllerSelector);\n return {\n by: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)($this, 'controller-by', 'slide'),\n control: swipers,\n inverse: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)($this, 'controller-inverse', false),\n };\n}\n\n\n//# sourceURL=webpack://Waterfall/./src/modules/controller.ts?");
150
+
151
+ /***/ }),
152
+
143
153
  /***/ "./src/modules/effect.ts":
144
154
  /*!*******************************!*\
145
155
  !*** ./src/modules/effect.ts ***!
@@ -256,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
256
266
  \*********************/
257
267
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
258
268
 
259
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getUniqueClasses: () => (/* binding */ getUniqueClasses),\n/* harmony export */ parseAttr: () => (/* binding */ parseAttr),\n/* harmony export */ parseString: () => (/* binding */ parseString),\n/* harmony export */ printDebug: () => (/* binding */ printDebug),\n/* harmony export */ removeNullOrUndefinedKeys: () => (/* binding */ removeNullOrUndefinedKeys)\n/* harmony export */ });\nfunction printDebug(debug, str, el) {\n if (!debug)\n return;\n console.log(str, ': ', el);\n}\nfunction getUniqueClasses(targetElement, comparisonElement) {\n if (!targetElement.length)\n return ''; // If no element, return an empty string\n let targetClasses = (targetElement.attr('class') || '').split(/\\s+/);\n let comparisonClasses = (comparisonElement.attr('class') || '').split(/\\s+/);\n let filtered = targetClasses.filter((className) => className && !comparisonClasses.includes(className));\n // Get the class attribute, split into an array, filter out the classToRemove, and join back into a string\n return filtered.join(' '); // Join the remaining classes into a string\n}\nfunction parseString(el, attrName, defaultValue) {\n var _a;\n const attrValue = (_a = $(el).attr(attrName)) === null || _a === void 0 ? void 0 : _a.trim();\n if (!attrValue)\n return null;\n // Nullify the attribute if it matches the default value from SwiperJS\n if (attrValue === defaultValue)\n return null;\n return attrValue;\n}\nfunction parseAttr(el, attrName, defaultValue) {\n const attrValue = $(el).attr(attrName);\n if (!attrValue)\n return null;\n // Trim the input to avoid issues with leading/trailing spaces\n const trimmedInput = attrValue.trim();\n // Check if input is a number\n if (!isNaN(Number(trimmedInput))) {\n const parsedNumber = parseFloat(trimmedInput);\n if (parsedNumber === defaultValue) {\n return null; // Return null if it matches the default value\n }\n return parsedNumber; // Return the parsed number\n }\n // Check if input is a boolean\n if (trimmedInput.toLowerCase() === 'true') {\n if (defaultValue === true) {\n return null; // Return null if it matches the default value\n }\n return true;\n }\n else if (trimmedInput.toLowerCase() === 'false') {\n if (defaultValue === false) {\n return null; // Return null if it matches the default value\n }\n return false;\n }\n // Return null if the input matches the default value (as a string)\n if (trimmedInput === String(defaultValue)) {\n return null;\n }\n // Return the input as a string\n return trimmedInput;\n}\nfunction removeNullOrUndefinedKeys(obj) {\n if (typeof obj !== 'object' || obj === null) {\n return obj; // Return non-objects or null as is\n }\n // Iterate over the keys in the object\n for (const key in obj) {\n if (obj[key] === null || obj[key] === undefined) {\n delete obj[key]; // ✅ Remove `null` or `undefined` keys\n }\n else if (typeof obj[key] === 'object' &&\n !(obj[key] instanceof HTMLElement)) {\n // Recursively handle nested objects\n removeNullOrUndefinedKeys(obj[key]);\n // Remove empty objects after recursion\n if (Object.keys(obj[key]).length === 0) {\n delete obj[key];\n }\n }\n }\n return obj;\n}\n\n\n//# sourceURL=webpack://Waterfall/./src/util.ts?");
269
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getSwipersByName: () => (/* binding */ getSwipersByName),\n/* harmony export */ getUniqueClasses: () => (/* binding */ getUniqueClasses),\n/* harmony export */ parseAttr: () => (/* binding */ parseAttr),\n/* harmony export */ parseString: () => (/* binding */ parseString),\n/* harmony export */ printDebug: () => (/* binding */ printDebug),\n/* harmony export */ removeNullOrUndefinedKeys: () => (/* binding */ removeNullOrUndefinedKeys)\n/* harmony export */ });\nfunction printDebug(debug, str, el) {\n if (!debug)\n return;\n console.log(str, ': ', el);\n}\nfunction getUniqueClasses(targetElement, comparisonElement) {\n if (!targetElement.length)\n return ''; // If no element, return an empty string\n let targetClasses = (targetElement.attr('class') || '').split(/\\s+/);\n let comparisonClasses = (comparisonElement.attr('class') || '').split(/\\s+/);\n let filtered = targetClasses.filter((className) => className && !comparisonClasses.includes(className));\n // Get the class attribute, split into an array, filter out the classToRemove, and join back into a string\n return filtered.join(' '); // Join the remaining classes into a string\n}\nfunction parseString(el, attrName, defaultValue) {\n var _a;\n const attrValue = (_a = $(el).attr(attrName)) === null || _a === void 0 ? void 0 : _a.trim();\n if (!attrValue)\n return null;\n // Nullify the attribute if it matches the default value from SwiperJS\n if (attrValue === defaultValue)\n return null;\n return attrValue;\n}\nfunction parseAttr(el, attrName, defaultValue) {\n const attrValue = $(el).attr(attrName);\n if (!attrValue)\n return null;\n // Trim the input to avoid issues with leading/trailing spaces\n const trimmedInput = attrValue.trim();\n // Check if input is a number\n if (!isNaN(Number(trimmedInput))) {\n const parsedNumber = parseFloat(trimmedInput);\n if (parsedNumber === defaultValue) {\n return null; // Return null if it matches the default value\n }\n return parsedNumber; // Return the parsed number\n }\n // Check if input is a boolean\n if (trimmedInput.toLowerCase() === 'true') {\n if (defaultValue === true) {\n return null; // Return null if it matches the default value\n }\n return true;\n }\n else if (trimmedInput.toLowerCase() === 'false') {\n if (defaultValue === false) {\n return null; // Return null if it matches the default value\n }\n return false;\n }\n // Return null if the input matches the default value (as a string)\n if (trimmedInput === String(defaultValue)) {\n return null;\n }\n // Return the input as a string\n return trimmedInput;\n}\nfunction removeNullOrUndefinedKeys(obj) {\n if (typeof obj !== 'object' || obj === null) {\n return obj; // Return non-objects or null as is\n }\n // Iterate over the keys in the object\n for (const key in obj) {\n if (obj[key] === null || obj[key] === undefined) {\n delete obj[key]; // ✅ Remove `null` or `undefined` keys\n }\n else if (typeof obj[key] === 'object' &&\n !(obj[key] instanceof HTMLElement)) {\n // Recursively handle nested objects\n removeNullOrUndefinedKeys(obj[key]);\n // Remove empty objects after recursion\n if (Object.keys(obj[key]).length === 0) {\n delete obj[key];\n }\n }\n }\n return obj;\n}\nfunction getSwipersByName(waterfalls, selector) {\n const strArr = splitByUnderscores(selector);\n const swipers = [];\n strArr.forEach((str) => {\n const waterfall = waterfalls.find((w) => {\n if (w.name === str)\n return true;\n return false;\n });\n if (waterfall)\n swipers.push(waterfall === null || waterfall === void 0 ? void 0 : waterfall.swiper);\n });\n return swipers;\n}\nfunction splitByUnderscores(str) {\n return str.split('_');\n}\n\n\n//# sourceURL=webpack://Waterfall/./src/util.ts?");
260
270
 
261
271
  /***/ }),
262
272
 
@@ -266,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
266
276
  \**************************/
267
277
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
268
278
 
269
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var swiper_bundle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! swiper/bundle */ \"./node_modules/swiper/swiper-bundle.mjs\");\n/* harmony import */ var swiper_css_bundle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! swiper/css/bundle */ \"./node_modules/swiper/swiper-bundle.css\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ \"./src/util.ts\");\n/* harmony import */ var _modules_navigation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/navigation */ \"./src/modules/navigation.ts\");\n/* harmony import */ var _modules_breakpoints__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./modules/breakpoints */ \"./src/modules/breakpoints.ts\");\n/* harmony import */ var _modules_pagination__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./modules/pagination */ \"./src/modules/pagination.ts\");\n/* harmony import */ var _modules_scrollbar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./modules/scrollbar */ \"./src/modules/scrollbar.ts\");\n/* harmony import */ var _modules_playback__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./modules/playback */ \"./src/modules/playback.ts\");\n/* harmony import */ var _modules_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./modules/effect */ \"./src/modules/effect.ts\");\n/* harmony import */ var _modules_layout__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./modules/layout */ \"./src/modules/layout.ts\");\n/* harmony import */ var _modules_general__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./modules/general */ \"./src/modules/general.ts\");\n/* harmony import */ var _modules_slideCount__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./modules/slideCount */ \"./src/modules/slideCount.ts\");\n/* harmony import */ var _modules_thumbs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./modules/thumbs */ \"./src/modules/thumbs.ts\");\n/* harmony import */ var _modules_input__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./modules/input */ \"./src/modules/input.ts\");\n/* harmony import */ var _modules_hashhistory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./modules/hashhistory */ \"./src/modules/hashhistory.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconsole.log(`🚿 Hello from Wellflow Waterfall v${\"0.3.2\"}`);\nconst sliders = [];\n// Initialize Thumb Sliders first\n$('[waterfall][waterfall-el=\"thumbs\"]').each((index, el) => initConfig(el, index));\n// Initialize all other sliders\n$('[waterfall]')\n .not('[waterfall-el=\"thumbs\"]')\n .each((index, el) => initConfig(el, index));\nfunction initConfig(el, index) {\n {\n const $this = $(el);\n const name = (0,_util__WEBPACK_IMPORTED_MODULE_2__.parseString)($this, 'waterfall', `Swiper ${index}`);\n if (!name)\n return;\n const debug = Boolean((0,_util__WEBPACK_IMPORTED_MODULE_2__.parseAttr)($this, 'debug-mode', false) || false);\n console.log(`Initializing Waterfall: ${name} ${debug ? '[DEBUG MODE]' : ''}`);\n // GENERAL CONFIG\n const swiperConfig = (0,_modules_general__WEBPACK_IMPORTED_MODULE_10__.generalConfig)($this);\n // BREAKPOINTS\n swiperConfig.breakpoints = (0,_modules_breakpoints__WEBPACK_IMPORTED_MODULE_4__.breakpointsConfig)($this);\n // PLAYBACK\n const playbackMode = (0,_util__WEBPACK_IMPORTED_MODULE_2__.parseAttr)($this, 'playback-mode', 'none');\n if (playbackMode === 'loop')\n swiperConfig.loop = true;\n if (playbackMode === 'rewind')\n swiperConfig.rewind = true;\n if (playbackMode === 'none') {\n swiperConfig.loop = false;\n swiperConfig.rewind = false;\n }\n swiperConfig.autoplay = (0,_modules_playback__WEBPACK_IMPORTED_MODULE_7__.autoplayConfig)($this);\n // NAVIGATION\n swiperConfig.navigation = (0,_modules_navigation__WEBPACK_IMPORTED_MODULE_3__.navigationConfig)($this, name);\n // PAGINATION\n let pagination = $this.find(\"[waterfall-el='pagination-bullet']\").length;\n if (pagination)\n swiperConfig.pagination = (0,_modules_pagination__WEBPACK_IMPORTED_MODULE_5__.paginationConfig)($this);\n // SCROLLBAR\n const $scrollbar = $this.find(\"[waterfall-el='scrollbar']\");\n if ($scrollbar)\n swiperConfig.scrollbar = (0,_modules_scrollbar__WEBPACK_IMPORTED_MODULE_6__.scrollbarConfig)($this);\n // EFFECT\n swiperConfig.fadeEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.fadeConfig)($this);\n swiperConfig.coverflowEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.coverflowEffect)($this);\n swiperConfig.flipEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.flipEffect)($this);\n swiperConfig.cardsEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.cardsEffect)($this);\n swiperConfig.cubeEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.cubeEffect)($this);\n // FREE MODE\n swiperConfig.freeMode = (0,_modules_playback__WEBPACK_IMPORTED_MODULE_7__.freeModeConfig)($this);\n // GRID\n swiperConfig.grid = (0,_modules_layout__WEBPACK_IMPORTED_MODULE_9__.gridConfig)($this);\n // THUMBS\n const isThumbs = (0,_util__WEBPACK_IMPORTED_MODULE_2__.parseAttr)($this, 'waterfall-el', null) === 'thumbs';\n if (!isThumbs)\n swiperConfig.thumbs = (0,_modules_thumbs__WEBPACK_IMPORTED_MODULE_12__.thumbsConfig)($this, sliders);\n // ZOOM - NOT IMPLEMENTED\n // KEYBOARD\n swiperConfig.keyboard = (0,_modules_input__WEBPACK_IMPORTED_MODULE_13__.keyboardConfig)($this);\n // MOUSE\n swiperConfig.mousewheel = (0,_modules_input__WEBPACK_IMPORTED_MODULE_13__.mouseConfig)($this);\n // VIRTUAL SLIDES - NOT IMPLEMENTED\n // HASH NAVIGATION\n swiperConfig.hashNavigation = (0,_modules_hashhistory__WEBPACK_IMPORTED_MODULE_14__.hashNavigationConfig)($this);\n // HISTORY NAVIGATION\n swiperConfig.historyNavigation = (0,_modules_hashhistory__WEBPACK_IMPORTED_MODULE_14__.historyNavigationConfig)($this);\n // Clean up the config and debug\n //printDebug(debug, 'CONFIG (UNCLEANED)', swiperConfig);\n const config = (0,_util__WEBPACK_IMPORTED_MODULE_2__.removeNullOrUndefinedKeys)(swiperConfig);\n (0,_util__WEBPACK_IMPORTED_MODULE_2__.printDebug)(debug, 'CONFIG', config);\n // Initialize swiper\n const swiper = new swiper_bundle__WEBPACK_IMPORTED_MODULE_0__[\"default\"]($this.find('.swiper')[0], config);\n // Add to sliders array\n sliders.push({ name, swiper: swiper });\n }\n}\n(0,_modules_slideCount__WEBPACK_IMPORTED_MODULE_11__.initSlideCount)();\n\n\n//# sourceURL=webpack://Waterfall/./src/waterfall.ts?");
279
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var swiper_bundle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! swiper/bundle */ \"./node_modules/swiper/swiper-bundle.mjs\");\n/* harmony import */ var swiper_css_bundle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! swiper/css/bundle */ \"./node_modules/swiper/swiper-bundle.css\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ \"./src/util.ts\");\n/* harmony import */ var _modules_navigation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/navigation */ \"./src/modules/navigation.ts\");\n/* harmony import */ var _modules_breakpoints__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./modules/breakpoints */ \"./src/modules/breakpoints.ts\");\n/* harmony import */ var _modules_pagination__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./modules/pagination */ \"./src/modules/pagination.ts\");\n/* harmony import */ var _modules_scrollbar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./modules/scrollbar */ \"./src/modules/scrollbar.ts\");\n/* harmony import */ var _modules_playback__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./modules/playback */ \"./src/modules/playback.ts\");\n/* harmony import */ var _modules_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./modules/effect */ \"./src/modules/effect.ts\");\n/* harmony import */ var _modules_layout__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./modules/layout */ \"./src/modules/layout.ts\");\n/* harmony import */ var _modules_general__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./modules/general */ \"./src/modules/general.ts\");\n/* harmony import */ var _modules_slideCount__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./modules/slideCount */ \"./src/modules/slideCount.ts\");\n/* harmony import */ var _modules_thumbs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./modules/thumbs */ \"./src/modules/thumbs.ts\");\n/* harmony import */ var _modules_input__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./modules/input */ \"./src/modules/input.ts\");\n/* harmony import */ var _modules_hashhistory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./modules/hashhistory */ \"./src/modules/hashhistory.ts\");\n/* harmony import */ var _modules_controller__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./modules/controller */ \"./src/modules/controller.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconsole.log(`🚿 Hello from Wellflow Waterfall v${\"0.3.4\"}`);\nconst waterfalls = [];\n// Initialize Thumb Sliders first\n$('[waterfall][waterfall-load=\"pre\"]').each((index, el) => initConfig(el, index));\n// Initialize all other sliders\n$('[waterfall]')\n .not('[waterfall-load=\"pre]')\n .not('[waterfall-load=\"post]')\n .each((index, el) => initConfig(el, index));\n$('[waterfall][waterfall-load=\"post\"]').each((index, el) => initConfig(el, index));\nfunction initConfig(el, index) {\n {\n const $this = $(el);\n const name = (0,_util__WEBPACK_IMPORTED_MODULE_2__.parseString)($this, 'waterfall', `Swiper ${index}`);\n if (!name)\n return;\n const debug = Boolean((0,_util__WEBPACK_IMPORTED_MODULE_2__.parseAttr)($this, 'debug-mode', false) || false);\n console.log(`Initializing Waterfall: ${name} ${debug ? '[DEBUG MODE]' : ''}`);\n // GENERAL CONFIG\n const swiperConfig = (0,_modules_general__WEBPACK_IMPORTED_MODULE_10__.generalConfig)($this);\n // BREAKPOINTS\n swiperConfig.breakpoints = (0,_modules_breakpoints__WEBPACK_IMPORTED_MODULE_4__.breakpointsConfig)($this);\n // PLAYBACK\n const playbackMode = (0,_util__WEBPACK_IMPORTED_MODULE_2__.parseAttr)($this, 'playback-mode', 'none');\n if (playbackMode === 'loop')\n swiperConfig.loop = true;\n if (playbackMode === 'rewind')\n swiperConfig.rewind = true;\n if (playbackMode === 'none') {\n swiperConfig.loop = false;\n swiperConfig.rewind = false;\n }\n swiperConfig.autoplay = (0,_modules_playback__WEBPACK_IMPORTED_MODULE_7__.autoplayConfig)($this);\n // NAVIGATION\n swiperConfig.navigation = (0,_modules_navigation__WEBPACK_IMPORTED_MODULE_3__.navigationConfig)($this, name);\n // PAGINATION\n let pagination = $this.find(\"[waterfall-el='pagination-bullet']\").length;\n if (pagination)\n swiperConfig.pagination = (0,_modules_pagination__WEBPACK_IMPORTED_MODULE_5__.paginationConfig)($this);\n // SCROLLBAR\n const $scrollbar = $this.find(\"[waterfall-el='scrollbar']\");\n if ($scrollbar)\n swiperConfig.scrollbar = (0,_modules_scrollbar__WEBPACK_IMPORTED_MODULE_6__.scrollbarConfig)($this);\n // EFFECT\n swiperConfig.fadeEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.fadeConfig)($this);\n swiperConfig.coverflowEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.coverflowEffect)($this);\n swiperConfig.flipEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.flipEffect)($this);\n swiperConfig.cardsEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.cardsEffect)($this);\n swiperConfig.cubeEffect = (0,_modules_effect__WEBPACK_IMPORTED_MODULE_8__.cubeEffect)($this);\n // FREE MODE\n swiperConfig.freeMode = (0,_modules_playback__WEBPACK_IMPORTED_MODULE_7__.freeModeConfig)($this);\n // GRID\n swiperConfig.grid = (0,_modules_layout__WEBPACK_IMPORTED_MODULE_9__.gridConfig)($this);\n // THUMBS\n const isThumbs = (0,_util__WEBPACK_IMPORTED_MODULE_2__.parseAttr)($this, 'waterfall-el', null) === 'thumbs';\n if (!isThumbs)\n swiperConfig.thumbs = (0,_modules_thumbs__WEBPACK_IMPORTED_MODULE_12__.thumbsConfig)($this, waterfalls);\n // ZOOM - NOT IMPLEMENTED\n // KEYBOARD\n swiperConfig.keyboard = (0,_modules_input__WEBPACK_IMPORTED_MODULE_13__.keyboardConfig)($this);\n // MOUSE\n swiperConfig.mousewheel = (0,_modules_input__WEBPACK_IMPORTED_MODULE_13__.mouseConfig)($this);\n // VIRTUAL SLIDES - NOT IMPLEMENTED\n // HASH NAVIGATION\n swiperConfig.hashNavigation = (0,_modules_hashhistory__WEBPACK_IMPORTED_MODULE_14__.hashNavigationConfig)($this);\n // HISTORY NAVIGATION\n swiperConfig.history = (0,_modules_hashhistory__WEBPACK_IMPORTED_MODULE_14__.historyNavigationConfig)($this);\n // CONTROLLER\n swiperConfig.controller = (0,_modules_controller__WEBPACK_IMPORTED_MODULE_15__.controllerConfig)($this, waterfalls);\n // Clean up the config and debug\n //printDebug(debug, 'CONFIG (UNCLEANED)', swiperConfig);\n const config = (0,_util__WEBPACK_IMPORTED_MODULE_2__.removeNullOrUndefinedKeys)(swiperConfig);\n (0,_util__WEBPACK_IMPORTED_MODULE_2__.printDebug)(debug, 'CONFIG', config);\n // Initialize swiper\n const swiper = new swiper_bundle__WEBPACK_IMPORTED_MODULE_0__[\"default\"]($this.find('.swiper')[0], config);\n // Add to sliders array\n waterfalls.push({ name, swiper: swiper });\n }\n}\n(0,_modules_slideCount__WEBPACK_IMPORTED_MODULE_11__.initSlideCount)();\n\n\n//# sourceURL=webpack://Waterfall/./src/waterfall.ts?");
270
280
 
271
281
  /***/ }),
272
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "well-waterfall",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "An attribute-based wrapper of SwiperJS for Webflow",
5
5
  "main": "waterfall.js",
6
6
  "scripts": {
@@ -0,0 +1,18 @@
1
+ import { Waterfall } from 'types/waterfall';
2
+ import { getSwipersByName, parseAttr, parseString } from '../util';
3
+ import Swiper from 'swiper';
4
+
5
+ export function controllerConfig(
6
+ $this: JQuery<HTMLElement>,
7
+ waterfalls: Waterfall[],
8
+ ) {
9
+ const controllerSelector = parseString($this, 'controller-control', '');
10
+ if (!controllerSelector) return;
11
+ const swipers: Swiper[] = getSwipersByName(waterfalls, controllerSelector);
12
+
13
+ return {
14
+ by: parseAttr($this, 'controller-by', 'slide'),
15
+ control: swipers,
16
+ inverse: parseAttr($this, 'controller-inverse', false),
17
+ };
18
+ }
package/src/util.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import Swiper from 'swiper';
2
+ import { Waterfall } from 'types/waterfall';
3
+
1
4
  export function printDebug(debug: boolean, str: string, el: any) {
2
5
  if (!debug) return;
3
6
  console.log(str, ': ', el);
@@ -96,3 +99,21 @@ export function removeNullOrUndefinedKeys(obj: any) {
96
99
 
97
100
  return obj;
98
101
  }
102
+
103
+ export function getSwipersByName(waterfalls: Waterfall[], selector: string) {
104
+ const strArr = splitByUnderscores(selector);
105
+ const swipers: Swiper[] = [];
106
+
107
+ strArr.forEach((str) => {
108
+ const waterfall = waterfalls.find((w) => {
109
+ if (w.name === str) return true;
110
+ return false;
111
+ });
112
+ if (waterfall) swipers.push(waterfall?.swiper);
113
+ });
114
+ return swipers;
115
+ }
116
+
117
+ function splitByUnderscores(str: string) {
118
+ return str.split('_');
119
+ }
package/src/waterfall.ts CHANGED
@@ -28,21 +28,27 @@ import {
28
28
  hashNavigationConfig,
29
29
  historyNavigationConfig,
30
30
  } from './modules/hashhistory';
31
+ import { controllerConfig } from './modules/controller';
31
32
 
32
33
  console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
33
34
 
34
- const sliders: Waterfall[] = [];
35
+ const waterfalls: Waterfall[] = [];
35
36
 
36
37
  // Initialize Thumb Sliders first
37
- $('[waterfall][waterfall-el="thumbs"]').each((index, el) =>
38
+ $('[waterfall][waterfall-load="pre"]').each((index, el) =>
38
39
  initConfig(el, index),
39
40
  );
40
41
 
41
42
  // Initialize all other sliders
42
43
  $('[waterfall]')
43
- .not('[waterfall-el="thumbs"]')
44
+ .not('[waterfall-load="pre]')
45
+ .not('[waterfall-load="post]')
44
46
  .each((index, el) => initConfig(el, index));
45
47
 
48
+ $('[waterfall][waterfall-load="post"]').each((index, el) =>
49
+ initConfig(el, index),
50
+ );
51
+
46
52
  function initConfig(el: HTMLElement, index: number) {
47
53
  {
48
54
  const $this = $(el);
@@ -97,7 +103,7 @@ function initConfig(el: HTMLElement, index: number) {
97
103
 
98
104
  // THUMBS
99
105
  const isThumbs = parseAttr($this, 'waterfall-el', null) === 'thumbs';
100
- if (!isThumbs) swiperConfig.thumbs = thumbsConfig($this, sliders);
106
+ if (!isThumbs) swiperConfig.thumbs = thumbsConfig($this, waterfalls);
101
107
 
102
108
  // ZOOM - NOT IMPLEMENTED
103
109
 
@@ -113,7 +119,10 @@ function initConfig(el: HTMLElement, index: number) {
113
119
  swiperConfig.hashNavigation = hashNavigationConfig($this);
114
120
 
115
121
  // HISTORY NAVIGATION
116
- swiperConfig.historyNavigation = historyNavigationConfig($this);
122
+ swiperConfig.history = historyNavigationConfig($this);
123
+
124
+ // CONTROLLER
125
+ swiperConfig.controller = controllerConfig($this, waterfalls);
117
126
 
118
127
  // Clean up the config and debug
119
128
  //printDebug(debug, 'CONFIG (UNCLEANED)', swiperConfig);
@@ -124,7 +133,7 @@ function initConfig(el: HTMLElement, index: number) {
124
133
  const swiper = new Swiper($this.find('.swiper')[0], config);
125
134
 
126
135
  // Add to sliders array
127
- sliders.push({ name, swiper: swiper });
136
+ waterfalls.push({ name, swiper: swiper });
128
137
  }
129
138
  }
130
139