Skip to content

Commit afd1d7e

Browse files
davidagustinclaude
andcommitted
fix: smooth carousel transitions with sync mode and reduced slide distance
Change AnimatePresence from mode="wait" (jerk/gap between slides) to mode="sync" (simultaneous enter/exit). Reduce slide distance from 300px to 150px and use Material Design easing curve for smoother motion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ced5ba7 commit afd1d7e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/components/Projects.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ const CarouselView: React.FC<{
166166
const pageProjects = projects.slice(pageIndex, pageIndex + columns);
167167

168168
const variants = {
169-
enter: (d: number) => ({ x: d > 0 ? 300 : -300 }),
170-
center: { x: 0 },
171-
exit: (d: number) => ({ x: d > 0 ? -300 : 300 }),
169+
enter: (d: number) => ({ x: d > 0 ? 150 : -150, opacity: 0 }),
170+
center: { x: 0, opacity: 1 },
171+
exit: (d: number) => ({ x: d > 0 ? -150 : 150, opacity: 0 }),
172172
};
173173

174174
const gridClass =
@@ -201,15 +201,15 @@ const CarouselView: React.FC<{
201201

202202
{/* Cards Grid */}
203203
<div className={`overflow-hidden rounded-xl ${columns === 1 ? 'min-h-[420px]' : 'min-h-[480px]'}`}>
204-
<AnimatePresence mode="wait" custom={direction}>
204+
<AnimatePresence mode="sync" custom={direction}>
205205
<motion.div
206206
key={pageIndex}
207207
custom={direction}
208208
variants={variants}
209209
initial="enter"
210210
animate="center"
211211
exit="exit"
212-
transition={{ duration: 0.3, ease: 'easeInOut' }}
212+
transition={{ duration: 0.25, ease: [0.4, 0, 0.2, 1] }}
213213
className={`grid ${gridClass} gap-6`}
214214
>
215215
{pageProjects.map((project) => (

0 commit comments

Comments
 (0)