well-waterfall 0.3.7 → 0.4.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/dist/waterfall.js CHANGED
@@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
256
256
  \*******************************/
257
257
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
258
258
 
259
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ thumbsConfig: () => (/* binding */ thumbsConfig)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util */ \"./src/util.ts\");\n\nfunction getThumbsSwiper(el, sliders) {\n const sliderName = (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)(el, 'thumbs-waterfall', null);\n if (sliderName === null)\n return null;\n const foundSlider = sliders.find((slider) => slider.name === sliderName);\n if (foundSlider)\n return foundSlider;\n return null; // Return null if no match is found\n}\nfunction thumbsConfig(el, swipers) {\n const waterfall = getThumbsSwiper(el, swipers);\n if (!waterfall)\n return;\n return {\n autoScrollOffset: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)(el, 'auto-scroll-offset', 0),\n multipleActiveThumbs: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)(el, 'multiple-active-thumbs', false),\n slideThumbActiveClass: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)(el, 'slide-thumb-active-class', 'swiper-slide-thumb-active'),\n swiper: waterfall.swiper,\n thumbsContainerClass: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)(el, 'thumbs-container-class', 'swiper-thumbs'),\n };\n}\n\n\n//# sourceURL=webpack://Waterfall/./src/modules/thumbs.ts?");
259
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ thumbsConfig: () => (/* binding */ thumbsConfig)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util */ \"./src/util.ts\");\n\nfunction getThumbsSwiper(el, sliders) {\n const sliderName = (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseAttr)(el, 'thumbs-name', null);\n if (sliderName === null)\n return null;\n const foundSlider = sliders.find((slider) => slider.name === sliderName);\n if (foundSlider)\n return foundSlider;\n console.log('A matching thumbs waterfall was not found for ', sliderName);\n return null; // Return null if no match is found\n}\nfunction thumbsConfig(el, swipers) {\n const waterfall = getThumbsSwiper(el, swipers);\n if (!waterfall)\n return;\n let config = {\n autoScrollOffset: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseNumber)(el, 'auto-scroll-offset', 0),\n multipleActiveThumbs: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseBoolean)(el, 'multiple-active-thumbs', false),\n slideThumbActiveClass: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseString)(el, 'slide-thumb-active-class', 'swiper-slide-thumb-active'),\n swiper: waterfall.swiper,\n thumbsContainerClass: (0,_util__WEBPACK_IMPORTED_MODULE_0__.parseString)(el, 'thumbs-container-class', 'swiper-thumbs'),\n };\n}\n\n\n//# sourceURL=webpack://Waterfall/./src/modules/thumbs.ts?");
260
260
 
261
261
  /***/ }),
262
262
 
@@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
266
266
  \*********************/
267
267
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
268
268
 
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?");
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 */ parseBoolean: () => (/* binding */ parseBoolean),\n/* harmony export */ parseNumber: () => (/* binding */ parseNumber),\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 undefined;\n // Nullify the attribute if it matches the default value from SwiperJS\n if (attrValue === defaultValue)\n return undefined;\n return attrValue;\n}\nfunction parseNumber(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 undefined;\n const parsedValue = Number(attrValue);\n if (isNaN(parsedValue))\n return undefined;\n return parsedValue === defaultValue ? undefined : parsedValue;\n}\nfunction parseBoolean(el, attrName, defaultValue) {\n var _a, _b;\n const attrValue = (_b = (_a = $(el).attr(attrName)) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.toLowerCase();\n if (!attrValue)\n return undefined;\n if (attrValue === 'true')\n return true;\n if (attrValue === 'false')\n return false;\n return attrValue === defaultValue.toString() ? undefined : undefined;\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?");
270
270
 
271
271
  /***/ }),
272
272
 
@@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
276
276
  \**************************/
277
277
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
278
278
 
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.7\"}`);\nconst waterfalls = [];\n// Initialize Thumb Sliders first\n$('[waterfall][waterfall-preload=\"true\"]').each((index, el) => initConfig(el, index));\n// Initialize all other sliders\n$('[waterfall]')\n .not('[waterfall-preload=\"true\"]')\n .not('[waterfall-postload=\"true\"]')\n .each((index, el) => initConfig(el, index));\n$('[waterfall][waterfall-postload=\"true\"]').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-thumbs', null) === true;\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?");
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.4.0\"}`);\nconst waterfalls = [];\n// Initialize Thumb Sliders first\n$('[waterfall][waterfall-preload=\"true\"]').each((index, el) => initConfig(el, index));\n// Initialize all other sliders\n$('[waterfall]')\n .not('[waterfall-preload=\"true\"]')\n .not('[waterfall-postload=\"true\"]')\n .each((index, el) => initConfig(el, index));\n$('[waterfall][waterfall-postload=\"true\"]').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-thumbs', null) === true;\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?");
280
280
 
281
281
  /***/ }),
282
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "well-waterfall",
3
- "version": "0.3.7",
3
+ "version": "0.4.0",
4
4
  "description": "An attribute-based wrapper of SwiperJS for Webflow",
