Skip to content

Commit a5fb1e3

Browse files
committed
Merge branch 'master' of github.com:com-480-data-visualization/DataRizz
2 parents a4b0721 + 4c91114 commit a5fb1e3

3 files changed

Lines changed: 400 additions & 194 deletions

File tree

website/index.html

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,8 @@ <h2>Project Gamma</h2>
328328
<script>
329329
new fullpage('#website', {
330330
autoScrolling: true,
331-
332-
// We replace the default fullPage dots with our race track.
331+
scrollOverflow: true,
333332
navigation: false,
334-
335333
navigationPosition: 'right',
336334
scrollingSpeed: 700,
337335
slidesNavigation: true,
@@ -372,6 +370,111 @@ <h2>Project Gamma</h2>
372370
}
373371
}
374372
});
373+
374+
(function () {
375+
let lastMove = 0;
376+
let touchStartY = null;
377+
378+
function shouldForceScroll(target) {
379+
const activeSection = document.querySelector(".fp-section.active");
380+
const activeSlide = activeSection?.querySelector(".fp-slide.active");
381+
const slideAnchor = activeSlide?.dataset.anchor;
382+
383+
return (
384+
slideAnchor === "bodytype-viz" ||
385+
slideAnchor === "body-types-viz" ||
386+
slideAnchor === "geopolitics-viz" ||
387+
slideAnchor === "fair-viz" ||
388+
target.closest("#bodytype-viz") ||
389+
target.closest("#geopolitics-map-viz") ||
390+
target.closest("#geo-event-list") ||
391+
target.closest("#fair-viz")
392+
);
393+
}
394+
395+
function moveFullpage(deltaY, event) {
396+
if (!window.fullpage_api) return;
397+
if (Math.abs(deltaY) < 10) return;
398+
399+
const now = Date.now();
400+
if (now - lastMove < 750) {
401+
event.preventDefault();
402+
return;
403+
}
404+
405+
event.preventDefault();
406+
lastMove = now;
407+
408+
if (deltaY > 0) {
409+
window.fullpage_api.moveSectionDown();
410+
} else {
411+
window.fullpage_api.moveSectionUp();
412+
}
413+
}
414+
415+
document.addEventListener("wheel", function (event) {
416+
const target = event.target;
417+
418+
if (target.closest("select, option, button, input, textarea, a, .geo-popup-overlay")) {
419+
return;
420+
}
421+
422+
if (!shouldForceScroll(target)) return;
423+
424+
moveFullpage(event.deltaY, event);
425+
}, { passive: false, capture: true });
426+
427+
document.addEventListener("keydown", function (event) {
428+
if (!["ArrowDown", "PageDown", "ArrowUp", "PageUp"].includes(event.key)) return;
429+
430+
const target = event.target;
431+
if (target.closest("input, textarea, a, .geo-popup-overlay")) return;
432+
433+
document.querySelectorAll("select").forEach(select => {
434+
select.addEventListener("change", () => select.blur());
435+
});
436+
437+
const activeSection = document.querySelector(".fp-section.active");
438+
const activeSlide = activeSection?.querySelector(".fp-slide.active");
439+
const slideAnchor = activeSlide?.dataset.anchor;
440+
441+
const shouldForceScroll =
442+
slideAnchor === "bodytype-viz" ||
443+
slideAnchor === "body-types-viz" ||
444+
slideAnchor === "geopolitics-viz" ||
445+
slideAnchor === "fair-viz" ||
446+
slideAnchor === "never-medaled";
447+
448+
if (!shouldForceScroll || !window.fullpage_api) return;
449+
450+
event.preventDefault();
451+
452+
if (event.key === "ArrowDown" || event.key === "PageDown") {
453+
window.fullpage_api.moveSectionDown();
454+
} else {
455+
window.fullpage_api.moveSectionUp();
456+
}
457+
}, { capture: true });
458+
459+
document.addEventListener("touchstart", function (event) {
460+
touchStartY = event.touches[0].clientY;
461+
}, { passive: true, capture: true });
462+
463+
document.addEventListener("touchmove", function (event) {
464+
const target = event.target;
465+
466+
if (target.closest("select, option, button, input, textarea, a, .geo-popup-overlay")) {
467+
return;
468+
}
469+
470+
if (!shouldForceScroll(target) || touchStartY === null) return;
471+
472+
const currentY = event.touches[0].clientY;
473+
const deltaY = touchStartY - currentY;
474+
475+
moveFullpage(deltaY, event);
476+
}, { passive: false, capture: true });
477+
})();
375478
</script>
376479

377480
</html>

0 commit comments

Comments
 (0)