diff --git a/frontend/application/app/catalog/CatalogClient.tsx b/frontend/application/app/catalog/CatalogClient.tsx index b7fdbaab..8c7a728c 100644 --- a/frontend/application/app/catalog/CatalogClient.tsx +++ b/frontend/application/app/catalog/CatalogClient.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useRef } from "react"; import SafeImage from "../../components/SafeImage"; import { Download, Printer, ShieldCheck, Sparkles, CheckCircle2, ChevronLeft, Search, Filter } from "lucide-react"; import Link from "next/link"; @@ -14,6 +14,36 @@ export default function CatalogClient() { const [searchQuery, setSearchQuery] = useState(""); const [selectedCategory, setSelectedCategory] = useState("all"); + const scrollRef = useRef(null); + const [isMouseDown, setIsMouseDown] = useState(false); + const [startX, setStartX] = useState(0); + const [scrollLeft, setScrollLeft] = useState(0); + + const handleMouseDown = (e: React.MouseEvent) => { + if (!scrollRef.current) return; + setIsMouseDown(true); + setStartX(e.pageX - scrollRef.current.offsetLeft); + setScrollLeft(scrollRef.current.scrollLeft); + }; + + const handleMouseLeaveOrUp = () => { + setIsMouseDown(false); + }; + + const handleMouseMove = (e: React.MouseEvent) => { + if (!isMouseDown || !scrollRef.current) return; + e.preventDefault(); + const x = e.pageX - scrollRef.current.offsetLeft; + const walk = (x - startX) * 2; // scroll speed + scrollRef.current.scrollLeft = scrollLeft - walk; + }; + + const handleWheel = (e: React.WheelEvent) => { + if (scrollRef.current && e.deltaY !== 0) { + scrollRef.current.scrollLeft += e.deltaY; + } + }; + useEffect(() => { productService.getProducts({ limit: 999 }) .then(res => { @@ -97,7 +127,15 @@ export default function CatalogClient() { /> -
+