5
5
  "main": "waterfall.js",
6
6
  "scripts": {
@@ -1,11 +1,12 @@
1
- import { parseAttr } from '../util';
1
+ import { ThumbsOptions } from 'swiper/types';
2
+ import { parseAttr, parseBoolean, parseNumber, parseString } from '../util';
2
3
  import { Waterfall } from 'types/waterfall';
3
4
 
4
5
  function getThumbsSwiper(
5
6
  el: JQuery<HTMLElement>,
6
7
  sliders: Waterfall[],
7
8
  ): Waterfall | null {
8
- const sliderName = parseAttr(el, 'thumbs-waterfall', null);
9
+ const sliderName = parseAttr(el, 'thumbs-name', null);
9
10
  if (sliderName === null) return null;
10
11
 
11
12
  const foundSlider = sliders.find(
@@ -13,6 +14,7 @@ function getThumbsSwiper(
13
14
  );
14
15
 
15
16
  if (foundSlider) return foundSlider;
17
+ console.log('A matching thumbs waterfall was not found for ', sliderName);
16
18
  return null; // Return null if no match is found
17
19
  }
18
20
 
@@ -20,16 +22,16 @@ export function thumbsConfig(el: JQuery<HTMLElement>, swipers: Waterfall[]) {
20
22
  const waterfall = getThumbsSwiper(el, swipers);
21
23
  if (!waterfall) return;
22
24
 
23
- return {
24
- autoScrollOffset: parseAttr(el, 'auto-scroll-offset', 0),
25
- multipleActiveThumbs: parseAttr(el, 'multiple-active-thumbs', false),
26
- slideThumbActiveClass: parseAttr(
25
+ let config: ThumbsOptions = {
26
+ autoScrollOffset: parseNumber(el, 'auto-scroll-offset', 0),
27
+ multipleActiveThumbs: parseBoolean(el, 'multiple-active-thumbs', false),
28
+ slideThumbActiveClass: parseString(
27
29
  el,
28
30
  'slide-thumb-active-class',
29
31
  'swiper-slide-thumb-active',
30
32
  ),
31
33
  swiper: waterfall.swiper,
32
- thumbsContainerClass: parseAttr(
34
+ thumbsContainerClass: parseString(
33
35
  el,
34
36
  'thumbs-container-class',
35
37
  'swiper-thumbs',
package/src/util.ts CHANGED
@@ -28,12 +28,40 @@ export function parseString(
28
28
  defaultValue: string,
29
29
  ) {
30
30
  const attrValue = $(el).attr(attrName)?.trim();
31
- if (!attrValue) return null;
31
+ if (!attrValue) return undefined;
32
32
  // Nullify the attribute if it matches the default value from SwiperJS
33
- if (attrValue === defaultValue) return null;
33
+ if (attrValue === defaultValue) return undefined;
34
34
  return attrValue;
35
35
  }
36
36
 
37
+ export function parseNumber(
38
+ el: JQuery<HTMLElement>,
39
+ attrName: string,
40
+ defaultValue: number,
41
+ ): number | undefined {
42
+ const attrValue = $(el).attr(attrName)?.trim();
43
+ if (!attrValue) return undefined;
44
+
45
+ const parsedValue = Number(attrValue);
46
+ if (isNaN(parsedValue)) return undefined;
47
+
48
+ return parsedValue === defaultValue ? undefined : parsedValue;
49
+ }
50
+
51
+ export function parseBoolean(
52
+ el: JQuery<HTMLElement>,
53
+ attrName: string,
54
+ defaultValue: boolean,
55
+ ): boolean | undefined {
56
+ const attrValue = $(el).attr(attrName)?.trim()?.toLowerCase();
57
+ if (!attrValue) return undefined;
58
+
59
+ if (attrValue === 'true') return true;
60
+ if (attrValue === 'false') return false;
61
+
62
+ return attrValue === defaultValue.toString() ? undefined : undefined;
63
+ }
64
+
37
65
  export function parseAttr(
38
66
  el: JQuery<HTMLElement>,
39
67
  attrName: string,
package/src/waterfall.ts CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  historyNavigationConfig,
30
30
  } from './modules/hashhistory';
31
31
  import { controllerConfig } from './modules/controller';
32
+ import { SwiperOptions } from 'swiper/types';
32
33
 
33
34
  console.log(`🚿 Hello from Wellflow Waterfall v${APP_VERSION}`);
34
35
 
@@ -126,7 +127,7 @@ function initConfig(el: HTMLElement, index: number) {
126
127
 
127
128
  // Clean up the config and debug
128
129
  //printDebug(debug, 'CONFIG (UNCLEANED)', swiperConfig);
129
- const config = removeNullOrUndefinedKeys(swiperConfig);
130
+ const config: SwiperOptions = removeNullOrUndefinedKeys(swiperConfig);
130
131
  printDebug(debug, 'CONFIG', config);
131
132
 
132
133
  // Initialize swiper