well-waterfall 0.0.1 → 0.0.2
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 +594 -0
- package/package.json +16 -6
- package/src/waterfall.js +102 -0
- package/webpack.config.js +29 -0
- package/src/index.js +0 -171
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "well-waterfall",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"main": "
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "An attribute-based wrapper of SwiperJS for Webflow",
|
|
5
|
+
"main": "waterfall.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "webpack"
|
|
8
9
|
},
|
|
9
10
|
"keywords": [],
|
|
10
|
-
"author": "",
|
|
11
|
-
"license": "ISC"
|
|
11
|
+
"author": "kevingerstner",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"css-loader": "^7.1.2",
|
|
15
|
+
"style-loader": "^4.0.0",
|
|
16
|
+
"swiper": "^11.1.14",
|
|
17
|
+
"webpack": "^5.95.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"webpack-cli": "^5.1.4"
|
|
21
|
+
}
|
|
12
22
|
}
|
package/src/waterfall.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
console.log("🚿 Hello from Wellflow Waterfall");
|
|
2
|
+
|
|
3
|
+
import Swiper from 'swiper/bundle';
|
|
4
|
+
import 'swiper/css/bundle';
|
|
5
|
+
|
|
6
|
+
const sliders = [];
|
|
7
|
+
|
|
8
|
+
function parseBool(attr) {
|
|
9
|
+
return attr === "true";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getAttrOrDefault(el, attrName, defaultValue) {
|
|
13
|
+
return $(el).attr(attrName) || defaultValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
$(".waterfall").each(function (index) {
|
|
17
|
+
const $this = $(this);
|
|
18
|
+
const name = getAttrOrDefault($this, "slidername", `Slider ${index}`);
|
|
19
|
+
|
|
20
|
+
const swiperConfig = {
|
|
21
|
+
slidesPerView: getAttrOrDefault($this, "portraitSlides", "auto"),
|
|
22
|
+
centeredSlides: parseBool(getAttrOrDefault($this, "portraitCenteredSlides", false)),
|
|
23
|
+
direction: getAttrOrDefault($this, "direction", "horizontal"),
|
|
24
|
+
loop: parseBool(getAttrOrDefault($this, "loopMode", false)),
|
|
25
|
+
effect: getAttrOrDefault($this, "effect", "slide"),
|
|
26
|
+
speed: parseInt(getAttrOrDefault($this, "speed", 700), 10),
|
|
27
|
+
spaceBetween: parseInt(getAttrOrDefault($this, "spaceBetween", 0), 10),
|
|
28
|
+
allowTouchMove: parseBool(getAttrOrDefault($this, "allowTouchMove", false)),
|
|
29
|
+
breakpoints: {
|
|
30
|
+
478: {
|
|
31
|
+
slidesPerView: getAttrOrDefault($this, "landscapeSlides", "auto"),
|
|
32
|
+
centeredSlides: parseBool(getAttrOrDefault($this, "landscapeCenteredSlides", false)),
|
|
33
|
+
},
|
|
34
|
+
767: {
|
|
35
|
+
slidesPerView: getAttrOrDefault($this, "tabletSlides", "auto"),
|
|
36
|
+
centeredSlides: parseBool(getAttrOrDefault($this, "tabletCenteredSlides", false)),
|
|
37
|
+
},
|
|
38
|
+
991: {
|
|
39
|
+
slidesPerView: getAttrOrDefault($this, "slides", "auto"),
|
|
40
|
+
centeredSlides: parseBool(getAttrOrDefault($this, "centeredSlides", false)),
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Autoplay configuration
|
|
46
|
+
if (parseBool(getAttrOrDefault($this, "autoplayMode", false))) {
|
|
47
|
+
swiperConfig.autoplay = {
|
|
48
|
+
delay: parseInt(getAttrOrDefault($this, "delay", 0), 10),
|
|
49
|
+
disableOnInteraction: parseBool(getAttrOrDefault($this, "disableOnInteraction", false)),
|
|
50
|
+
reverseDirection: parseBool(getAttrOrDefault($this, "reverseDirection", false)),
|
|
51
|
+
pauseOnMouseEnter: parseBool(getAttrOrDefault($this, "pauseOnMouseEnter", false)),
|
|
52
|
+
stopOnLastSlide: parseBool(getAttrOrDefault($this, "stopOnLastSlide", false)),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Pagination configuration
|
|
57
|
+
const paginationEl = $this.find("[waterfall-el='pagination']")[0];
|
|
58
|
+
if (paginationEl && parseBool(getAttrOrDefault($this, "paginationMode", false))) {
|
|
59
|
+
swiperConfig.pagination = {
|
|
60
|
+
el: paginationEl,
|
|
61
|
+
clickable: parseBool(getAttrOrDefault($this, "paginationClickable", true)),
|
|
62
|
+
bulletClass: $this.find("[waterfall-el='pagination-bullet']").attr("class"),
|
|
63
|
+
bulletActiveClass: $this.find("[waterfall-pagination-class]").attr("waterfall-pagination-class"),
|
|
64
|
+
type: "bullets",
|
|
65
|
+
dynamicBullets: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Navigation configuration
|
|
70
|
+
if (parseBool(getAttrOrDefault($this, "navigationMode", false))) {
|
|
71
|
+
swiperConfig.navigation = {
|
|
72
|
+
nextEl: $this.find("[waterfall-el='next']")[0],
|
|
73
|
+
prevEl: $this.find("[waterfall-el='prev']")[0],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Scrollbar configuration
|
|
78
|
+
const scrollbarEl = $this.find("[waterfall-el='scrollbar']");
|
|
79
|
+
console.log("SCROLLBAR: ", scrollbarEl);
|
|
80
|
+
if (scrollbarEl && parseBool(getAttrOrDefault($this, "scrollbarMode", false))) {
|
|
81
|
+
swiperConfig.scrollbar = {
|
|
82
|
+
dragClass: $(scrollbarEl)
|
|
83
|
+
.find("[waterfall-el='scrollbar-drag']")
|
|
84
|
+
.attr("class"),
|
|
85
|
+
dragSize: "auto",
|
|
86
|
+
draggable: false,
|
|
87
|
+
el: "." + scrollbarEl.attr("class"),
|
|
88
|
+
enabled: true,
|
|
89
|
+
hide: false,
|
|
90
|
+
horizontalClass: "swiper-scrollbar-horizontal",
|
|
91
|
+
lockClass: "swiper-scrollbar-lock",
|
|
92
|
+
scrollbarDisabledClass: "swiper-scrollbar-disabled",
|
|
93
|
+
snapOnRelease: false,
|
|
94
|
+
verticalClass: "swiper-scrollbar-vertical",
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Initialize swiper
|
|
99
|
+
const swiper = new Swiper($this.find(".swiper")[0], swiperConfig);
|
|
100
|
+
|
|
101
|
+
sliders.push({ name, slider: swiper });
|
|
102
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// webpack.config.js
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
entry: "./src/waterfall.js",
|
|
6
|
+
output: {
|
|
7
|
+
path: path.resolve(__dirname, 'dist'),
|
|
8
|
+
filename: 'waterfall.js', // Output bundle file
|
|
9
|
+
library: 'Waterfall', // Name of the global variable if your package is used in the browser
|
|
10
|
+
libraryTarget: 'umd', // Universal module definition, for browser and Node.js
|
|
11
|
+
globalObject: 'this', // Ensures compatibility in different environments
|
|
12
|
+
},
|
|
13
|
+
module: {
|
|
14
|
+
rules: [
|
|
15
|
+
{
|
|
16
|
+
test: /\.css$/, // Apply this rule to all `.css` files
|
|
17
|
+
use: [
|
|
18
|
+
'style-loader', // Injects CSS into the DOM
|
|
19
|
+
'css-loader', // Turns CSS into CommonJS
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
externals: {
|
|
25
|
+
// Any dependencies you don't want to include in your bundle
|
|
26
|
+
'some-other-external': 'commonjs2 some-other-external',
|
|
27
|
+
},
|
|
28
|
+
mode: 'development', // Can be 'development' for debugging
|
|
29
|
+
};
|
package/src/index.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WEBFLOW WATERFALL SLIDER
|
|
3
|
-
*
|
|
4
|
-
* Include in Head:
|
|
5
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"/>
|
|
6
|
-
*
|
|
7
|
-
* Include in Body:
|
|
8
|
-
* <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
|
|
9
|
-
**/
|
|
10
|
-
|
|
11
|
-
let sliders = [];
|
|
12
|
-
|
|
13
|
-
$(".slider-component").each(function (index) {
|
|
14
|
-
let name = $(this).attr("slidername") || `Slider ${index}`;
|
|
15
|
-
console.log($(this).attr("slidername"));
|
|
16
|
-
// all
|
|
17
|
-
let loopMode = $(this).attr("loopMode") || false;
|
|
18
|
-
let speed = $(this).attr("speed") || 700;
|
|
19
|
-
let effect = $(this).attr("effect") || "slide";
|
|
20
|
-
let direction = $(this).attr("direction") || "horizontal";
|
|
21
|
-
|
|
22
|
-
// autoplay
|
|
23
|
-
let autoplay = $(this).attr("autoplayMode") === "true" || null;
|
|
24
|
-
let delay = $(this).attr("delay") || 0;
|
|
25
|
-
console.log("AUTOPLAY:", autoplay);
|
|
26
|
-
let disableOnInteraction = $(this).attr("disableOnInteraction") || false;
|
|
27
|
-
let pauseOnMouseEnter = $(this).attr("pauseOnMouseEnter") || false;
|
|
28
|
-
let reverseDirection = $(this).attr("reverseDirection") || false;
|
|
29
|
-
console.log($(this).attr("reverseDirection"));
|
|
30
|
-
let stopOnLastSlide = $(this).attr("stopOnLastSlide") || false;
|
|
31
|
-
|
|
32
|
-
let spaceBetween = $(this).attr("spaceBetween") || 0;
|
|
33
|
-
let allowTouchMove = $(this).attr("allowTouchMove") === "true" || false;
|
|
34
|
-
|
|
35
|
-
let autoplayConfig = {
|
|
36
|
-
delay: autoplay,
|
|
37
|
-
disableOnInteraction: disableOnInteraction,
|
|
38
|
-
reverseDirection: reverseDirection,
|
|
39
|
-
pauseOnMouseEnter: pauseOnMouseEnter,
|
|
40
|
-
stopOnLastSlide: stopOnLastSlide,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// pagination
|
|
44
|
-
let paginationEl = $(this).find(".swiper-pagination")[0];
|
|
45
|
-
let pagination = paginationEl != null;
|
|
46
|
-
let paginationBullet = $(paginationEl).find(".swiper-pagination-bullet")[0];
|
|
47
|
-
let paginationBulletClass = getBulletClass(paginationBullet);
|
|
48
|
-
let paginationClickable = $(this).attr("paginationClickable") || true;
|
|
49
|
-
let paginationNumbers = $(paginationEl).attr("numbers") || true;
|
|
50
|
-
|
|
51
|
-
let paginationConfig = {
|
|
52
|
-
bulletActiveClass: "is-active",
|
|
53
|
-
bulletClass: "swiper-pagination-bullet",
|
|
54
|
-
bulletElement: "button",
|
|
55
|
-
clickable: paginationClickable,
|
|
56
|
-
el: paginationEl,
|
|
57
|
-
renderBullet: function (index, className) {
|
|
58
|
-
// Adds 'my-custom-bullet' class to each bullet along with the default class
|
|
59
|
-
return `<span class="${className} ${paginationBulletClass}">
|
|
60
|
-
${paginationNumbers === "true" ? "uh" : ""}
|
|
61
|
-
</span>`;
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// navigation
|
|
66
|
-
let nextEl = $(this).find(".swiper-next")[0];
|
|
67
|
-
let prevEl = $(this).find(".swiper-prev")[0];
|
|
68
|
-
let navigation = nextEl != null || prevEl != null;
|
|
69
|
-
|
|
70
|
-
let navigationConfig = {
|
|
71
|
-
disabledClass: "swiper-button-disabled",
|
|
72
|
-
enabled: true,
|
|
73
|
-
hiddenClass: "swiper-button-hidden",
|
|
74
|
-
hideOnClick: false,
|
|
75
|
-
lockClass: "swiper-button-lock",
|
|
76
|
-
navigationDisabledClass: "swiper-navigation-disabled",
|
|
77
|
-
nextEl: nextEl,
|
|
78
|
-
prevEl: prevEl,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// scrollbar
|
|
82
|
-
let scrollbarEl = $(this).find(".swiper-scrollbar")[0];
|
|
83
|
-
|
|
84
|
-
let scrollbarConfig = {
|
|
85
|
-
dragClass: "swiper-scrollbar-drag",
|
|
86
|
-
dragSize: "auto",
|
|
87
|
-
draggable: false,
|
|
88
|
-
el: scrollbarEl,
|
|
89
|
-
enabled: true,
|
|
90
|
-
hide: false,
|
|
91
|
-
horizontalClass: "swiper-scrollbar-horizontal",
|
|
92
|
-
lockClass: "swiper-scrollbar-lock",
|
|
93
|
-
scrollbarDisabledClass: "swiper-scrollbar-disabled",
|
|
94
|
-
snapOnRelease: false,
|
|
95
|
-
verticalClass: "swiper-scrollbar-vertical",
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// desktop
|
|
99
|
-
let centeredSlides = $(this).attr("centeredSlides") || false;
|
|
100
|
-
let slides = $(this).attr("slides") || "auto";
|
|
101
|
-
|
|
102
|
-
// tablet
|
|
103
|
-
let tabletSlides = $(this).attr("tabletSlides") || slides;
|
|
104
|
-
let tabletCenteredSlides =
|
|
105
|
-
$(this).attr("tabletCenteredSlides") || centeredSlides;
|
|
106
|
-
|
|
107
|
-
// mobile landscape
|
|
108
|
-
let landscapeSlides = $(this).attr("landscapeSlides") || slides;
|
|
109
|
-
let landscapeCenteredSlides =
|
|
110
|
-
$(this).attr("landscapeCenteredSlides") || tabletCenteredSlides;
|
|
111
|
-
|
|
112
|
-
// mobile portrait
|
|
113
|
-
let portraitSlides = $(this).attr("portraitSlides") || slides;
|
|
114
|
-
let portraitCenteredSlides =
|
|
115
|
-
$(this).attr("portraitCenteredSlides") || landscapeCenteredSlides;
|
|
116
|
-
|
|
117
|
-
// initialize swipers
|
|
118
|
-
const swiper = new Swiper($(this).find(".swiper")[0], {
|
|
119
|
-
slidesPerView: portraitSlides,
|
|
120
|
-
centeredSlides: portraitCenteredSlides,
|
|
121
|
-
direction: direction,
|
|
122
|
-
loop: loopMode,
|
|
123
|
-
...(autoplay && {
|
|
124
|
-
autoplay: autoplayConfig,
|
|
125
|
-
}),
|
|
126
|
-
effect: effect,
|
|
127
|
-
speed: speed,
|
|
128
|
-
spaceBetween: spaceBetween,
|
|
129
|
-
allowTouchMove: allowTouchMove,
|
|
130
|
-
navigation: navigationConfig,
|
|
131
|
-
pagination: paginationConfig,
|
|
132
|
-
scrollbar: scrollbarConfig,
|
|
133
|
-
breakpoints: {
|
|
134
|
-
// Mobile Landscape
|
|
135
|
-
478: {
|
|
136
|
-
slidesPerView: landscapeSlides,
|
|
137
|
-
centeredSlides: landscapeCenteredSlides,
|
|
138
|
-
},
|
|
139
|
-
// Tablet
|
|
140
|
-
767: {
|
|
141
|
-
slidesPerView: tabletSlides,
|
|
142
|
-
centeredSlides: tabletCenteredSlides,
|
|
143
|
-
},
|
|
144
|
-
// Desktop
|
|
145
|
-
991: {
|
|
146
|
-
slidesPerView: slides,
|
|
147
|
-
centeredSlides: centeredSlides,
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
sliders.push({
|
|
153
|
-
name: name,
|
|
154
|
-
slider: swiper,
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
//console.log(sliders);
|
|
159
|
-
|
|
160
|
-
function getBulletClass(element) {
|
|
161
|
-
if (!element) return;
|
|
162
|
-
var allClasses = $(element).attr("class").split(/\s+/);
|
|
163
|
-
// Filter out the class you don't want
|
|
164
|
-
var filteredClasses = allClasses.filter(function (className) {
|
|
165
|
-
return (
|
|
166
|
-
className !== "swiper-pagination-bullet" && className !== "is-active"
|
|
167
|
-
);
|
|
168
|
-
});
|
|
169
|
-
// Join the remaining classes back into a string
|
|
170
|
-
return filteredClasses.join(" ");
|
|
171
|
-
}
|