diff --git a/src/components/profile/sortable-profile-item.tsx b/src/components/profile/sortable-profile-item.tsx index 4b53a26cb..b9c148574 100644 --- a/src/components/profile/sortable-profile-item.tsx +++ b/src/components/profile/sortable-profile-item.tsx @@ -4,6 +4,8 @@ import { Box } from '@mui/material' import { ProfileItem, type ProfileItemProps } from './profile-item' +const SORT_TRANSITION = 'transform 160ms cubic-bezier(0.2, 0, 0, 1)' + type SortableProfileItemProps = Omit< ProfileItemProps, 'dragHandleRef' | 'dragHandleAttributes' | 'dragHandleListeners' @@ -18,24 +20,33 @@ export const SortableProfileItem = ({ const { attributes, listeners, + setActivatorNodeRef, setNodeRef, transform, - transition, + isSorting, isDragging, - } = useSortable({ id }) + isOver, + } = useSortable({ id, transition: null }) + + const isDiagonalMove = + transform !== null && transform.x !== 0 && transform.y !== 0 return ( diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx index 60f6397a5..6f9f3f78f 100644 --- a/src/pages/profiles.tsx +++ b/src/pages/profiles.tsx @@ -1,9 +1,11 @@ import { closestCenter, + type CollisionDetection, DndContext, type DragEndEvent, DragOverlay, KeyboardSensor, + pointerWithin, PointerSensor, useSensor, useSensors, @@ -77,6 +79,11 @@ import { debugLog } from '@/utils/debug' const PROFILE_UPDATE_WORKER_LIMIT = 8 const PROFILE_SWITCH_LOADING_DELAY = 400 +const profileCollisionDetection: CollisionDetection = (args) => { + const pointerCollisions = pointerWithin(args) + return pointerCollisions.length > 0 ? pointerCollisions : closestCenter(args) +} + // Equivalent to rectSortingStrategy without copying the full rect array for every item. const profileRectSortingStrategy: SortingStrategy = ({ rects, @@ -928,7 +935,7 @@ const ProfilePage = () => {