fix: fixed scrolling by draggable on mobile

This commit is contained in:
2025-08-13 18:18:37 +04:00
parent 0836e4f0ca
commit 7932f3f5c8
2 changed files with 12 additions and 20 deletions

View File

@ -1,33 +1,28 @@
import {
KeyboardSensor,
PointerSensor,
MouseSensor,
TouchSensor,
useSensor,
useSensors,
} from "@dnd-kit/core";
import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
import useIsMobile from "@/hooks/useIsMobile";
const useDndSensors = () => {
const isMobile = useIsMobile();
const sensorOptions = {
activationConstraint: isMobile
? {
delay: 500,
tolerance: 5,
}
: {
distance: 5,
},
};
return useSensors(
useSensor(PointerSensor, sensorOptions),
useSensor(MouseSensor, {
activationConstraint: {
distance: 8,
},
}),
useSensor(KeyboardSensor, {
coordinateGetter: sortableKeyboardCoordinates,
}),
useSensor(TouchSensor, sensorOptions)
useSensor(TouchSensor, {
activationConstraint: {
delay: 300,
tolerance: 5,
},
})
);
};