fix(focus): prevent card rebound on swipe release by freezing exit position

This commit is contained in:
Michael committed 2026-02-13 08:41:56 +01:00
1 parent 9d41a74b36
commit b04dc992d9
2 files changed
+113 -70

No files matched your search

+3 -3
View File
@@ -24,7 +24,7 @@ interface FocusCardStackProps {
export function FocusCardStack({ articles, onMarkRead, onKeep, onToggleFavorite, onEmpty }: FocusCardStackProps) {
const [currentIndex, setCurrentIndex] = useState(0);
const [readingArticle, setReadingArticle] = useState<Article | null>(null);
// const [exitX, setExitX] = useState(0); // Removed per simplification
const [exitX, setExitX] = useState(0);
const isMobile = useIsMobile();
const [isProcessing, setIsProcessing] = useState(false);
@@ -84,7 +84,7 @@ export function FocusCardStack({ articles, onMarkRead, onKeep, onToggleFavorite,
if (!active && trigger) {
// Swipe Validé
const isRight = mx > 0;
// setExitX(isRight ? 500 : -500); // Trigger exit animation - Removed lateral movement per user request
setExitX(x.get()); // Capture current position to freeze exit animation
// Trigger action via handler
handleAction(isRight ? 'read' : 'keep');
@@ -208,7 +208,7 @@ export function FocusCardStack({ articles, onMarkRead, onKeep, onToggleFavorite,
}
}}
animate={{ scale: 1 - i * 0.05, y: i * 20 }}
exit={{ opacity: 0, scale: 0.9, transition: { duration: 0.2 } }}
exit={{ x: exitX, opacity: 0, scale: 0.9, transition: { duration: 0.2 } }}
>
<FocusCard article={article} isTop={isTop} />
</motion.div>