Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ <h2 class="section-title">Contact</h2>
var reduceMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var scrollDebounce = null;
var lastScrollIndex = -1;
var programmaticScrollIndex = null;
var programmaticScrollTimer = null;

function clearProgrammaticScroll() {
programmaticScrollIndex = null;
if (programmaticScrollTimer) {
clearTimeout(programmaticScrollTimer);
programmaticScrollTimer = null;
}
}

function markProgrammaticScroll(index) {
programmaticScrollIndex = index;
if (programmaticScrollTimer) clearTimeout(programmaticScrollTimer);
programmaticScrollTimer = window.setTimeout(clearProgrammaticScroll, 1000);
}

function indexFromCenter() {
if (!carousel) return 0;
Expand Down Expand Up @@ -251,6 +267,7 @@ <h2 class="section-title">Contact</h2>
}

if (!fromScroll) {
markProgrammaticScroll(index);
scrollTabToCenter(index);
}

Expand All @@ -264,6 +281,10 @@ <h2 class="section-title">Contact</h2>
if (scrollDebounce) clearTimeout(scrollDebounce);
scrollDebounce = setTimeout(function () {
scrollDebounce = null;
if (programmaticScrollIndex !== null) {
clearProgrammaticScroll();
return;
}
var idx = indexFromCenter();
if (idx === lastScrollIndex) return;
setActive(idx, false, true);
Expand Down Expand Up @@ -314,7 +335,7 @@ <h2 class="section-title">Contact</h2>
tabs.forEach(function (t, i) {
if (t.classList.contains('is-active')) initialIndex = i;
});
setActive(initialIndex, false, false);
setActive(initialIndex, false, true);
})();
</script>
</body>
Expand Down