Skip to content

Commit 5c6046d

Browse files
committed
I think i finally fixed it?
1 parent 86607d8 commit 5c6046d

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

LongevityWorldCup.Website/wwwroot/partials/leaderboard-content.html

+32-11
Original file line numberDiff line numberDiff line change
@@ -2676,14 +2676,17 @@ <h3>Proofs</h3>
26762676

26772677
sidebarClose.addEventListener('click', () => {
26782678
closeSidebar();
2679+
console.log("click close");
26792680
});
26802681

26812682
function toggleSidebar() {
26822683
if (sidebar.classList.contains('expanded')) {
26832684
closeSidebar();
2685+
console.log("close");
26842686
}
26852687
else {
26862688
openSidebar();
2689+
console.log("open");
26872690
}
26882691
}
26892692

@@ -2693,6 +2696,7 @@ <h3>Proofs</h3>
26932696

26942697
if (!sidebar.classList.contains('expanded')) {
26952698
sidebar.classList.add('expanded');
2699+
console.log("added expanded");
26962700
}
26972701
if (!sidebarToggle.classList.contains('active')) {
26982702
sidebarToggle.classList.add('active')
@@ -2710,6 +2714,7 @@ <h3>Proofs</h3>
27102714

27112715
function closeSidebar() {
27122716
sidebar.classList.remove('expanded');
2717+
console.log("removed expanded");
27132718
sidebarToggle.classList.remove('active');
27142719
sidebar.classList.remove('partially-expanded');
27152720
if (!sidebar.classList.contains('button-collapsed')) {
@@ -2726,24 +2731,40 @@ <h3>Proofs</h3>
27262731
// Sidebar swipe gesture
27272732
let startX = 0;
27282733
let endX = 0;
2734+
let startY = 0;
2735+
let endY = 0;
2736+
const SWIPE_THRESHOLD = 50; // Minimum distance to qualify as a swipe
2737+
const TAP_THRESHOLD = 10; // Allowable movement for taps
27292738

27302739
document.addEventListener('touchstart', (e) => {
27312740
startX = e.changedTouches[0].clientX;
2741+
startY = e.changedTouches[0].clientY;
27322742
}, false);
27332743

2734-
document.addEventListener('touchmove', (e) => {
2744+
document.addEventListener('touchend', (e) => {
27352745
endX = e.changedTouches[0].clientX;
2736-
}, false);
2746+
endY = e.changedTouches[0].clientY;
27372747

2738-
document.addEventListener('touchend', () => {
2739-
const difference = endX - startX;
2740-
// Set a minimum distance to qualify as a swipe (e.g. 50px)
2741-
if (difference > 50) {
2742-
// Swiped from left to right => open sidebar
2743-
openSidebar();
2744-
} else if (difference < -50) {
2745-
// Swiped from right to left => close sidebar
2746-
closeSidebar();
2748+
const deltaX = endX - startX; // Horizontal movement
2749+
const deltaY = endY - startY; // Vertical movement
2750+
2751+
// Check if it's a tap (small movement)
2752+
if (Math.abs(deltaX) < TAP_THRESHOLD && Math.abs(deltaY) < TAP_THRESHOLD) {
2753+
return; // Do nothing, treat as a tap
2754+
console.log("tap");
2755+
}
2756+
2757+
// Check for swipe
2758+
if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > SWIPE_THRESHOLD) {
2759+
if (deltaX > 0) {
2760+
// Swiped from left to right => open sidebar
2761+
openSidebar();
2762+
console.log("swiped open");
2763+
} else {
2764+
// Swiped from right to left => close sidebar
2765+
closeSidebar();
2766+
console.log("swiped close");
2767+
}
27472768
}
27482769
}, false);
27492770
</script>

0 commit comments

Comments
 (0)