fix: 滑卡退出距离自适应屏幕宽度,小屏设备体验更顺滑

This commit is contained in:
2026-02-26 16:33:41 +08:00
parent 37eb7f07d7
commit 31003110e1
+4 -2
View File
@@ -13,7 +13,8 @@ import RestaurantCard from "./RestaurantCard";
import { Restaurant, SwipeDirection } from "@/types";
const SWIPE_THRESHOLD = 120;
const EXIT_X = 600;
const getExitX = () =>
typeof window !== "undefined" ? window.innerWidth * 1.5 : 600;
const ROTATION_RANGE = 18;
interface SwipeableCardProps {
@@ -66,7 +67,8 @@ export default function SwipeableCard({
const flyOut = (direction: SwipeDirection) => {
if (isSwiping.current) return;
isSwiping.current = true;
const exitX = direction === "right" ? EXIT_X : -EXIT_X;
const exit = getExitX();
const exitX = direction === "right" ? exit : -exit;
animate(x, exitX, {
type: "spring",
stiffness: 600,