@widelab-nc/widelab 1.1.32 → 1.1.33
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/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/index.js +67 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1324,6 +1324,73 @@ window.heroSliders = function(e) {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
|
|
1326
1326
|
|
|
1327
|
+
// Splide without GSAP; pagination inserted as first child INSIDE .splide
|
|
1328
|
+
window.awwwardsSliders = function (el) {
|
|
1329
|
+
if (el.dataset.splideInitialized === '1') return;
|
|
1330
|
+
|
|
1331
|
+
// 1) Find or create Splide root
|
|
1332
|
+
let root = el.classList?.contains('splide') ? el : el.closest?.('.splide');
|
|
1333
|
+
const track = el.querySelector?.('.splide__track') || el.closest?.('.splide__track');
|
|
1334
|
+
|
|
1335
|
+
if (!root && track) {
|
|
1336
|
+
root = document.createElement('div');
|
|
1337
|
+
root.className = 'splide testimonial';
|
|
1338
|
+
track.parentNode.insertBefore(root, track);
|
|
1339
|
+
root.appendChild(track);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
// 2) Validate structure
|
|
1343
|
+
if (!root || !root.querySelector('.splide__track') || !root.querySelector('.splide__list')) {
|
|
1344
|
+
console.warn('[awwwardsSliders] Missing required Splide structure.');
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// 3) Splide config
|
|
1349
|
+
const config = {
|
|
1350
|
+
type: 'loop',
|
|
1351
|
+
perPage: 1,
|
|
1352
|
+
perMove: 1,
|
|
1353
|
+
gap: '0px',
|
|
1354
|
+
arrows: false,
|
|
1355
|
+
pagination: true,
|
|
1356
|
+
drag: false,
|
|
1357
|
+
speed: 300,
|
|
1358
|
+
easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
|
|
1359
|
+
classes: {
|
|
1360
|
+
pagination: 'splide__pagination awwwards-pagination',
|
|
1361
|
+
page: 'splide__pagination__page awwwards-page',
|
|
1362
|
+
},
|
|
1363
|
+
breakpoints: {
|
|
1364
|
+
992: { drag: true },
|
|
1365
|
+
},
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
const splide = new Splide(root, config).mount();
|
|
1369
|
+
|
|
1370
|
+
// 4) Move pagination INSIDE .splide as FIRST child
|
|
1371
|
+
splide.on('pagination:mounted', (data) => {
|
|
1372
|
+
const list = data.list;
|
|
1373
|
+
if (list && root.firstChild) {
|
|
1374
|
+
root.insertBefore(list, root.firstChild);
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
// Fallback if pagination already exists
|
|
1379
|
+
queueMicrotask(() => {
|
|
1380
|
+
const list = root.querySelector('.splide__pagination');
|
|
1381
|
+
const track = root.querySelector('.splide__track');
|
|
1382
|
+
if (list && track && list.nextSibling !== track) {
|
|
1383
|
+
root.insertBefore(list, track);
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1387
|
+
// 5) Click-to-next on desktop
|
|
1388
|
+
if (window.innerWidth > 992) {
|
|
1389
|
+
root.addEventListener('click', () => splide.go('+1'));
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
el.dataset.splideInitialized = '1';
|
|
1393
|
+
};
|
|
1327
1394
|
|
|
1328
1395
|
// Sliders on Services page
|
|
1329
1396
|
window.servicesSliders = function(e) {
|