@widelab-nc/widelab 1.1.48 → 1.1.49

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.48",
3
+ "version": "1.1.49",
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
@@ -550,6 +550,7 @@ window.hueAwardsAnimation = function(e) {
550
550
  };
551
551
 
552
552
 
553
+
553
554
  window.expandableProcessSticky = function (e) {
554
555
  var wrapper = e;
555
556
  if (!wrapper || wrapper.dataset.expandableProcessStickyInit === 'true') return;
@@ -559,8 +560,10 @@ window.expandableProcessSticky = function (e) {
559
560
  var count = items.length;
560
561
  if (count === 0) return;
561
562
 
563
+ var mq = window.matchMedia('(max-width: 991px)');
562
564
  var currentActive = -1;
563
565
  var ticking = false;
566
+ var isEnabled = false;
564
567
 
565
568
  function setActive(index) {
566
569
  if (index === currentActive) return;
@@ -611,23 +614,75 @@ window.expandableProcessSticky = function (e) {
611
614
  });
612
615
  }
613
616
 
614
- for (var i = 0; i < items.length; i++) {
615
- (function (index) {
616
- var tab = items[index].closest('.process-wrapper');
617
- if (!tab) return;
618
- tab.addEventListener('click', function (event) {
619
- if (event.target.closest('.process-item')) return;
620
- scrollToIndex(index);
621
- });
622
- })(i);
617
+ function onTabClick(event, index) {
618
+ if (event.target.closest('.process-item')) return;
619
+ scrollToIndex(index);
623
620
  }
624
621
 
625
- window.addEventListener('scroll', onScrollOrResize, { passive: true });
626
- window.addEventListener('resize', onResize);
627
- update();
622
+ var tabClickHandlers = [];
623
+
624
+ function enable() {
625
+ if (isEnabled) return;
626
+ isEnabled = true;
627
+
628
+ for (var i = 0; i < items.length; i++) {
629
+ (function (index) {
630
+ var tab = items[index].closest('.process-wrapper');
631
+ if (!tab) return;
632
+ var handler = function (event) { onTabClick(event, index); };
633
+ tabClickHandlers[index] = { tab: tab, handler: handler };
634
+ tab.addEventListener('click', handler);
635
+ })(i);
636
+ }
637
+
638
+ window.addEventListener('scroll', onScrollOrResize, { passive: true });
639
+ window.addEventListener('resize', onResize);
640
+ update();
641
+ }
642
+
643
+ function disable() {
644
+ if (!isEnabled) return;
645
+ isEnabled = false;
646
+
647
+ window.removeEventListener('scroll', onScrollOrResize);
648
+ window.removeEventListener('resize', onResize);
649
+
650
+ for (var i = 0; i < tabClickHandlers.length; i++) {
651
+ var entry = tabClickHandlers[i];
652
+ if (entry) entry.tab.removeEventListener('click', entry.handler);
653
+ }
654
+ tabClickHandlers = [];
655
+
656
+ // Reset inline styles so mobile falls back to default CSS state.
657
+ for (var j = 0; j < items.length; j++) {
658
+ items[j].classList.remove('is-active');
659
+ items[j].style.height = '';
660
+ }
661
+ currentActive = -1;
662
+ }
663
+
664
+ function handleBreakpointChange(mql) {
665
+ if (mql.matches) {
666
+ // Mobile (<=991px): fully disabled.
667
+ disable();
668
+ } else {
669
+ enable();
670
+ }
671
+ }
672
+
673
+ handleBreakpointChange(mq);
674
+
675
+ if (mq.addEventListener) {
676
+ mq.addEventListener('change', handleBreakpointChange);
677
+ } else if (mq.addListener) {
678
+ // Safari fallback
679
+ mq.addListener(handleBreakpointChange);
680
+ }
628
681
  };
629
682
 
630
683
 
684
+
685
+
631
686
  window.faqDropdowns = function (e) {
632
687
  var wrapper = e;
633
688
  if (!wrapper || wrapper.dataset.faqDropdownsInit === 'true') return;
@@ -703,6 +758,7 @@ window.navbarThemeWatcher = function () {
703
758
  };
704
759
 
705
760
 
761
+
706
762
  window.stickyServices = function (e) {
707
763
  var wrapper = e;
708
764
  if (!wrapper || wrapper.dataset.stickyServicesInit === 'true') return;
@@ -710,10 +766,22 @@ window.stickyServices = function (e) {
710
766
 
711
767
  var navItems = wrapper.querySelectorAll('.services_item-wrapper.is-animated');
712
768
  var stackItems = wrapper.querySelectorAll('.services-stack-img');
769
+ var mobileHandlers = wrapper.querySelectorAll('.mobile-handler');
713
770
 
714
771
  var count = Math.min(navItems.length, stackItems.length);
715
772
  if (count === 0) return;
716
773
 
774
+ // Copy each desktop .service-desc block into its matching .mobile-handler once,
775
+ // so editors only maintain the desktop copy and mobile text stays in sync.
776
+ for (var m = 0; m < count; m++) {
777
+ var sourceDesc = stackItems[m].querySelector('.service-desc');
778
+ var mobileContent = mobileHandlers[m] ? mobileHandlers[m].querySelector('.mobile-content-wrapper') : null;
779
+ if (sourceDesc && mobileContent && !mobileContent.querySelector('.service-desc')) {
780
+ var clonedDesc = sourceDesc.cloneNode(true);
781
+ mobileContent.insertBefore(clonedDesc, mobileContent.firstChild);
782
+ }
783
+ }
784
+
717
785
  var currentActive = -1;
718
786
  var displayedProgress = 0;
719
787
  var pendingIndex = -1; // set while a click-triggered scroll is animating
@@ -727,6 +795,12 @@ window.stickyServices = function (e) {
727
795
  for (var j = 0; j < stackItems.length; j++) {
728
796
  stackItems[j].classList.toggle('is-active', j === index);
729
797
  }
798
+ // Mirror the same active state on the mobile accordion panels
799
+ for (var k = 0; k < mobileHandlers.length; k++) {
800
+ var isTarget = k === index;
801
+ mobileHandlers[k].classList.toggle('is-active', isTarget);
802
+ mobileHandlers[k].style.height = isTarget ? mobileHandlers[k].scrollHeight + 'px' : '0px';
803
+ }
730
804
  }
731
805
 
732
806
  function getTargetProgress() {
@@ -746,7 +820,7 @@ window.stickyServices = function (e) {
746
820
  if (pendingIndex !== -1) {
747
821
  var pendingProgress = (pendingIndex + 0.5) / count;
748
822
  if (Math.abs(target - pendingProgress) < 0.02) {
749
- pendingIndex = -1; // real scroll has caught up, resume normal driving
823
+ pendingIndex = -1;
750
824
  } else {
751
825
  setActive(pendingIndex);
752
826
  requestAnimationFrame(loop);
@@ -783,18 +857,28 @@ window.stickyServices = function (e) {
783
857
  });
784
858
  }
785
859
 
786
- for (var k = 0; k < navItems.length; k++) {
860
+ for (var n = 0; n < navItems.length; n++) {
787
861
  (function (index) {
788
862
  navItems[index].addEventListener('click', function () {
789
863
  scrollToIndex(index);
790
864
  });
791
- })(k);
865
+ })(n);
792
866
  }
793
867
 
868
+ // Keep the open mobile panel's height correct if its content reflows on resize
869
+ function onResize() {
870
+ if (currentActive === -1) return;
871
+ var openHandler = mobileHandlers[currentActive];
872
+ if (openHandler) openHandler.style.height = openHandler.scrollHeight + 'px';
873
+ }
874
+ window.addEventListener('resize', onResize);
875
+
794
876
  loop();
795
877
  };
796
878
 
797
879
 
880
+
881
+
798
882
  window.heroAnimationOnLoad = function(e) {
799
883
  const videoMask = e.querySelector('.hero_headline_ract-mask');
800
884
  const heroAnimation = gsap.timeline({}),