well-waterfall 0.0.10 → 0.0.12
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/README.md +16 -29
- package/dist/waterfall.js +1 -1
- package/package.json +1 -1
- package/src/waterfall.js +50 -47
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[](https://badge.fury.io/js/angular2-expandable-list) [](https://github.com/prettier/prettier)
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# 🚿 Waterfall by Wellflow 🚿
|
|
4
4
|
|
|
5
5
|
Waterfall is a single-line of code for Webflow that enables developers to use attributes to quickly build sliders based on SwiperJS. This library is a basically an attribute wrapper for SwiperJS 10.9.0.
|
|
6
6
|
|
|
@@ -8,8 +8,7 @@ While other slider options are paid, Waterfall will always be a free solution (u
|
|
|
8
8
|
|
|
9
9
|
## Table of contents
|
|
10
10
|
|
|
11
|
-
- [
|
|
12
|
-
- [Prerequisites](#prerequisites)
|
|
11
|
+
- [Waterfall](#project-name)
|
|
13
12
|
- [Table of contents](#table-of-contents)
|
|
14
13
|
- [Getting Started](#getting-started)
|
|
15
14
|
- [Installation](#installation)
|
|
@@ -123,37 +122,25 @@ type: "bullets",
|
|
|
123
122
|
|
|
124
123
|
dynamicBullets: false,
|
|
125
124
|
|
|
126
|
-
## Scrollbar
|
|
125
|
+
## Scrollbar
|
|
127
126
|
|
|
128
127
|
To add a scrollbar, first set `[scrollbar-mode='true']`.
|
|
129
128
|
|
|
130
129
|
Add `[waterfall-el='scrollbar']` to the scrollbar element (the full scrollbar) and add `[waterfall-el='scrollbar-drag']` to the draggable area of the scrollbar.
|
|
131
130
|
|
|
132
|
-
**Scrollbar Settings (
|
|
133
|
-
|
|
134
|
-
| attributeName
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
hide: false,
|
|
147
|
-
|
|
148
|
-
horizontalClass: "swiper-scrollbar-horizontal",
|
|
149
|
-
|
|
150
|
-
lockClass: "swiper-scrollbar-lock",
|
|
151
|
-
|
|
152
|
-
scrollbarDisabledClass: "swiper-scrollbar-disabled",
|
|
153
|
-
|
|
154
|
-
snapOnRelease: false,
|
|
155
|
-
|
|
156
|
-
verticalClass: "swiper-scrollbar-vertical",
|
|
131
|
+
**Scrollbar Settings (COMPLETE)**
|
|
132
|
+
|
|
133
|
+
| attributeName | description | type | default |
|
|
134
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------- | ------- | ----------------------------- |
|
|
135
|
+
| dragSize | Size of scrollbar draggable element in px | number | 'auto' |
|
|
136
|
+
| draggable | Set to `true` to enable make scrollbar draggable that allows you to control slider position | boolean | false |
|
|
137
|
+
| scrollbarEnabled | Boolean property to use with breakpoints to enable/disable scrollbar on certain breakpoints | boolean | true |
|
|
138
|
+
| scrollbarHide | Hide scrollbar automatically after user interaction | boolean | false |
|
|
139
|
+
| scrollbarHorizontalClass | CSS class name set to scrollbar in horizontal Swiper | string | "swiper-scrollbar-horizontal" |
|
|
140
|
+
| scrollbarLockClass | Scrollbar element additional CSS class when it is disabled | string | "swiper-scrollbar-lock" |
|
|
141
|
+
| scrollbarDisabledClass | CSS class name added on swiper container and scrollbar element when scrollbar is disabled by breakpoint | string | "swiper-scrollbar-disabled" |
|
|
142
|
+
| snapOnRelease | Set to `true` to snap slider position to slides when you release scrollbar | boolean | false |
|
|
143
|
+
| scrollbarVerticalClass | CSS class name set to scrollbar in vertical Swiper | string | "swiper-scrollbar-vertical" |
|
|
157
144
|
|
|
158
145
|
## Contributing
|
|
159
146
|
|
package/dist/waterfall.js
CHANGED
|
@@ -136,7 +136,7 @@ eval("\n\n/* istanbul ignore next */\nfunction styleTagTransform(css, styleElem
|
|
|
136
136
|
\**************************/
|
|
137
137
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
138
138
|
|
|
139
|
-
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\");\nconsole.log(\"🚿 Hello from Wellflow Waterfall\");\n\n\n\n\nconst sliders = [];\n\nfunction
|
|
139
|
+
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\");\nconsole.log(\"🚿 Hello from Wellflow Waterfall\");\n\n\n\n\nconst sliders = [];\n\n// Helper function to get an attribute with type conversion\nfunction getAttr(el, attrName, defaultValue) {\n const value = $(el).attr(attrName);\n if (value === undefined || value === null) return defaultValue;\n\n if (typeof defaultValue === \"boolean\") {\n return value === \"true\";\n }\n if (typeof defaultValue === \"number\") {\n return parseInt(value, 10);\n }\n return value;\n}\n\n$(\"[waterfall]\").each(function (index) {\n const $this = $(this);\n const name = getAttr($this, \"waterfall\", `Swiper ${index}`);\n const debug = getAttr($this, \"debugMode\", false);\n\n function printDebug(str, el) {\n if (!debug) return;\n console.log(str, \": \", el);\n }\n\n const swiperConfig = {\n slidesPerView: getAttr($this, \"portraitSlides\", \"auto\"),\n centeredSlides: getAttr($this, \"portraitCenteredSlides\", false),\n direction: getAttr($this, \"direction\", \"horizontal\"),\n loop: getAttr($this, \"loopMode\", false),\n effect: getAttr($this, \"effect\", \"slide\"),\n speed: getAttr($this, \"speed\", 700),\n spaceBetween: getAttr($this, \"spaceBetween\", 0),\n allowTouchMove: getAttr($this, \"allowTouchMove\", false),\n breakpoints: {\n 478: {\n slidesPerView: getAttr($this, \"landscapeSlides\", \"auto\"),\n centeredSlides: getAttr($this, \"landscapeCenteredSlides\", false),\n },\n 767: {\n slidesPerView: getAttr($this, \"tabletSlides\", \"auto\"),\n centeredSlides: getAttr($this, \"tabletCenteredSlides\", false),\n },\n 991: {\n slidesPerView: getAttr($this, \"slides\", \"auto\"),\n centeredSlides: getAttr($this, \"centeredSlides\", false),\n },\n },\n };\n\n //------- Modules --------------------------------\n const autoplayMode = getAttr($this, \"autoplayMode\", false);\n printDebug(\"AUTOPLAY MODE\", autoplayMode);\n\n const paginationMode = getAttr($this, \"paginationMode\", false);\n printDebug(\"PAGINATION MODE\", paginationMode);\n\n const navigationMode = getAttr($this, \"navigationMode\", false);\n printDebug(\"NAVIGATION MODE\", navigationMode);\n\n const scrollbarMode = getAttr($this, \"scrollbarMode\", false);\n printDebug(\"SCROLLBAR MODE\", scrollbarMode);\n\n // AUTOPLAY\n if (autoplayMode) {\n swiperConfig.autoplay = {\n delay: getAttr($this, \"delay\", 0),\n disableOnInteraction: getAttr($this, \"disableOnInteraction\", false),\n reverseDirection: getAttr($this, \"reverseDirection\", false),\n pauseOnMouseEnter: getAttr($this, \"pauseOnMouseEnter\", false),\n stopOnLastSlide: getAttr($this, \"stopOnLastSlide\", false),\n };\n }\n\n // PAGINATION\n const paginationEl = $this.find(\"[waterfall-el='pagination']\")[0];\n printDebug(\"PAGINATION\", paginationEl);\n\n if (paginationMode) {\n swiperConfig.pagination = {\n el: paginationEl,\n clickable: getAttr($this, \"paginationClickable\", true),\n bulletClass: $this.find(\"[waterfall-el='pagination-bullet']\").attr(\"class\"),\n bulletActiveClass: $this.find(\"[waterfall-pagination-active-class]\").attr(\"waterfall-pagination-active-class\"),\n type: \"bullets\",\n dynamicBullets: false,\n };\n }\n\n // NAVIGATION\n if (navigationMode) {\n swiperConfig.navigation = {\n nextEl: $this.find(\"[waterfall-el='next']\")[0],\n prevEl: $this.find(\"[waterfall-el='prev']\")[0],\n };\n printDebug(\"NEXT BUTTON\", swiperConfig.navigation.nextEl);\n printDebug(\"PREV BUTTON\", swiperConfig.navigation.prevEl);\n }\n\n // SCROLLBAR\n const scrollbarEl = $this.find(\"[waterfall-el='scrollbar']\")[0];\n printDebug(\"SCROLLBAR\", scrollbarEl);\n const scrollbarDrag = $(scrollbarEl).find(\"[waterfall-el='scrollbar-drag']\")[0];\n printDebug(\"SCROLLBAR DRAG\", scrollbarDrag);\n\n if (scrollbarMode) {\n swiperConfig.scrollbar = {\n dragClass: $(scrollbarDrag).attr(\"class\"),\n dragSize: getAttr($this, \"dragSize\", true),\n draggable: getAttr($this, \"draggable\", true),\n el: scrollbarEl,\n enabled: getAttr($this, \"scrollbarEnabled\", true),\n hide: getAttr($this, \"scrollbarHide\", true),\n horizontalClass: getAttr($this, \"scrollbarHorizontalClass\", \"swiper-scrollbar-horizontal\"),\n lockClass: getAttr($this, \"scrollbarLockClass\", \"swiper-scrollbar-lock\"),\n scrollbarDisabledClass: getAttr($this, \"scrollbarDisabledClass\", \"swiper-scrollbar-disabled\"),\n snapOnRelease: getAttr($this, \"snapOnRelease\", false),\n verticalClass: getAttr($this, \"scrollbarVerticalClass\", \"swiper-scrollbar-vertical\"),\n };\n }\n\n // Initialize swiper\n const swiper = new swiper_bundle__WEBPACK_IMPORTED_MODULE_0__[\"default\"]($this.find(\".swiper\")[0], swiperConfig);\n\n sliders.push({ name, slider: swiper });\n});\n\n\n//# sourceURL=webpack://Waterfall/./src/waterfall.js?");
|
|
140
140
|
|
|
141
141
|
/***/ }),
|
|
142
142
|
|
package/package.json
CHANGED
package/src/waterfall.js
CHANGED
|
@@ -5,18 +5,24 @@ import 'swiper/css/bundle';
|
|
|
5
5
|
|
|
6
6
|
const sliders = [];
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// Helper function to get an attribute with type conversion
|
|
9
|
+
function getAttr(el, attrName, defaultValue) {
|
|
10
|
+
const value = $(el).attr(attrName);
|
|
11
|
+
if (value === undefined || value === null) return defaultValue;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
if (typeof defaultValue === "boolean") {
|
|
14
|
+
return value === "true";
|
|
15
|
+
}
|
|
16
|
+
if (typeof defaultValue === "number") {
|
|
17
|
+
return parseInt(value, 10);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
$("[waterfall]").each(function (index) {
|
|
17
23
|
const $this = $(this);
|
|
18
|
-
const name =
|
|
19
|
-
const debug =
|
|
24
|
+
const name = getAttr($this, "waterfall", `Swiper ${index}`);
|
|
25
|
+
const debug = getAttr($this, "debugMode", false);
|
|
20
26
|
|
|
21
27
|
function printDebug(str, el) {
|
|
22
28
|
if (!debug) return;
|
|
@@ -24,54 +30,51 @@ $("[waterfall]").each(function (index) {
|
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
const swiperConfig = {
|
|
27
|
-
slidesPerView:
|
|
28
|
-
centeredSlides:
|
|
29
|
-
direction:
|
|
30
|
-
loop:
|
|
31
|
-
effect:
|
|
32
|
-
speed:
|
|
33
|
-
spaceBetween:
|
|
34
|
-
allowTouchMove:
|
|
33
|
+
slidesPerView: getAttr($this, "portraitSlides", "auto"),
|
|
34
|
+
centeredSlides: getAttr($this, "portraitCenteredSlides", false),
|
|
35
|
+
direction: getAttr($this, "direction", "horizontal"),
|
|
36
|
+
loop: getAttr($this, "loopMode", false),
|
|
37
|
+
effect: getAttr($this, "effect", "slide"),
|
|
38
|
+
speed: getAttr($this, "speed", 700),
|
|
39
|
+
spaceBetween: getAttr($this, "spaceBetween", 0),
|
|
40
|
+
allowTouchMove: getAttr($this, "allowTouchMove", false),
|
|
35
41
|
breakpoints: {
|
|
36
42
|
478: {
|
|
37
|
-
slidesPerView:
|
|
38
|
-
centeredSlides:
|
|
43
|
+
slidesPerView: getAttr($this, "landscapeSlides", "auto"),
|
|
44
|
+
centeredSlides: getAttr($this, "landscapeCenteredSlides", false),
|
|
39
45
|
},
|
|
40
46
|
767: {
|
|
41
|
-
slidesPerView:
|
|
42
|
-
centeredSlides:
|
|
47
|
+
slidesPerView: getAttr($this, "tabletSlides", "auto"),
|
|
48
|
+
centeredSlides: getAttr($this, "tabletCenteredSlides", false),
|
|
43
49
|
},
|
|
44
50
|
991: {
|
|
45
|
-
slidesPerView:
|
|
46
|
-
centeredSlides:
|
|
51
|
+
slidesPerView: getAttr($this, "slides", "auto"),
|
|
52
|
+
centeredSlides: getAttr($this, "centeredSlides", false),
|
|
47
53
|
},
|
|
48
|
-
}
|
|
54
|
+
},
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
//------- Modules --------------------------------
|
|
52
|
-
const autoplayMode =
|
|
58
|
+
const autoplayMode = getAttr($this, "autoplayMode", false);
|
|
53
59
|
printDebug("AUTOPLAY MODE", autoplayMode);
|
|
54
60
|
|
|
55
|
-
const paginationMode =
|
|
61
|
+
const paginationMode = getAttr($this, "paginationMode", false);
|
|
56
62
|
printDebug("PAGINATION MODE", paginationMode);
|
|
57
63
|
|
|
58
|
-
const navigationMode =
|
|
59
|
-
printDebug(
|
|
64
|
+
const navigationMode = getAttr($this, "navigationMode", false);
|
|
65
|
+
printDebug("NAVIGATION MODE", navigationMode);
|
|
60
66
|
|
|
61
|
-
const scrollbarMode =
|
|
67
|
+
const scrollbarMode = getAttr($this, "scrollbarMode", false);
|
|
62
68
|
printDebug("SCROLLBAR MODE", scrollbarMode);
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
66
70
|
// AUTOPLAY
|
|
67
|
-
|
|
68
71
|
if (autoplayMode) {
|
|
69
72
|
swiperConfig.autoplay = {
|
|
70
|
-
delay:
|
|
71
|
-
disableOnInteraction:
|
|
72
|
-
reverseDirection:
|
|
73
|
-
pauseOnMouseEnter:
|
|
74
|
-
stopOnLastSlide:
|
|
73
|
+
delay: getAttr($this, "delay", 0),
|
|
74
|
+
disableOnInteraction: getAttr($this, "disableOnInteraction", false),
|
|
75
|
+
reverseDirection: getAttr($this, "reverseDirection", false),
|
|
76
|
+
pauseOnMouseEnter: getAttr($this, "pauseOnMouseEnter", false),
|
|
77
|
+
stopOnLastSlide: getAttr($this, "stopOnLastSlide", false),
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -82,7 +85,7 @@ $("[waterfall]").each(function (index) {
|
|
|
82
85
|
if (paginationMode) {
|
|
83
86
|
swiperConfig.pagination = {
|
|
84
87
|
el: paginationEl,
|
|
85
|
-
clickable:
|
|
88
|
+
clickable: getAttr($this, "paginationClickable", true),
|
|
86
89
|
bulletClass: $this.find("[waterfall-el='pagination-bullet']").attr("class"),
|
|
87
90
|
bulletActiveClass: $this.find("[waterfall-pagination-active-class]").attr("waterfall-pagination-active-class"),
|
|
88
91
|
type: "bullets",
|
|
@@ -109,16 +112,16 @@ $("[waterfall]").each(function (index) {
|
|
|
109
112
|
if (scrollbarMode) {
|
|
110
113
|
swiperConfig.scrollbar = {
|
|
111
114
|
dragClass: $(scrollbarDrag).attr("class"),
|
|
112
|
-
dragSize: "
|
|
113
|
-
draggable:
|
|
114
|
-
el:
|
|
115
|
-
enabled: true,
|
|
116
|
-
hide:
|
|
117
|
-
horizontalClass: "swiper-scrollbar-horizontal",
|
|
118
|
-
lockClass: "swiper-scrollbar-lock",
|
|
119
|
-
scrollbarDisabledClass: "swiper-scrollbar-disabled",
|
|
120
|
-
snapOnRelease: false,
|
|
121
|
-
verticalClass: "swiper-scrollbar-vertical",
|
|
115
|
+
dragSize: getAttr($this, "dragSize", true),
|
|
116
|
+
draggable: getAttr($this, "draggable", true),
|
|
117
|
+
el: scrollbarEl,
|
|
118
|
+
enabled: getAttr($this, "scrollbarEnabled", true),
|
|
119
|
+
hide: getAttr($this, "scrollbarHide", true),
|
|
120
|
+
horizontalClass: getAttr($this, "scrollbarHorizontalClass", "swiper-scrollbar-horizontal"),
|
|
121
|
+
lockClass: getAttr($this, "scrollbarLockClass", "swiper-scrollbar-lock"),
|
|
122
|
+
scrollbarDisabledClass: getAttr($this, "scrollbarDisabledClass", "swiper-scrollbar-disabled"),
|
|
123
|
+
snapOnRelease: getAttr($this, "snapOnRelease", false),
|
|
124
|
+
verticalClass: getAttr($this, "scrollbarVerticalClass", "swiper-scrollbar-vertical"),
|
|
122
125
|
};
|
|
123
126
|
}
|
|
124
127
|
|
|
@@ -126,4 +129,4 @@ $("[waterfall]").each(function (index) {
|
|
|
126
129
|
const swiper = new Swiper($this.find(".swiper")[0], swiperConfig);
|
|
127
130
|
|
|
128
131
|
sliders.push({ name, slider: swiper });
|
|
129
|
-
});
|
|
132
|
+
});
|