Skip to content

Commit 5c7c8c4

Browse files
committed
try a different version
1 parent 662eb0e commit 5c7c8c4

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

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

+32-19
Original file line numberDiff line numberDiff line change
@@ -2693,26 +2693,39 @@ <h3>Proofs</h3>
26932693
closeOpenComponents();
26942694
});
26952695

2696-
let startX = 0;
2697-
let endX = 0;
2698-
2699-
document.addEventListener('touchstart', (e) => {
2700-
startX = e.changedTouches[0].clientX;
2701-
}, false);
2702-
2703-
document.addEventListener('touchmove', (e) => {
2704-
endX = e.changedTouches[0].clientX;
2705-
}, false);
2706-
2707-
document.addEventListener('touchend', () => {
2708-
const difference = endX - startX;
2709-
// Set a minimum distance to qualify as a swipe (e.g. 50px)
2710-
if (difference > 50) {
2711-
// Swiped from left to right => open sidebar
2696+
// Sidebar swipe gesture
2697+
let startX = 0; // Starting X coordinate
2698+
let currentX = 0; // Current X coordinate during touchmove
2699+
const swipeThreshold = 50; // Minimum distance to consider a swipe
2700+
2701+
// Add touch event listeners to the sidebar and main container
2702+
const mainContainer = document.querySelector('.main-container');
2703+
2704+
mainContainer.addEventListener('touchstart', (e) => {
2705+
startX = e.touches[0].clientX; // Record the starting touch point
2706+
});
2707+
2708+
mainContainer.addEventListener('touchmove', (e) => {
2709+
currentX = e.touches[0].clientX; // Update current touch point
2710+
});
2711+
2712+
mainContainer.addEventListener('touchend', () => {
2713+
const swipeDistance = currentX - startX;
2714+
2715+
if (swipeDistance > swipeThreshold) {
2716+
// Swipe Right - Show Sidebar
27122717
sidebar.classList.add('expanded');
2713-
} else if (difference < -50) {
2714-
// Swiped from right to left => close sidebar
2718+
sidebar.classList.remove('collapsed');
2719+
sidebarToggle.classList.add('active');
2720+
} else if (swipeDistance < -swipeThreshold) {
2721+
// Swipe Left - Hide Sidebar
27152722
sidebar.classList.remove('expanded');
2723+
sidebar.classList.add('collapsed');
2724+
sidebarToggle.classList.remove('active');
27162725
}
2717-
}, false);
2726+
2727+
// Reset touch positions
2728+
startX = 0;
2729+
currentX = 0;
2730+
});
27182731
</script>

0 commit comments

Comments
 (0)