@widelab-nc/widelab 1.1.43 → 1.1.44
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 +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/index.js +19 -24
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -513,6 +513,8 @@ window.customCursorTextUpdate = function(el) {
|
|
|
513
513
|
el.addEventListener('pointerleave', maybeDeactivate);
|
|
514
514
|
};
|
|
515
515
|
|
|
516
|
+
|
|
517
|
+
|
|
516
518
|
window.stickyServices = function (e) {
|
|
517
519
|
var wrapper = e;
|
|
518
520
|
if (!wrapper || wrapper.dataset.stickyServicesInit === 'true') return;
|
|
@@ -525,12 +527,11 @@ window.stickyServices = function (e) {
|
|
|
525
527
|
if (count === 0) return;
|
|
526
528
|
|
|
527
529
|
var currentActive = -1;
|
|
528
|
-
var
|
|
530
|
+
var displayedProgress = 0;
|
|
529
531
|
|
|
530
532
|
function setActive(index) {
|
|
531
533
|
if (index === currentActive) return;
|
|
532
534
|
currentActive = index;
|
|
533
|
-
|
|
534
535
|
for (var i = 0; i < navItems.length; i++) {
|
|
535
536
|
navItems[i].classList.toggle('is-active', i === index);
|
|
536
537
|
}
|
|
@@ -539,39 +540,33 @@ window.stickyServices = function (e) {
|
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
542
|
|
|
542
|
-
function
|
|
543
|
-
ticking = false;
|
|
544
|
-
|
|
543
|
+
function getTargetProgress() {
|
|
545
544
|
var rect = wrapper.getBoundingClientRect();
|
|
546
545
|
var total = wrapper.offsetHeight - window.innerHeight;
|
|
547
|
-
|
|
548
|
-
// Wrapper not tall enough to scroll through (e.g. very tall viewport) — keep first item active.
|
|
549
|
-
if (total <= 0) {
|
|
550
|
-
setActive(0);
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
|
|
546
|
+
if (total <= 0) return 0;
|
|
554
547
|
var scrolled = -rect.top;
|
|
555
|
-
|
|
556
|
-
var activeIndex = Math.min(count - 1, Math.floor(progress * count));
|
|
557
|
-
|
|
558
|
-
setActive(activeIndex);
|
|
548
|
+
return Math.min(1, Math.max(0, scrolled / total));
|
|
559
549
|
}
|
|
560
550
|
|
|
561
|
-
function
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
551
|
+
function loop() {
|
|
552
|
+
var target = getTargetProgress();
|
|
553
|
+
displayedProgress += (target - displayedProgress) * 0.18;
|
|
554
|
+
if (Math.abs(target - displayedProgress) < 0.001) {
|
|
555
|
+
displayedProgress = target;
|
|
565
556
|
}
|
|
557
|
+
var activeIndex = Math.min(count - 1, Math.floor(displayedProgress * count));
|
|
558
|
+
setActive(activeIndex);
|
|
559
|
+
requestAnimationFrame(loop);
|
|
566
560
|
}
|
|
567
561
|
|
|
568
|
-
|
|
569
|
-
window.addEventListener('resize', onScrollOrResize);
|
|
570
|
-
|
|
571
|
-
update(); // set correct state immediately on load (handles page-load mid-scroll / refresh position)
|
|
562
|
+
loop();
|
|
572
563
|
};
|
|
573
564
|
|
|
574
565
|
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
575
570
|
window.heroAnimationOnLoad = function(e) {
|
|
576
571
|
const videoMask = e.querySelector('.hero_headline_ract-mask');
|
|
577
572
|
const heroAnimation = gsap.timeline({}),
|