feat: adapt portfolio sections for smaller screens
This commit is contained in:
@@ -6,8 +6,6 @@ import { ArrowLeft, ArrowRight, ArrowUpRight } from 'lucide-react';
|
||||
import { projects } from '@/data/projects';
|
||||
import styles from './ProjectsSection.module.css';
|
||||
|
||||
const CARD_STEP = 384;
|
||||
|
||||
export const ProjectsSection: React.FC = () => {
|
||||
const viewportRef = useRef<HTMLDivElement>(null);
|
||||
const dragState = useRef({
|
||||
@@ -40,8 +38,14 @@ export const ProjectsSection: React.FC = () => {
|
||||
}, []);
|
||||
|
||||
const scrollByCard = (direction: -1 | 1) => {
|
||||
viewportRef.current?.scrollBy({
|
||||
left: direction * CARD_STEP,
|
||||
const viewport = viewportRef.current;
|
||||
const track = viewport?.firstElementChild as HTMLElement | null;
|
||||
const card = track?.firstElementChild as HTMLElement | null;
|
||||
if (!viewport || !track || !card) return;
|
||||
|
||||
const gap = Number.parseFloat(window.getComputedStyle(track).columnGap) || 0;
|
||||
viewport.scrollBy({
|
||||
left: direction * (card.getBoundingClientRect().width + gap),
|
||||
behavior: 'smooth',
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user