@widelab-nc/widelab 1.1.36 → 1.1.37
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 +82 -96
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -16,6 +16,23 @@ function customGsapEasing() {
|
|
|
16
16
|
CustomEase.create('loader2', '0.77, 0, 0.175, 1');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
// Smoothly scrolls to section if current URL contains a hash
|
|
20
|
+
function scrollToHashOnLoad(offsetY = 0) {
|
|
21
|
+
window.addEventListener('load', () => {
|
|
22
|
+
const hash = window.location.hash;
|
|
23
|
+
if (!hash) return;
|
|
24
|
+
|
|
25
|
+
const target = document.querySelector(hash);
|
|
26
|
+
if (!target) return;
|
|
27
|
+
|
|
28
|
+
gsap.to(window, {
|
|
29
|
+
scrollTo: { y: target, offsetY: offsetY },
|
|
30
|
+
duration: 1,
|
|
31
|
+
ease: 'power2.out'
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
19
36
|
// Functions definitions
|
|
20
37
|
|
|
21
38
|
// Contact form open animation
|
|
@@ -343,53 +360,75 @@ window.customCursorTextUpdate = function(el) {
|
|
|
343
360
|
);
|
|
344
361
|
}
|
|
345
362
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
width: '100%',
|
|
352
|
-
duration: 0.35,
|
|
353
|
-
ease: 'loader2',
|
|
354
|
-
paused: true,
|
|
355
|
-
});
|
|
356
|
-
ScrollTrigger.create({
|
|
357
|
-
animation: maskAnimation,
|
|
358
|
-
trigger: mask,
|
|
359
|
-
start: 'top 80%',
|
|
360
|
-
onEnter: () => maskAnimation.play(),
|
|
361
|
-
});
|
|
363
|
+
// Case study mask animation + pill fade-in (last step)
|
|
364
|
+
window.caseStudyInteraction = function (e) {
|
|
365
|
+
// Video mask + pill timeline
|
|
366
|
+
const mask = e.querySelector('.portfolio_item_image-mask');
|
|
367
|
+
const pill = e.querySelector('.cs_pill');
|
|
362
368
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
369
|
+
// Build a single timeline so the pill fades in AFTER the mask animation
|
|
370
|
+
const tl = gsap.timeline({
|
|
371
|
+
paused: true,
|
|
372
|
+
defaults: { ease: 'loader2' }
|
|
373
|
+
});
|
|
368
374
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
372
|
-
e.addEventListener('mouseenter', hoverIN, false);
|
|
373
|
-
e.addEventListener('mouseleave', hoverOUT, false);
|
|
375
|
+
// Ensure pill starts hidden
|
|
376
|
+
if (pill) gsap.set(pill, { autoAlpha: 0 }); // autoAlpha controls visibility + opacity
|
|
374
377
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
+
// Mask reveals first...
|
|
379
|
+
tl.from(mask, {
|
|
380
|
+
width: '100%',
|
|
381
|
+
duration: 0.35
|
|
382
|
+
});
|
|
378
383
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
384
|
+
// ...then pill fades in as the last step
|
|
385
|
+
if (pill) {
|
|
386
|
+
tl.to(pill, {
|
|
387
|
+
autoAlpha: 1,
|
|
388
|
+
duration: 0.25
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Trigger on scroll
|
|
393
|
+
ScrollTrigger.create({
|
|
394
|
+
animation: tl,
|
|
395
|
+
trigger: mask,
|
|
396
|
+
start: 'top 80%',
|
|
397
|
+
onEnter: () => tl.play()
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Video on hover actions
|
|
401
|
+
const videoElements = e.getElementsByTagName('video');
|
|
402
|
+
if (window.innerWidth > 992) {
|
|
403
|
+
const videoElement = videoElements.length > 0 ? videoElements[0] : null;
|
|
404
|
+
if (!videoElement) return;
|
|
405
|
+
|
|
406
|
+
videoElement.addEventListener('loadeddata', () => {
|
|
407
|
+
videoElement.pause();
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
e.addEventListener('mouseenter', hoverIN, false);
|
|
411
|
+
e.addEventListener('mouseleave', hoverOUT, false);
|
|
412
|
+
|
|
413
|
+
function hoverIN() {
|
|
414
|
+
videoElement.play();
|
|
391
415
|
}
|
|
416
|
+
|
|
417
|
+
function hoverOUT() {
|
|
418
|
+
videoElement.pause();
|
|
419
|
+
// videoElement.currentTime = 0;
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
// Mobile: keep poster only
|
|
423
|
+
Array.from(videoElements).forEach((videoElem) => {
|
|
424
|
+
const poster = videoElem.getAttribute('poster');
|
|
425
|
+
videoElem.innerHTML = '';
|
|
426
|
+
videoElem.setAttribute('poster', poster);
|
|
427
|
+
videoElem.load();
|
|
428
|
+
videoElem.pause();
|
|
429
|
+
});
|
|
392
430
|
}
|
|
431
|
+
};
|
|
393
432
|
|
|
394
433
|
// Reviews slider
|
|
395
434
|
window.reviewsSlider = function(e) {
|
|
@@ -446,61 +485,6 @@ window.customCursorTextUpdate = function(el) {
|
|
|
446
485
|
});
|
|
447
486
|
}
|
|
448
487
|
|
|
449
|
-
// Reviews slider
|
|
450
|
-
window.reviewsSlider = function(e) {
|
|
451
|
-
// Put content of static slide into list
|
|
452
|
-
const staticContent = e.querySelector(
|
|
453
|
-
'.splide__slide.reviews_collection_item.is-static'
|
|
454
|
-
).innerHTML;
|
|
455
|
-
const dynamicElement = e.querySelector('.reviews_collection_item');
|
|
456
|
-
dynamicElement.innerHTML = staticContent;
|
|
457
|
-
dynamicElement.classList.add('is-static');
|
|
458
|
-
|
|
459
|
-
// Init reviews splide
|
|
460
|
-
const reviewsSplide = new Splide(e, {
|
|
461
|
-
type: 'slide',
|
|
462
|
-
fixedWidth: '24.5rem',
|
|
463
|
-
rewind: true,
|
|
464
|
-
focus: 0,
|
|
465
|
-
padding: { left: '2.5rem', right: 0 },
|
|
466
|
-
gap: 0,
|
|
467
|
-
omitEnd: true,
|
|
468
|
-
arrows: false,
|
|
469
|
-
drag: false,
|
|
470
|
-
easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
|
|
471
|
-
snap: true,
|
|
472
|
-
classes: {
|
|
473
|
-
pagination: 'splide__pagination reviews-pagination',
|
|
474
|
-
page: 'splide__pagination__page reviews-page',
|
|
475
|
-
},
|
|
476
|
-
breakpoints: {
|
|
477
|
-
992: { fixedWidth: '17.438rem', padding: { left: '1.75rem' }, drag: 'free', snap: false },
|
|
478
|
-
480: { fixedWidth: '16.25rem', padding: { left: '1.375rem' }},
|
|
479
|
-
},
|
|
480
|
-
}).mount();
|
|
481
|
-
|
|
482
|
-
// Next slide on click
|
|
483
|
-
if (window.innerWidth > 992) {
|
|
484
|
-
reviewsSplide.on('click', function () {
|
|
485
|
-
reviewsSplide.go('+1');
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Animation in
|
|
490
|
-
gsap.from(e, {
|
|
491
|
-
scrollTrigger: {
|
|
492
|
-
trigger: e,
|
|
493
|
-
start: 'top bottom',
|
|
494
|
-
end: 'bottom bottom-=15%',
|
|
495
|
-
scrub: 1,
|
|
496
|
-
once: true,
|
|
497
|
-
},
|
|
498
|
-
x: '10%',
|
|
499
|
-
opacity: 0,
|
|
500
|
-
ease: 'linear',
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
|
|
504
488
|
// Facts slider
|
|
505
489
|
window.factsSlider = function(e) {
|
|
506
490
|
// Facts slider splide initialize
|
|
@@ -1684,6 +1668,7 @@ window.initBentoRevealScrub = function (container) {
|
|
|
1684
1668
|
}
|
|
1685
1669
|
);
|
|
1686
1670
|
};
|
|
1671
|
+
|
|
1687
1672
|
window.initPartnerVideos = function (container) {
|
|
1688
1673
|
const items = Array.from(container.querySelectorAll('.partner_item'));
|
|
1689
1674
|
const vids = items.map(i => i.querySelector('video')).filter(Boolean);
|
|
@@ -2045,4 +2030,5 @@ window.closeInfoBar = function() {
|
|
|
2045
2030
|
customCursorOnClick();
|
|
2046
2031
|
contactFormOpenAnimation();
|
|
2047
2032
|
disableScrollMenu();
|
|
2033
|
+
scrollToHashOnLoad();
|
|
2048
2034
|
});
|