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:
parent
72414f8dc9
commit
57339147fc
@ -4,7 +4,7 @@ import { ArrowLeft, ChevronLeft, ChevronRight, Menu, X } from 'lucide-react';
|
|||||||
import VideoCard from '@/components/video-card';
|
import VideoCard from '@/components/video-card';
|
||||||
import BunnyVideoModal from '@/components/bunny-video-modal';
|
import BunnyVideoModal from '@/components/bunny-video-modal';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import type { Video } from '@shared/schema';
|
import type { Video } from '@shared/schema';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Search } from 'lucide-react';
|
import { Search } from 'lucide-react';
|
||||||
@ -17,6 +17,8 @@ export default function FolxStadlPage() {
|
|||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [viewMode, setViewMode] = useState<"grid" | "list">("grid");
|
const [viewMode, setViewMode] = useState<"grid" | "list">("grid");
|
||||||
const [, setLocation] = useLocation();
|
const [, setLocation] = useLocation();
|
||||||
|
const [touchStart, setTouchStart] = useState<number>(0);
|
||||||
|
const [touchEnd, setTouchEnd] = useState<number>(0);
|
||||||
const itemsPerPage = 10;
|
const itemsPerPage = 10;
|
||||||
|
|
||||||
const { data, isLoading } = useQuery<{videos: Video[], total: number}>({
|
const { data, isLoading } = useQuery<{videos: Video[], total: number}>({
|
||||||
@ -47,6 +49,35 @@ export default function FolxStadlPage() {
|
|||||||
setSelectedVideo(null);
|
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) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-bunny-dark flex items-center justify-center">
|
<div className="min-h-screen bg-bunny-dark flex items-center justify-center">
|
||||||
@ -184,7 +215,12 @@ export default function FolxStadlPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main Content */}
|
{/* 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 */}
|
{/* Video List with Descriptions */}
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
|
|||||||
@ -67,12 +67,16 @@ export default function GeschichteLiedPage() {
|
|||||||
const distance = touchStart - touchEnd;
|
const distance = touchStart - touchEnd;
|
||||||
const isLeftSwipe = distance > 50;
|
const isLeftSwipe = distance > 50;
|
||||||
const isRightSwipe = distance < -50;
|
const isRightSwipe = distance < -50;
|
||||||
|
|
||||||
|
console.log('Swipe detected:', { distance, isLeftSwipe, isRightSwipe, currentPage, totalPages });
|
||||||
|
|
||||||
if (isLeftSwipe && currentPage < totalPages) {
|
if (isLeftSwipe && currentPage < totalPages) {
|
||||||
setCurrentPage(currentPage + 1);
|
setCurrentPage(currentPage + 1);
|
||||||
|
console.log('Swiped to next page:', currentPage + 1);
|
||||||
}
|
}
|
||||||
if (isRightSwipe && currentPage > 1) {
|
if (isRightSwipe && currentPage > 1) {
|
||||||
setCurrentPage(currentPage - 1);
|
setCurrentPage(currentPage - 1);
|
||||||
|
console.log('Swiped to previous page:', currentPage - 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -67,12 +67,16 @@ export default function GipfelstammtischPage() {
|
|||||||
const distance = touchStart - touchEnd;
|
const distance = touchStart - touchEnd;
|
||||||
const isLeftSwipe = distance > 50;
|
const isLeftSwipe = distance > 50;
|
||||||
const isRightSwipe = distance < -50;
|
const isRightSwipe = distance < -50;
|
||||||
|
|
||||||
|
console.log('Swipe detected:', { distance, isLeftSwipe, isRightSwipe, currentPage, totalPages });
|
||||||
|
|
||||||
if (isLeftSwipe && currentPage < totalPages) {
|
if (isLeftSwipe && currentPage < totalPages) {
|
||||||
setCurrentPage(currentPage + 1);
|
setCurrentPage(currentPage + 1);
|
||||||
|
console.log('Swiped to next page:', currentPage + 1);
|
||||||
}
|
}
|
||||||
if (isRightSwipe && currentPage > 1) {
|
if (isRightSwipe && currentPage > 1) {
|
||||||
setCurrentPage(currentPage - 1);
|
setCurrentPage(currentPage - 1);
|
||||||
|
console.log('Swiped to previous page:', currentPage - 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user