fix: 滑卡退出距离自适应屏幕宽度,小屏设备体验更顺滑
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user