@widelab-nc/widelab 1.1.45 → 1.1.47

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.45",
3
+ "version": "1.1.47",
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,26 +550,139 @@ window.hueAwardsAnimation = function(e) {
550
550
  };
551
551
 
552
552
 
553
+ window.expandableProcessSticky = function (e) {
554
+ var wrapper = e;
555
+ if (!wrapper || wrapper.dataset.expandableProcessStickyInit === 'true') return;
556
+ wrapper.dataset.expandableProcessStickyInit = 'true';
553
557
 
558
+ var items = wrapper.querySelectorAll('.process-item');
559
+ var count = items.length;
560
+ if (count === 0) return;
554
561
 
562
+ var currentActive = -1;
563
+ var ticking = false;
555
564
 
556
- window.navbarThemeSwitcher = function (e) {
557
- var navbar = document.getElementById('heroNavbar');
558
- if (!navbar) return;
559
- ScrollTrigger.create({
560
- trigger: e,
561
- start: 'top center',
562
- end: 'bottom center',
563
- onEnter: () => navbar.classList.add('is-dark'),
564
- onEnterBack: () => navbar.classList.add('is-dark'),
565
- onLeave: () => navbar.classList.remove('is-dark'),
566
- onLeaveBack: () => navbar.classList.remove('is-dark'),
567
- });
565
+ function setActive(index) {
566
+ if (index === currentActive) return;
567
+ currentActive = index;
568
+ for (var i = 0; i < items.length; i++) {
569
+ var isTarget = i === index;
570
+ items[i].classList.toggle('is-active', isTarget);
571
+ items[i].style.height = isTarget ? items[i].scrollHeight + 'px' : '0px';
572
+ }
573
+ }
574
+
575
+ function update() {
576
+ ticking = false;
577
+ var rect = wrapper.getBoundingClientRect();
578
+ var total = wrapper.offsetHeight - window.innerHeight;
579
+ if (total <= 0) { setActive(0); return; }
580
+ var scrolled = -rect.top;
581
+ var progress = Math.min(1, Math.max(0, scrolled / total));
582
+ var activeIndex = Math.min(count - 1, Math.floor(progress * (count + 1)));
583
+ setActive(activeIndex);
584
+ }
585
+
586
+ function onScrollOrResize() {
587
+ if (!ticking) { requestAnimationFrame(update); ticking = true; }
588
+ }
589
+
590
+ function onResize() {
591
+ onScrollOrResize();
592
+ if (currentActive !== -1) {
593
+ items[currentActive].style.height = items[currentActive].scrollHeight + 'px';
594
+ }
595
+ }
596
+
597
+ window.addEventListener('scroll', onScrollOrResize, { passive: true });
598
+ window.addEventListener('resize', onResize);
599
+ update();
568
600
  };
569
601
 
570
602
 
571
603
 
572
604
 
605
+ window.faqDropdowns = function (e) {
606
+ var wrapper = e;
607
+ if (!wrapper || wrapper.dataset.faqDropdownsInit === 'true') return;
608
+ wrapper.dataset.faqDropdownsInit = 'true';
609
+
610
+ var faqItems = wrapper.querySelectorAll('.faq_ci');
611
+ var count = faqItems.length;
612
+ if (count === 0) return;
613
+
614
+ var currentActive = -1;
615
+
616
+ function setActive(index) {
617
+ currentActive = index;
618
+ for (var i = 0; i < count; i++) {
619
+ var isTarget = i === index;
620
+ var faqCi = faqItems[i];
621
+ var item = faqCi.querySelector('.faq-item');
622
+ var verticalBar = faqCi.querySelector('.is-vertical');
623
+
624
+ if (item) {
625
+ item.classList.toggle('is-active', isTarget);
626
+ item.style.height = isTarget ? item.scrollHeight + 'px' : '0px';
627
+ }
628
+ if (verticalBar) {
629
+ verticalBar.classList.toggle('is-active', isTarget);
630
+ }
631
+ }
632
+ }
633
+
634
+ // Keeps the open item's height correct if content reflows on resize (e.g. text wrapping)
635
+ function onResize() {
636
+ if (currentActive === -1) return;
637
+ var item = faqItems[currentActive].querySelector('.faq-item');
638
+ if (item) item.style.height = item.scrollHeight + 'px';
639
+ }
640
+
641
+ for (var i = 0; i < count; i++) {
642
+ (function (index) {
643
+ faqItems[index].addEventListener('click', function () {
644
+ var nextIndex = currentActive === index ? -1 : index;
645
+ setActive(nextIndex);
646
+ });
647
+ })(i);
648
+ }
649
+
650
+ window.addEventListener('resize', onResize);
651
+ };
652
+
653
+
654
+
655
+
656
+
657
+ window.navbarThemeWatcher = function () {
658
+ function checkNavbarTheme() {
659
+ var stack = document.elementsFromPoint(window.innerWidth / 2, 20);
660
+ var isDark = stack.some(function (el) {
661
+ return el.closest && el.closest('.is-dark-bg');
662
+ });
663
+ document.body.classList.toggle('is-nav-dark', isDark);
664
+ }
665
+
666
+ var ticking = false;
667
+ function onScroll() {
668
+ if (!ticking) {
669
+ requestAnimationFrame(function () {
670
+ checkNavbarTheme();
671
+ ticking = false;
672
+ });
673
+ ticking = true;
674
+ }
675
+ }
676
+
677
+ window.addEventListener('scroll', onScroll, { passive: true });
678
+ window.addEventListener('resize', onScroll);
679
+ checkNavbarTheme();
680
+ };
681
+
682
+
683
+
684
+
685
+
573
686
 
574
687
  window.stickyServices = function (e) {
575
688
  var wrapper = e;