@widelab-nc/widelab 1.1.46 → 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/dist/index.js +3 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/index.js +102 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -550,6 +550,108 @@ 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';
|
|
557
|
+
|
|
558
|
+
var items = wrapper.querySelectorAll('.process-item');
|
|
559
|
+
var count = items.length;
|
|
560
|
+
if (count === 0) return;
|
|
561
|
+
|
|
562
|
+
var currentActive = -1;
|
|
563
|
+
var ticking = false;
|
|
564
|
+
|
|
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();
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
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
|
+
|
|
553
655
|
|
|
554
656
|
|
|
555
657
|
window.navbarThemeWatcher = function () {
|