@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widelab-nc/widelab",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "description": "Widelab starter template based on Finsweet template + add-ons.",
5
5
  "homepage": "https://widelab.co",
6
6
  "license": "ISC",
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 ticking = false;
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 update() {
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
- var progress = Math.min(1, Math.max(0, scrolled / total));
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 onScrollOrResize() {
562
- if (!ticking) {
563
- requestAnimationFrame(update);
564
- ticking = true;
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
- window.addEventListener('scroll', onScrollOrResize, { passive: true });
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({}),