Enable intuitive swipe navigation for an improved mobile viewing experience

Adds touch event handlers to `FolxStadlPage`, `GeschichteLiedPage`, and `GipfelstammtischPage` components to implement left and right swipe gestures for page navigation.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 890577b1-c154-40a4-a177-a0c6d55320c3
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/890577b1-c154-40a4-a177-a0c6d55320c3/DyHCx4q
This commit is contained in:
sebastjanartic 2025-09-01 21:48:33 +00:00
parent 72414f8dc9
commit 57339147fc
3 changed files with 46 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import { ArrowLeft, ChevronLeft, ChevronRight, Menu, X } from 'lucide-react';
import VideoCard from '@/components/video-card';
import BunnyVideoModal from '@/components/bunny-video-modal';
import { Button } from '@/components/ui/button';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import type { Video } from '@shared/schema';
import { Input } from '@/components/ui/input';
import { Search } from 'lucide-react';
@ -17,6 +17,8 @@ export default function FolxStadlPage() {
const [searchQuery, setSearchQuery] = useState("");
const [viewMode, setViewMode] = useState<"grid" | "list">("grid");
const [, setLocation] = useLocation();
const [touchStart, setTouchStart] = useState<number>(0);
const [touchEnd, setTouchEnd] = useState<number>(0);
const itemsPerPage = 10;
const { data, isLoading } = useQuery<{videos: Video[], total: number}>({
@ -47,6 +49,35 @@ export default function FolxStadlPage() {
setSelectedVideo(null);
};
// Touch handlers for swipe navigation
const handleTouchStart = (e: React.TouchEvent) => {
setTouchEnd(0);
setTouchStart(e.targetTouches[0].clientX);
};
const handleTouchMove = (e: React.TouchEvent) => {
setTouchEnd(e.targetTouches[0].clientX);
};
const handleTouchEnd = () => {
if (!touchStart || !touchEnd) return;
const distance = touchStart - touchEnd;
const isLeftSwipe = distance > 50;
const isRightSwipe = distance < -50;
console.log('Swipe detected:', { distance, isLeftSwipe, isRightSwipe, currentPage, totalPages });
if (isLeftSwipe && currentPage < totalPages) {
setCurrentPage(currentPage + 1);
console.log('Swiped to next page:', currentPage + 1);
}
if (isRightSwipe && currentPage > 1) {
setCurrentPage(currentPage - 1);
console.log('Swiped to previous page:', currentPage - 1);
}
};
if (isLoading) {
return (
<div className="min-h-screen bg-bunny-dark flex items-center justify-center">
@ -184,7 +215,12 @@ export default function FolxStadlPage() {
</div>
{/* Main Content */}
<div className="container pt-8 pb-8">
<div
className="container pt-8 pb-8"
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
{/* Video List with Descriptions */}
<div className="space-y-6">

View File

@ -68,11 +68,15 @@ export default function GeschichteLiedPage() {
const isLeftSwipe = distance > 50;
const isRightSwipe = distance < -50;
console.log('Swipe detected:', { distance, isLeftSwipe, isRightSwipe, currentPage, totalPages });
if (isLeftSwipe && currentPage < totalPages) {
setCurrentPage(currentPage + 1);
console.log('Swiped to next page:', currentPage + 1);
}
if (isRightSwipe && currentPage > 1) {
setCurrentPage(currentPage - 1);
console.log('Swiped to previous page:', currentPage - 1);
}
};

View File

@ -68,11 +68,15 @@ export default function GipfelstammtischPage() {
const isLeftSwipe = distance > 50;
const isRightSwipe = distance < -50;
console.log('Swipe detected:', { distance, isLeftSwipe, isRightSwipe, currentPage, totalPages });
if (isLeftSwipe && currentPage < totalPages) {
setCurrentPage(currentPage + 1);
console.log('Swiped to next page:', currentPage + 1);
}
if (isRightSwipe && currentPage > 1) {
setCurrentPage(currentPage - 1);
console.log('Swiped to previous page:', currentPage - 1);
}
};