mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-19 18:32:10 +08:00
fix(profiles): stabilize drag reorder motion
Close: 7798
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
<DndContext
|
||||
sensors={sensors}
|
||||
collisionDetection={closestCenter}
|
||||
collisionDetection={profileCollisionDetection}
|
||||
onDragEnd={onDragEnd}
|
||||
>
|
||||
<Box
|
||||
|
||||
Reference in New Issue
Block a user